diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5ae3aa9c..f522d468e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: name: Lint (${{ matrix.os }} + ${{ matrix.channel }}) needs: [format, format-cargo-toml, docs] strategy: - fail-fast: false + fail-fast: true matrix: os: - ubuntu-latest @@ -58,15 +58,16 @@ jobs: - run: cargo hakari manage-deps --yes - run: cargo hakari verify - run: cargo install cargo-hack --locked - - run: cargo hack clippy --workspace --feature-powerset - - run: cargo hack clippy --workspace --feature-powerset --bins - - run: cargo hack clippy --workspace --feature-powerset --examples - - run: cargo hack clippy --workspace --feature-powerset --tests + - run: cargo clippy --workspace --all-features -vv + - run: cargo hack clippy --workspace --feature-powerset --depth 3 --tests + - run: cargo hack clippy --workspace --feature-powerset --depth 3 + - run: cargo hack clippy --workspace --feature-powerset --depth 3 --bins + - run: cargo hack clippy --workspace --feature-powerset --depth 3 --examples test: name: Test (${{ matrix.os }} + ${{ matrix.channel }}) needs: [format, format-cargo-toml, docs] strategy: - fail-fast: false + fail-fast: true matrix: os: - macos-latest @@ -85,7 +86,7 @@ jobs: name: Compile Benchmarks (${{ matrix.os }} + ${{ matrix.channel }}) needs: [format, format-cargo-toml, docs] strategy: - fail-fast: false + fail-fast: true matrix: os: - macos-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index edf94f61d..a15832cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Removed ### Fixed +- [\#302](https://github.com/Manta-Network/manta-rs/pull/302) Fix fuzzing test bug - [\#296](https://github.com/Manta-Network/manta-rs/pull/296) Fix AssetMetadata display for values less than 1 - [\#294](https://github.com/Manta-Network/manta-rs/pull/294) Distinguish between panic-errors and possible-fix-errors diff --git a/manta-crypto/src/arkworks/ff.rs b/manta-crypto/src/arkworks/ff.rs index bd35bb3cf..39895dabf 100644 --- a/manta-crypto/src/arkworks/ff.rs +++ b/manta-crypto/src/arkworks/ff.rs @@ -17,6 +17,7 @@ //! Arkworks Finite Field Backend use manta_util::{byte_count, into_array_unchecked}; +use num_integer::Integer; #[doc(inline)] pub use ark_ff::*; @@ -53,6 +54,23 @@ field_try_into! { try_into_u128 => u128, } +/// Divides the [`BigInteger`]s `n` by `m` and returns the quotient and the remainder. +#[inline] +pub fn div_rem(n: B, m: B) -> (B, B) +where + B: BigInteger, +{ + let (quotient, remainder) = n.into().div_rem(&m.into()); + ( + B::try_from(quotient) + .ok() + .expect("Unable to compute modular reduction."), + B::try_from(remainder) + .ok() + .expect("Unable to compute modular reduction."), + ) +} + /// Testing Suite #[cfg(test)] mod test { diff --git a/manta-crypto/src/rand.rs b/manta-crypto/src/rand.rs index a81708a76..d5073a512 100644 --- a/manta-crypto/src/rand.rs +++ b/manta-crypto/src/rand.rs @@ -539,7 +539,7 @@ pub mod fuzz { use super::*; #[cfg(all(feature = "arkworks", feature = "rand"))] - use crate::arkworks::ff::{BigInteger, PrimeField}; + use crate::arkworks::ff::{div_rem, BigInteger, FpParameters, PrimeField}; /// Fuzz Trait pub trait Fuzz { @@ -612,7 +612,8 @@ pub mod fuzz { where R: RngCore + ?Sized, { - P::from_repr(self.into_repr().fuzz(rng)) + let (_, fuzzed_element) = div_rem(self.into_repr().fuzz(rng), P::Params::MODULUS); + P::from_repr(fuzzed_element) .expect("Computing the field element from a big integer is not supposed to fail.") } } diff --git a/manta-trusted-setup/src/groth16/ppot/serialization.rs b/manta-trusted-setup/src/groth16/ppot/serialization.rs index 39794c596..94a998256 100644 --- a/manta-trusted-setup/src/groth16/ppot/serialization.rs +++ b/manta-trusted-setup/src/groth16/ppot/serialization.rs @@ -785,11 +785,9 @@ mod tests { const N: usize = 100; // number of samples let mut rng = ChaCha20Rng::from_seed([0; 32]); let g1: Vec = (0..N) - .into_iter() .map(|_| ::Projective::gen(&mut rng).into_affine()) .collect(); let g2: Vec = (0..N) - .into_iter() .map(|_| ::Projective::gen(&mut rng).into_affine()) .collect();