Switch to new fast-paillier with backend choice #739
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: | |
| push: | |
| branches: [ "m" ] | |
| pull_request: | |
| branches: [ "**" ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_NET_GIT_FETCH_WITH_CLI: true | |
| RUSTFLAGS: --deny warnings | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Build | |
| run: cargo build --release --all-features | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-tool | |
| path: target/release/measure_perf | |
| # Checks each library without default features. For libraries that require a | |
| # backend choice and thus don't compile with default features, test with both | |
| # backends | |
| bare_check: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| package: | |
| - name: key-share | |
| - name: cggmp24-keygen | |
| - name: cggmp24 | |
| backend: "--features=backend-num-bigint,std" | |
| - name: paillier-zk | |
| backend: "--features=backend-num-bigint,std" | |
| - name: cggmp24 | |
| backend: "--features=backend-rug,std" | |
| - name: paillier-zk | |
| backend: "--features=backend-rug,std" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Build | |
| run: cargo check --no-default-features ${{ matrix.package.backend }} --package ${{ matrix.package.name }} | |
| check-wasm-nostd: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Install wasm32-unknown-unknown toolchain | |
| run: rustup target add wasm32-unknown-unknown | |
| - name: Build on wasm32-unknown-unknown (no_std) | |
| run: | | |
| cargo check --no-default-features \ | |
| --features backend-num-bigint,no_std,serde,hd-wallet,spof,udigest,state-machine \ | |
| --workspace --exclude cggmp24-tests \ | |
| --target wasm32-unknown-unknown | |
| # Run tests with default features (num-bigint) (without HD wallets support) | |
| test-default-features: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Run tests | |
| # we exclude paillier-zk, as tests require __internal_doctest to be enabled | |
| run: cargo test --release --workspace --exclude paillier-zk | |
| # Run tests with default features and rug (without HD wallets support) | |
| test-rug-default-features: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Run tests | |
| # we exclude paillier-zk, as tests require __internal_doctest to be enabled | |
| run: | | |
| cargo test --release --workspace --exclude paillier-zk \ | |
| --no-default-features --features std,backend-rug | |
| # Run tests with all features, including HD wallets support (num-bigint) | |
| test-all-features: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Run tests | |
| run: cargo test --release --all-features | |
| # Run tests with all features, including HD wallets support (rug) | |
| test-rug-all-features: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Run tests | |
| run: | | |
| # We can't set --all-features as that will set backend-num-bigint which overrides rug, so we list all features except that | |
| features=std,hd-wallet,serde,state-machine,all-curves,hd-slip10,hd-stark,spof,insecure-assume-preimage-known,__internal_doctest,backend-rug | |
| # Check that num-bigint was not present as a dependency of fast-paillier, but rug was | |
| found_rug=$(cargo tree --edges=features --no-default-features --features $features --no-dedupe --invert fast-paillier | | |
| grep backend-rug -q || echo NOTFOUND) | |
| found_nbi=$(cargo tree --edges=features --no-default-features --features $features --no-dedupe --invert fast-paillier | | |
| grep backend-num-bigint -q || echo NOTFOUND) | |
| if [ NOTFOUND != "$found_nbi" ]; then | |
| echo "found num-bigint in dependencies of fast-paillier when the num-bigint backend should not be selected!" | |
| exit 1 | |
| fi | |
| if [ NOTFOUND == "$found_rug" ]; then | |
| echo "rug not found in dependencies of fast-paillier; this means that our detection script broke" | |
| exit 1 | |
| fi | |
| cargo test --release --no-default-features --features $features | |
| fmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| clippy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Run clippy | |
| run: cargo clippy --all --all-features --lib --exclude cggmp24-tests -- --no-deps -D clippy::all -D clippy::unwrap_used -D clippy::expect_used | |
| clippy-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Run clippy tests | |
| run: cargo clippy --tests --all-features --lib -- -D clippy::all | |
| check-doc: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: dtolnay/rust-toolchain@nightly | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: "true" | |
| - name: Check docs | |
| run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --all-features --no-deps | |
| bench: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: benchmark-tool | |
| - name: Set file permissions | |
| run: chmod +x ./measure_perf | |
| - name: Run benchmarks | |
| run: | | |
| ./measure_perf -n 3 --no-bench-primes-gen > perf_output | |
| sed -e '/PERF_OUTPUT/{r perf_output' -e 'd}' .github/pr-comment.tpl > pr-comment | |
| - name: Leave PR comment | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: bench | |
| path: pr-comment | |
| check-changelog: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check changelogs | |
| run: ./.github/changelog.sh |