@@ -29,7 +29,7 @@ fn bench_montgomery_conversion<M: Measurement>(group: &mut BenchmarkGroup<'_, M>
2929
3030 group. bench_function ( "ConstMontyForm retrieve" , |b| {
3131 b. iter_batched (
32- || ConstMontyForm :: random ( & mut rng) ,
32+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
3333 |x| black_box ( x. retrieve ( ) ) ,
3434 BatchSize :: SmallInput ,
3535 )
@@ -42,8 +42,8 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
4242 group. bench_function ( "add, U256" , |b| {
4343 b. iter_batched (
4444 || {
45- let a = ConstMontyForm :: random ( & mut rng) ;
46- let b = ConstMontyForm :: random ( & mut rng) ;
45+ let a = ConstMontyForm :: random_from_rng ( & mut rng) ;
46+ let b = ConstMontyForm :: random_from_rng ( & mut rng) ;
4747 ( a, b)
4848 } ,
4949 |( a, b) | black_box ( a) . add ( & black_box ( b) ) ,
@@ -53,7 +53,7 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
5353
5454 group. bench_function ( "double, U256" , |b| {
5555 b. iter_batched (
56- || ConstMontyForm :: random ( & mut rng) ,
56+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
5757 |a| black_box ( a) . double ( ) ,
5858 BatchSize :: SmallInput ,
5959 )
@@ -62,8 +62,8 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
6262 group. bench_function ( "sub, U256" , |b| {
6363 b. iter_batched (
6464 || {
65- let a = ConstMontyForm :: random ( & mut rng) ;
66- let b = ConstMontyForm :: random ( & mut rng) ;
65+ let a = ConstMontyForm :: random_from_rng ( & mut rng) ;
66+ let b = ConstMontyForm :: random_from_rng ( & mut rng) ;
6767 ( a, b)
6868 } ,
6969 |( a, b) | black_box ( a) . sub ( & black_box ( b) ) ,
@@ -73,15 +73,15 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
7373
7474 group. bench_function ( "neg, U256" , |b| {
7575 b. iter_batched (
76- || ConstMontyForm :: random ( & mut rng) ,
76+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
7777 |a| black_box ( a) . neg ( ) ,
7878 BatchSize :: SmallInput ,
7979 )
8080 } ) ;
8181
8282 group. bench_function ( "invert, U256" , |b| {
8383 b. iter_batched (
84- || ConstMontyForm :: random ( & mut rng) ,
84+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
8585 |x| black_box ( x) . invert ( ) ,
8686 BatchSize :: SmallInput ,
8787 )
@@ -90,8 +90,8 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
9090 group. bench_function ( "multiplication, U256*U256" , |b| {
9191 b. iter_batched (
9292 || {
93- let x = ConstMontyForm :: random ( & mut rng) ;
94- let y = ConstMontyForm :: random ( & mut rng) ;
93+ let x = ConstMontyForm :: random_from_rng ( & mut rng) ;
94+ let y = ConstMontyForm :: random_from_rng ( & mut rng) ;
9595 ( x, y)
9696 } ,
9797 |( x, y) | black_box ( x) . mul ( & black_box ( y) ) ,
@@ -101,7 +101,7 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
101101
102102 group. bench_function ( "squaring, U256*U256" , |b| {
103103 b. iter_batched (
104- || ConstMontyForm :: random ( & mut rng) ,
104+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
105105 |x| black_box ( x) . square ( ) ,
106106 BatchSize :: SmallInput ,
107107 )
@@ -110,8 +110,8 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
110110 group. bench_function ( "modpow, U256^U256" , |b| {
111111 b. iter_batched (
112112 || {
113- let x_m = ConstMontyForm :: random ( & mut rng) ;
114- let p = U256 :: random ( & mut rng) | ( U256 :: ONE << ( U256 :: BITS - 1 ) ) ;
113+ let x_m = ConstMontyForm :: random_from_rng ( & mut rng) ;
114+ let p = U256 :: random_from_rng ( & mut rng) | ( U256 :: ONE << ( U256 :: BITS - 1 ) ) ;
115115 ( x_m, p)
116116 } ,
117117 |( x, p) | black_box ( x. pow ( & p) ) ,
@@ -121,23 +121,23 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
121121
122122 group. bench_function ( "jacobi_symbol" , |b| {
123123 b. iter_batched (
124- || ConstMontyForm :: random ( & mut rng) ,
124+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
125125 |a| a. jacobi_symbol ( ) ,
126126 BatchSize :: SmallInput ,
127127 )
128128 } ) ;
129129
130130 group. bench_function ( "jacobi_symbol_vartime" , |b| {
131131 b. iter_batched (
132- || ConstMontyForm :: random ( & mut rng) ,
132+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
133133 |a| a. jacobi_symbol_vartime ( ) ,
134134 BatchSize :: SmallInput ,
135135 )
136136 } ) ;
137137
138138 group. bench_function ( "lincomb, U256*U256+U256*U256" , |b| {
139139 b. iter_batched (
140- || ConstMontyForm :: random ( & mut rng) ,
140+ || ConstMontyForm :: random_from_rng ( & mut rng) ,
141141 |a| {
142142 ConstMontyForm :: lincomb ( & [
143143 ( black_box ( a) , black_box ( a) ) ,
@@ -157,8 +157,9 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
157157 || {
158158 let bases_and_exponents: Vec < ( ConstMontyForm , U256 ) > = ( 1 ..=i)
159159 . map ( |_| {
160- let x_m = ConstMontyForm :: random ( & mut rng) ;
161- let p = U256 :: random ( & mut rng) | ( U256 :: ONE << ( U256 :: BITS - 1 ) ) ;
160+ let x_m = ConstMontyForm :: random_from_rng ( & mut rng) ;
161+ let p = U256 :: random_from_rng ( & mut rng)
162+ | ( U256 :: ONE << ( U256 :: BITS - 1 ) ) ;
162163 ( x_m, p)
163164 } )
164165 . collect ( ) ;
@@ -185,5 +186,4 @@ fn bench_montgomery(c: &mut Criterion) {
185186}
186187
187188criterion_group ! ( benches, bench_montgomery) ;
188-
189189criterion_main ! ( benches) ;
0 commit comments