Skip to content

Commit

Permalink
Only use num-bigint-dig in benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
fjarri committed Dec 23, 2023
1 parent ba54933 commit 223ad5e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ zeroize = { version = "1", optional = true, default-features = false }
bincode = "1"
criterion = { version = "0.5", features = ["html_reports"] }
hex-literal = "0.4"
num-bigint = { package = "num-bigint-dig", version = "0.8" }
num-bigint-dig = "0.8"
num-bigint = "0.4"
num-integer = "0.1"
num-modular = { version = "0.5", features = ["num-bigint"] }
proptest = "1"
rand_core = { version = "0.6", features = ["std"] }
rand_chacha = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion benches/boxed_monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crypto_bigint::{
modular::{BoxedMontyForm, BoxedMontyParams},
BoxedUint, NonZero, Odd, RandomMod,
};
use num_bigint::BigUint;
use num_bigint_dig::BigUint;
use rand_core::OsRng;

/// Size of `BoxedUint` to use in benchmark.
Expand Down
7 changes: 4 additions & 3 deletions tests/boxed_monty_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use crypto_bigint::{
modular::{BoxedMontyForm, BoxedMontyParams},
BoxedUint, Integer, Inverter, Limb, NonZero, Odd, PrecomputeInverter,
};
use num_bigint::{BigUint, ModInverse};
use num_bigint::BigUint;
use num_modular::ModularUnaryOps;
use proptest::prelude::*;
use std::cmp::Ordering;

Expand Down Expand Up @@ -84,7 +85,7 @@ proptest! {

let x_bi = retrieve_biguint(&x);
let n_bi = to_biguint(n.modulus());
let expected = x_bi.mod_inverse(&n_bi);
let expected = x_bi.invm(&n_bi);

match (expected, actual) {
(Some(exp), Some(act)) => prop_assert_eq!(exp, to_biguint(&act).into()),
Expand All @@ -101,7 +102,7 @@ proptest! {

let x_bi = retrieve_biguint(&x);
let n_bi = to_biguint(n.modulus());
let expected = x_bi.mod_inverse(&n_bi);
let expected = x_bi.invm(&n_bi);

match (expected, actual) {
(Some(exp), Some(act)) => {
Expand Down
5 changes: 3 additions & 2 deletions tests/boxed_uint_proptests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use core::cmp::Ordering;
use crypto_bigint::{BoxedUint, CheckedAdd, Integer, Limb, NonZero};
use num_bigint::{BigUint, ModInverse};
use num_bigint::BigUint;
use num_integer::Integer as _;
use num_modular::ModularUnaryOps;
use num_traits::identities::One;
use proptest::prelude::*;

Expand Down Expand Up @@ -170,7 +171,7 @@ proptest! {

let a_bi = to_biguint(&a);
let b_bi = to_biguint(&b);
let expected = a_bi.mod_inverse(b_bi);
let expected = a_bi.invm(&b_bi);
let actual = Option::from(a.inv_mod(&b));

match (expected, actual) {
Expand Down
7 changes: 4 additions & 3 deletions tests/const_monty_form.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Equivalence tests between `crypto_bigint::ConstMontyForm` and `num-bigint`.
use crypto_bigint::{impl_modulus, modular::ConstMontyParams, Encoding, Invert, Inverter, U256};
use num_bigint::{BigUint, ModInverse};
use num_bigint::BigUint;
use num_modular::ModularUnaryOps;
use proptest::prelude::*;

impl_modulus!(
Expand Down Expand Up @@ -38,7 +39,7 @@ proptest! {

let x_bi = retrieve_biguint(&x);
let n_bi = to_biguint(&Modulus::MODULUS);
let expected = x_bi.mod_inverse(&n_bi);
let expected = x_bi.invm(&n_bi);

match (expected, actual) {
(Some(exp), Some(act)) => {
Expand All @@ -59,7 +60,7 @@ proptest! {

let x_bi = retrieve_biguint(&x);
let n_bi = to_biguint(&Modulus::MODULUS);
let expected = x_bi.mod_inverse(&n_bi);
let expected = x_bi.invm(&n_bi);

match (expected, actual) {
(Some(exp), Some(act)) => {
Expand Down
7 changes: 4 additions & 3 deletions tests/monty_form.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Equivalence tests between `crypto_bigint::MontyForm` and `num-bigint`.
use crypto_bigint::{Encoding, Integer, Invert, Inverter, NonZero, Odd, PrecomputeInverter, U256};
use num_bigint::{BigUint, ModInverse};
use num_bigint::BigUint;
use num_modular::ModularUnaryOps;
use proptest::prelude::*;

type MontyForm = crypto_bigint::modular::MontyForm<{ U256::LIMBS }>;
Expand Down Expand Up @@ -45,7 +46,7 @@ proptest! {

let x_bi = retrieve_biguint(&x);
let n_bi = to_biguint(n.modulus());
let expected = x_bi.mod_inverse(&n_bi);
let expected = x_bi.invm(&n_bi);

match (expected, actual) {
(Some(exp), Some(act)) => {
Expand All @@ -66,7 +67,7 @@ proptest! {

let x_bi = retrieve_biguint(&x);
let n_bi = to_biguint(n.modulus());
let expected = x_bi.mod_inverse(&n_bi);
let expected = x_bi.invm(&n_bi);

match (expected, actual) {
(Some(exp), Some(act)) => {
Expand Down

0 comments on commit 223ad5e

Please sign in to comment.