@@ -1321,6 +1321,8 @@ impl Zeroize for RistrettoPoint {
13211321mod test {
13221322 use super :: * ;
13231323 use crate :: edwards:: CompressedEdwardsY ;
1324+ #[ cfg( feature = "group" ) ]
1325+ use proptest:: prelude:: * ;
13241326
13251327 use rand_core:: { OsRng , TryRngCore } ;
13261328
@@ -1867,32 +1869,36 @@ mod test {
18671869 }
18681870 }
18691871
1870- #[ test]
1871- #[ cfg( all( feature = "alloc" , feature = "rand_core" , feature = "group" ) ) ]
1872- fn multiply_double_and_compress_1024_random_points ( ) {
1873- use ff:: Field ;
1874- use group:: Group ;
1875- let mut rng = OsRng ;
1876-
1877- let mut scalars: Vec < Scalar > = ( 0 ..1024 )
1878- . map ( |_| Scalar :: try_from_rng ( & mut rng) . unwrap ( ) )
1879- . collect ( ) ;
1880- scalars[ 500 ] = Scalar :: ZERO ;
1881-
1882- let mut points: Vec < RistrettoPoint > = ( 0 ..1024 )
1883- . map ( |_| RistrettoPoint :: try_from_rng ( & mut rng) . unwrap ( ) )
1884- . collect ( ) ;
1885- points[ 500 ] = <RistrettoPoint as Group >:: identity ( ) ;
1886-
1887- let multiplied_points: Vec < RistrettoPoint > = scalars
1888- . iter ( )
1889- . zip ( & points)
1890- . map ( |( scalar, point) | scalar. div_by_2 ( ) * point)
1891- . collect ( ) ;
1892- let compressed = RistrettoPoint :: double_and_compress_batch ( & multiplied_points) ;
1893-
1894- for ( ( s, P ) , P2_compressed ) in scalars. iter ( ) . zip ( points) . zip ( compressed) {
1895- assert_eq ! ( P2_compressed , ( s * P ) . compress( ) ) ;
1872+ #[ cfg( feature = "group" ) ]
1873+ proptest ! {
1874+ #[ test]
1875+ fn multiply_double_and_compress_random_points(
1876+ p1 in any:: <[ u8 ; 64 ] >( ) ,
1877+ p2 in any:: <[ u8 ; 64 ] >( ) ,
1878+ s1 in any:: <[ u8 ; 32 ] >( ) ,
1879+ s2 in any:: <[ u8 ; 32 ] >( ) ,
1880+ ) {
1881+ use group:: Group ;
1882+
1883+ let scalars = [
1884+ Scalar :: from_bytes_mod_order( s1) ,
1885+ Scalar :: ZERO ,
1886+ Scalar :: from_bytes_mod_order( s2) ,
1887+ ] ;
1888+
1889+ let points = [
1890+ RistrettoPoint :: from_uniform_bytes( & p1) ,
1891+ <RistrettoPoint as Group >:: identity( ) ,
1892+ RistrettoPoint :: from_uniform_bytes( & p2) ,
1893+ ] ;
1894+
1895+ let multiplied_points: [ _; 3 ] =
1896+ core:: array:: from_fn( |i| scalars[ i] . div_by_2( ) * points[ i] ) ;
1897+ let compressed = RistrettoPoint :: double_and_compress_batch( & multiplied_points) ;
1898+
1899+ for ( ( s, P ) , P2_compressed ) in scalars. iter( ) . zip( points) . zip( compressed) {
1900+ prop_assert_eq!( P2_compressed , ( s * P ) . compress( ) ) ;
1901+ }
18961902 }
18971903 }
18981904
0 commit comments