Skip to content

Commit eb2997b

Browse files
committed
Only use num-bigint-dig in benchmarks
1 parent 548a473 commit eb2997b

File tree

7 files changed

+42
-12
lines changed

7 files changed

+42
-12
lines changed

Cargo.lock

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ zeroize = { version = "1", optional = true, default-features = false }
3232
bincode = "1"
3333
criterion = { version = "0.5", features = ["html_reports"] }
3434
hex-literal = "0.4"
35-
num-bigint = { package = "num-bigint-dig", version = "0.8" }
35+
num-bigint-dig = "0.8"
36+
num-bigint = "0.4"
3637
num-integer = "0.1"
38+
num-modular = { version = "0.5", features = ["num-bigint"] }
3739
proptest = "1"
3840
rand_core = { version = "0.6", features = ["std"] }
3941
rand_chacha = "0.3"

benches/boxed_monty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crypto_bigint::{
66
modular::{BoxedMontyForm, BoxedMontyParams},
77
BoxedUint, NonZero, Odd, RandomMod,
88
};
9-
use num_bigint::BigUint;
9+
use num_bigint_dig::BigUint;
1010
use rand_core::OsRng;
1111

1212
/// Size of `BoxedUint` to use in benchmark.

tests/boxed_monty_form.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use crypto_bigint::{
66
modular::{BoxedMontyForm, BoxedMontyParams},
77
BoxedUint, Integer, Limb, NonZero, Odd,
88
};
9-
use num_bigint::{BigUint, ModInverse};
9+
use num_bigint::BigUint;
10+
use num_modular::ModularUnaryOps;
1011
use proptest::prelude::*;
1112
use std::cmp::Ordering;
1213

@@ -84,7 +85,7 @@ proptest! {
8485

8586
let x_bi = retrieve_biguint(&x);
8687
let n_bi = to_biguint(n.modulus());
87-
let expected = x_bi.mod_inverse(&n_bi);
88+
let expected = x_bi.invm(&n_bi);
8889

8990
match (expected, actual) {
9091
(Some(exp), Some(act)) => prop_assert_eq!(exp, to_biguint(&act).into()),

tests/boxed_uint_proptests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
use core::cmp::Ordering;
66
use crypto_bigint::{BoxedUint, CheckedAdd, Integer, Limb, NonZero};
7-
use num_bigint::{BigUint, ModInverse};
7+
use num_bigint::BigUint;
8+
use num_modular::ModularUnaryOps;
89
use num_traits::identities::One;
910
use proptest::prelude::*;
1011

@@ -153,7 +154,7 @@ proptest! {
153154

154155
let a_bi = to_biguint(&a);
155156
let b_bi = to_biguint(&b);
156-
let expected = a_bi.mod_inverse(b_bi);
157+
let expected = a_bi.invm(&b_bi);
157158
let actual = Option::from(a.inv_mod(&b));
158159

159160
match (expected, actual) {

tests/const_monty_form.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Equivalence tests between `crypto_bigint::ConstMontyForm` and `num-bigint`.
22
33
use crypto_bigint::{impl_modulus, modular::ConstMontyParams, Encoding, Invert, Inverter, U256};
4-
use num_bigint::{BigUint, ModInverse};
4+
use num_bigint::BigUint;
5+
use num_modular::ModularUnaryOps;
56
use proptest::prelude::*;
67

78
impl_modulus!(
@@ -38,7 +39,7 @@ proptest! {
3839

3940
let x_bi = retrieve_biguint(&x);
4041
let n_bi = to_biguint(&Modulus::MODULUS);
41-
let expected = x_bi.mod_inverse(&n_bi);
42+
let expected = x_bi.invm(&n_bi);
4243

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

6061
let x_bi = retrieve_biguint(&x);
6162
let n_bi = to_biguint(&Modulus::MODULUS);
62-
let expected = x_bi.mod_inverse(&n_bi);
63+
let expected = x_bi.invm(&n_bi);
6364

6465
match (expected, actual) {
6566
(Some(exp), Some(act)) => {

tests/monty_form.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Equivalence tests between `crypto_bigint::MontyForm` and `num-bigint`.
22
33
use crypto_bigint::{Encoding, Integer, Invert, Inverter, NonZero, Odd, PrecomputeInverter, U256};
4-
use num_bigint::{BigUint, ModInverse};
4+
use num_bigint::BigUint;
5+
use num_modular::ModularUnaryOps;
56
use proptest::prelude::*;
67

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

4647
let x_bi = retrieve_biguint(&x);
4748
let n_bi = to_biguint(n.modulus());
48-
let expected = x_bi.mod_inverse(&n_bi);
49+
let expected = x_bi.invm(&n_bi);
4950

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

6768
let x_bi = retrieve_biguint(&x);
6869
let n_bi = to_biguint(n.modulus());
69-
let expected = x_bi.mod_inverse(&n_bi);
70+
let expected = x_bi.invm(&n_bi);
7071

7172
match (expected, actual) {
7273
(Some(exp), Some(act)) => {

0 commit comments

Comments
 (0)