File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1867,6 +1867,35 @@ mod test {
1867
1867
}
1868
1868
}
1869
1869
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( ) ) ;
1896
+ }
1897
+ }
1898
+
1870
1899
#[ test]
1871
1900
#[ cfg( feature = "alloc" ) ]
1872
1901
fn vartime_precomputed_vs_nonprecomputed_multiscalar ( ) {
You can’t perform that action at this time.
0 commit comments