88//! verified by finding out embedding degree of the curve, i.e. smallest k such that r|q^k-1.
99
1010use super :: * ;
11- use crate :: { Distribution , Monomial , Polynomial , Rng , Standard } ;
11+ use crate :: { Distribution , Monomial , Polynomial , Rng , StandardUniform } ;
1212
1313impl ExtensionField < 2 , 101 > for PlutoBaseFieldExtension {
1414 /// irreducible polynomial used to reduce field polynomials to second degree:
@@ -127,10 +127,11 @@ impl FiniteField for PlutoBaseFieldExtension {
127127 const PRIMITIVE_ELEMENT : Self = Self :: new ( [ PlutoBaseField :: new ( 14 ) , PlutoBaseField :: new ( 9 ) ] ) ;
128128}
129129
130- impl < const N : usize , const P : usize > Distribution < GaloisField < N , P > > for Standard {
130+ impl < const N : usize , const P : usize > Distribution < GaloisField < N , P > > for StandardUniform {
131131 #[ inline]
132132 fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> GaloisField < N , P > {
133- let coeffs = ( 0 ..N ) . map ( |_| rng. gen :: < PrimeField < P > > ( ) ) . collect :: < Vec < _ > > ( ) . try_into ( ) . unwrap ( ) ;
133+ let coeffs =
134+ ( 0 ..N ) . map ( |_| rng. random :: < PrimeField < P > > ( ) ) . collect :: < Vec < _ > > ( ) . try_into ( ) . unwrap ( ) ;
134135 GaloisField :: < N , P > :: new ( coeffs)
135136 }
136137}
@@ -147,7 +148,7 @@ impl Mul for PlutoBaseFieldExtension {
147148 Polynomial :: < Monomial , PlutoBaseField , 3 > :: from ( Self :: IRREDUCIBLE_POLYNOMIAL_COEFFICIENTS ) ;
148149 let product = ( poly_self * poly_rhs) % poly_irred;
149150 let res: [ PlutoBaseField ; 2 ] =
150- array:: from_fn ( |i| product. coefficients . get ( i) . cloned ( ) . unwrap_or ( PlutoBaseField :: ZERO ) ) ;
151+ array:: from_fn ( |i| product. coefficients . get ( i) . copied ( ) . unwrap_or ( PlutoBaseField :: ZERO ) ) ;
151152
152153 Self :: new ( res)
153154 }
@@ -251,10 +252,10 @@ mod tests {
251252
252253 #[ test]
253254 fn add_sub_neg_mul ( ) {
254- let mut rng = rand:: thread_rng ( ) ;
255- let x = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
256- let y = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
257- let z = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
255+ let mut rng = rand:: rng ( ) ;
256+ let x = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
257+ let y = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
258+ let z = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
258259 assert_eq ! ( x + ( -x) , <PlutoBaseFieldExtension >:: ZERO ) ;
259260 assert_eq ! ( -x, <PlutoBaseFieldExtension >:: ZERO - x) ;
260261 assert_eq ! (
@@ -268,13 +269,13 @@ mod tests {
268269 assert_eq ! ( x - ( y + z) , ( x - y) - z) ;
269270 assert_eq ! ( ( x + y) - z, x + ( y - z) ) ;
270271 assert_eq ! ( x * ( y + z) , x * y + x * z) ;
271- assert_eq ! ( x + y + z + x + y + z, [ x, x, y, y, z, z] . iter( ) . cloned ( ) . sum( ) ) ;
272+ assert_eq ! ( x + y + z + x + y + z, [ x, x, y, y, z, z] . iter( ) . copied ( ) . sum( ) ) ;
272273 }
273274
274275 #[ test]
275276 fn pow ( ) {
276- let mut rng = rand:: thread_rng ( ) ;
277- let x = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
277+ let mut rng = rand:: rng ( ) ;
278+ let x = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
278279
279280 assert_eq ! ( x, x. pow( 1 ) ) ;
280281
@@ -284,24 +285,24 @@ mod tests {
284285
285286 #[ test]
286287 fn inv_div ( ) {
287- let mut rng = rand:: thread_rng ( ) ;
288+ let mut rng = rand:: rng ( ) ;
288289 // Loop rng's until we get something with inverse.
289290 let mut x = <PlutoBaseFieldExtension >:: ZERO ;
290291 let mut x_inv = None ;
291292 while x_inv. is_none ( ) {
292- x = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
293+ x = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
293294 x_inv = x. inverse ( ) ;
294295 }
295296 let mut y = <PlutoBaseFieldExtension >:: ZERO ;
296297 let mut y_inv = None ;
297298 while y_inv. is_none ( ) {
298- y = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
299+ y = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
299300 y_inv = y. inverse ( ) ;
300301 }
301302 let mut z = <PlutoBaseFieldExtension >:: ZERO ;
302303 let mut z_inv = None ;
303304 while z_inv. is_none ( ) {
304- z = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
305+ z = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
305306 z_inv = z. inverse ( ) ;
306307 }
307308 assert_eq ! ( x * x. inverse( ) . unwrap( ) , <PlutoBaseFieldExtension >:: ONE ) ;
@@ -329,12 +330,12 @@ mod tests {
329330
330331 #[ test]
331332 fn add_sub_mul_subfield ( ) {
332- let mut rng = rand:: thread_rng ( ) ;
333- let x = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
333+ let mut rng = rand:: rng ( ) ;
334+ let x = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
334335 let mut y = <PlutoBaseFieldExtension >:: ZERO ;
335336 let mut y_inv = None ;
336337 while y_inv. is_none ( ) {
337- y = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
338+ y = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
338339 y_inv = y. inverse ( ) ;
339340 }
340341
@@ -362,17 +363,17 @@ mod tests {
362363
363364 #[ test]
364365 fn sqrt ( ) {
365- let mut rng = rand:: thread_rng ( ) ;
366- let x = <PlutoBaseFieldExtension >:: from ( rng. gen :: < PlutoBaseField > ( ) ) ;
366+ let mut rng = rand:: rng ( ) ;
367+ let x = <PlutoBaseFieldExtension >:: from ( rng. random :: < PlutoBaseField > ( ) ) ;
367368 let x_sq = x. pow ( 2 ) ;
368369
369370 let res = x_sq. sqrt ( ) ;
370371 assert ! ( res. is_some( ) ) ;
371372
372373 assert_eq ! ( res. unwrap( ) . 0 * res. unwrap( ) . 0 , x * x) ;
373374
374- let x_0 = rng. gen :: < PlutoBaseField > ( ) ;
375- let x_1 = rng. gen :: < PlutoBaseField > ( ) ;
375+ let x_0 = rng. random :: < PlutoBaseField > ( ) ;
376+ let x_1 = rng. random :: < PlutoBaseField > ( ) ;
376377 let x = <PlutoBaseFieldExtension >:: new ( [ x_0, x_1] ) ;
377378
378379 let x_sq = x. pow ( 2 ) ;
0 commit comments