Skip to content

Commit

Permalink
Merge branch 'main' into retrieve_transaction_data
Browse files Browse the repository at this point in the history
  • Loading branch information
bhgomes authored Jan 11, 2023
2 parents cca360c + e6edcad commit 70877a6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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

Expand Down
18 changes: 18 additions & 0 deletions manta-crypto/src/arkworks/ff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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<B>(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 {
Expand Down
5 changes: 3 additions & 2 deletions manta-crypto/src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<M = ()> {
Expand Down Expand Up @@ -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.")
}
}
Expand Down

0 comments on commit 70877a6

Please sign in to comment.