From 5f07a24bf8f9e4477459d2b5351ece79d7acb0f1 Mon Sep 17 00:00:00 2001 From: YoungWan Kwon <87213416+000wan@users.noreply.github.com> Date: Tue, 3 Oct 2023 06:36:29 +0900 Subject: [PATCH] Add `miri` to github ci (#72) * Add miri to github ci * Fix test errors * Decrease test matrix size for miri * Use random for testing `nbyte_add_mod` * Revert "Use random for testing `nbyte_add_mod`" This reverts commit 51a9ef331e22b508f34052a548599322979e6dbd. * Assign target packages for miri test * Reduce test sizes for miri * Test miri for both x86_64 and aarch64 --- .github/workflows/rust.yml | 19 +++++++++++++++++++ clmul/src/backend/clmul.rs | 4 ++++ matrix-transpose/src/lib.rs | 12 ++++++------ ot/mpz-ot/src/kos/receiver.rs | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 495996d6..9b8acea5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -37,6 +37,25 @@ jobs: # RUSTDOCFLAGS: -D warnings run: cargo doc --no-deps --workspace --lib --document-private-items --examples + miri: + if: ( ! github.event.pull_request.draft ) + name: "Miri" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Miri + run: | + rustup toolchain install nightly --component miri + rustup override set nightly + cargo miri setup + + - name: Test with Miri on x86_64 + run: cargo miri test -p clmul -p matrix-transpose --target x86_64-unknown-linux-gnu + + - name: Test with Miri on aarch64 + run: cargo miri test -p clmul -p matrix-transpose --target aarch64-unknown-linux-gnu + rustfmt_and_clippy: name: Rustfmt and Clippy runs-on: ubuntu-latest diff --git a/clmul/src/backend/clmul.rs b/clmul/src/backend/clmul.rs index f0444b84..678d5918 100644 --- a/clmul/src/backend/clmul.rs +++ b/clmul/src/backend/clmul.rs @@ -155,6 +155,10 @@ mod tests { #[test] fn test_against_emptool_impl() { + if !is_x86_feature_detected!("pclmulqdq") { + return; + } + let mut rng = ChaCha12Rng::from_seed([0; 32]); let a: [u8; 16] = rng.gen(); let b: [u8; 16] = rng.gen(); diff --git a/matrix-transpose/src/lib.rs b/matrix-transpose/src/lib.rs index d2e542b1..1bdb20d6 100644 --- a/matrix-transpose/src/lib.rs +++ b/matrix-transpose/src/lib.rs @@ -110,8 +110,8 @@ mod tests { #[test] fn test_transpose_bits() { - let rows = 512; - let columns = 256; + let rows = 64; + let columns = 32; let mut matrix: Vec = random_vec::(columns * rows); let naive = transpose_naive(&matrix, columns); @@ -154,9 +154,9 @@ mod tests { #[test] fn test_transpose() { - let rounds = 7_u32; + let rounds = 6_u32; let mut rows = 2_usize.pow(rounds); - let mut columns = 64; + let mut columns = 32; let mut matrix: Vec = random_vec::(columns * rows); let original = matrix.clone(); @@ -177,8 +177,8 @@ mod tests { #[test] fn test_bitmask_shift() { - let columns = 64; - let rows = 128; + let columns = 32; + let rows = 64; let mut matrix: Vec = random_vec::(columns * rows); let mut original = matrix.clone(); diff --git a/ot/mpz-ot/src/kos/receiver.rs b/ot/mpz-ot/src/kos/receiver.rs index 3856e145..8fe4b11d 100644 --- a/ot/mpz-ot/src/kos/receiver.rs +++ b/ot/mpz-ot/src/kos/receiver.rs @@ -182,7 +182,7 @@ where let actual_delta = <[u8; 16]>::from_lsb0_iter(choices).into(); if expected_delta != actual_delta { - return Err(ReceiverVerifyError::InconsistentDelta).map_err(ReceiverError::from)?; + return Err(ReceiverError::from(ReceiverVerifyError::InconsistentDelta)); } self.state = State::Verify(receiver.start_verification(actual_delta)?);