@@ -22,8 +22,8 @@ fn make_rng() -> ChaCha8Rng {
2222    ChaCha8Rng :: from_seed ( * b"01234567890123456789012345678901" ) 
2323} 
2424
25- fn  make_sieve < const  L :  usize > ( rng :  & mut  impl  CryptoRngCore )  -> Sieve < L >  { 
26-     let  start = random_odd_uint :: < L > ( rng,  Uint :: < L > :: BITS ) ; 
25+ fn  make_sieve < const  L :  usize > ( rng :  & mut  impl  CryptoRngCore )  -> Sieve < Uint < L > >  { 
26+     let  start = random_odd_uint :: < Uint < L > > ( rng,  Uint :: < L > :: BITS ) ; 
2727    Sieve :: new ( & start,  Uint :: < L > :: BITS ,  false ) 
2828} 
2929
@@ -36,13 +36,13 @@ fn bench_sieve(c: &mut Criterion) {
3636    let  mut  group = c. benchmark_group ( "Sieve" ) ; 
3737
3838    group. bench_function ( "(U128) random start" ,  |b| { 
39-         b. iter ( || random_odd_uint :: < {  nlimbs ! ( 128 )  } > ( & mut  OsRng ,  128 ) ) 
39+         b. iter ( || random_odd_uint :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  OsRng ,  128 ) ) 
4040    } ) ; 
4141
4242    group. bench_function ( "(U128) creation" ,  |b| { 
4343        b. iter_batched ( 
44-             || random_odd_uint :: < {  nlimbs ! ( 128 )  } > ( & mut  OsRng ,  128 ) , 
45-             |start| Sieve :: new ( & start,  128 ,  false ) , 
44+             || random_odd_uint :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  OsRng ,  128 ) , 
45+             |start| Sieve :: new ( start. as_ref ( ) ,  128 ,  false ) , 
4646            BatchSize :: SmallInput , 
4747        ) 
4848    } ) ; 
@@ -57,13 +57,13 @@ fn bench_sieve(c: &mut Criterion) {
5757    } ) ; 
5858
5959    group. bench_function ( "(U1024) random start" ,  |b| { 
60-         b. iter ( || random_odd_uint :: < {  nlimbs ! ( 1024 )  } > ( & mut  OsRng ,  1024 ) ) 
60+         b. iter ( || random_odd_uint :: < Uint < {  nlimbs ! ( 1024 )  } > > ( & mut  OsRng ,  1024 ) ) 
6161    } ) ; 
6262
6363    group. bench_function ( "(U1024) creation" ,  |b| { 
6464        b. iter_batched ( 
65-             || random_odd_uint :: < {  nlimbs ! ( 1024 )  } > ( & mut  OsRng ,  1024 ) , 
66-             |start| Sieve :: new ( & start,  1024 ,  false ) , 
65+             || random_odd_uint :: < Uint < {  nlimbs ! ( 1024 )  } > > ( & mut  OsRng ,  1024 ) , 
66+             |start| Sieve :: new ( start. as_ref ( ) ,  1024 ,  false ) , 
6767            BatchSize :: SmallInput , 
6868        ) 
6969    } ) ; 
@@ -84,7 +84,7 @@ fn bench_miller_rabin(c: &mut Criterion) {
8484
8585    group. bench_function ( "(U128) creation" ,  |b| { 
8686        b. iter_batched ( 
87-             || random_odd_uint :: < {  nlimbs ! ( 128 )  } > ( & mut  OsRng ,  128 ) , 
87+             || random_odd_uint :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  OsRng ,  128 ) , 
8888            MillerRabin :: new, 
8989            BatchSize :: SmallInput , 
9090        ) 
@@ -100,7 +100,7 @@ fn bench_miller_rabin(c: &mut Criterion) {
100100
101101    group. bench_function ( "(U1024) creation" ,  |b| { 
102102        b. iter_batched ( 
103-             || random_odd_uint :: < {  nlimbs ! ( 1024 )  } > ( & mut  OsRng ,  1024 ) , 
103+             || random_odd_uint :: < Uint < {  nlimbs ! ( 1024 )  } > > ( & mut  OsRng ,  1024 ) , 
104104            MillerRabin :: new, 
105105            BatchSize :: SmallInput , 
106106        ) 
@@ -193,39 +193,39 @@ fn bench_presets(c: &mut Criterion) {
193193
194194    group. bench_function ( "(U128) Prime test" ,  |b| { 
195195        b. iter_batched ( 
196-             || random_odd_uint :: < {  nlimbs ! ( 128 )  } > ( & mut  OsRng ,  128 ) , 
197-             |num| is_prime_with_rng ( & mut  OsRng ,  & num) , 
196+             || random_odd_uint :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  OsRng ,  128 ) , 
197+             |num| is_prime_with_rng ( & mut  OsRng ,  num. as_ref ( ) ) , 
198198            BatchSize :: SmallInput , 
199199        ) 
200200    } ) ; 
201201
202202    group. bench_function ( "(U128) Safe prime test" ,  |b| { 
203203        b. iter_batched ( 
204-             || random_odd_uint :: < {  nlimbs ! ( 128 )  } > ( & mut  OsRng ,  128 ) , 
205-             |num| is_safe_prime_with_rng ( & mut  OsRng ,  & num) , 
204+             || random_odd_uint :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  OsRng ,  128 ) , 
205+             |num| is_safe_prime_with_rng ( & mut  OsRng ,  num. as_ref ( ) ) , 
206206            BatchSize :: SmallInput , 
207207        ) 
208208    } ) ; 
209209
210210    let  mut  rng = make_rng ( ) ; 
211211    group. bench_function ( "(U128) Random prime" ,  |b| { 
212-         b. iter ( || generate_prime_with_rng :: < {  nlimbs ! ( 128 )  } > ( & mut  rng,  None ) ) 
212+         b. iter ( || generate_prime_with_rng :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  rng,  128 ) ) 
213213    } ) ; 
214214
215215    let  mut  rng = make_rng ( ) ; 
216216    group. bench_function ( "(U1024) Random prime" ,  |b| { 
217-         b. iter ( || generate_prime_with_rng :: < {  nlimbs ! ( 1024 )  } > ( & mut  rng,  None ) ) 
217+         b. iter ( || generate_prime_with_rng :: < Uint < {  nlimbs ! ( 1024 )  } > > ( & mut  rng,  1024 ) ) 
218218    } ) ; 
219219
220220    let  mut  rng = make_rng ( ) ; 
221221    group. bench_function ( "(U128) Random safe prime" ,  |b| { 
222-         b. iter ( || generate_safe_prime_with_rng :: < {  nlimbs ! ( 128 )  } > ( & mut  rng,  None ) ) 
222+         b. iter ( || generate_safe_prime_with_rng :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  rng,  128 ) ) 
223223    } ) ; 
224224
225225    group. sample_size ( 20 ) ; 
226226    let  mut  rng = make_rng ( ) ; 
227227    group. bench_function ( "(U1024) Random safe prime" ,  |b| { 
228-         b. iter ( || generate_safe_prime_with_rng :: < {  nlimbs ! ( 1024 )  } > ( & mut  rng,  None ) ) 
228+         b. iter ( || generate_safe_prime_with_rng :: < Uint < {  nlimbs ! ( 1024 )  } > > ( & mut  rng,  1024 ) ) 
229229    } ) ; 
230230
231231    group. finish ( ) ; 
@@ -235,19 +235,19 @@ fn bench_presets(c: &mut Criterion) {
235235
236236    let  mut  rng = make_rng ( ) ; 
237237    group. bench_function ( "(U128) Random safe prime" ,  |b| { 
238-         b. iter ( || generate_safe_prime_with_rng :: < {  nlimbs ! ( 128 )  } > ( & mut  rng,  None ) ) 
238+         b. iter ( || generate_safe_prime_with_rng :: < Uint < {  nlimbs ! ( 128 )  } > > ( & mut  rng,  128 ) ) 
239239    } ) ; 
240240
241241    // The performance should scale with the prime size, not with the Uint size. 
242242    // So we should strive for this test's result to be as close as possible 
243243    // to that of the previous one and as far away as possible from the next one. 
244244    group. bench_function ( "(U256) Random 128 bit safe prime" ,  |b| { 
245-         b. iter ( || generate_safe_prime_with_rng :: < {  nlimbs ! ( 256 )  } > ( & mut  rng,  Some ( 128 ) ) ) 
245+         b. iter ( || generate_safe_prime_with_rng :: < Uint < {  nlimbs ! ( 256 )  } > > ( & mut  rng,  128 ) ) 
246246    } ) ; 
247247
248248    // The upper bound for the previous test. 
249249    group. bench_function ( "(U256) Random 256 bit safe prime" ,  |b| { 
250-         b. iter ( || generate_safe_prime_with_rng :: < {  nlimbs ! ( 256 )  } > ( & mut  rng,  None ) ) 
250+         b. iter ( || generate_safe_prime_with_rng :: < Uint < {  nlimbs ! ( 256 )  } > > ( & mut  rng,  256 ) ) 
251251    } ) ; 
252252
253253    group. finish ( ) ; 
@@ -258,7 +258,7 @@ fn bench_gmp(c: &mut Criterion) {
258258    let  mut  group = c. benchmark_group ( "GMP" ) ; 
259259
260260    fn  random < const  L :  usize > ( rng :  & mut  impl  CryptoRngCore )  -> Integer  { 
261-         let  num = random_odd_uint :: < L > ( rng,  Uint :: < L > :: BITS ) ; 
261+         let  num = random_odd_uint :: < Uint < L > > ( rng,  Uint :: < L > :: BITS ) . get ( ) ; 
262262        Integer :: from_digits ( num. as_words ( ) ,  Order :: Lsf ) 
263263    } 
264264
0 commit comments