@@ -898,38 +898,19 @@ impl MultiscalarMul for EdwardsPoint {
898898 type Point = EdwardsPoint ;
899899
900900 fn multiscalar_mul < const N : usize > (
901- scalars : & [ Scalar ; N ] ,
902- points : & [ Self :: Point ; N ] ,
901+ points_and_scalars : & [ ( Self :: Point , Scalar ) ; N ] ,
903902 ) -> Self :: Point {
904- crate :: backend:: straus_multiscalar_mul ( scalars , points )
903+ crate :: backend:: straus_multiscalar_mul ( points_and_scalars )
905904 }
906905
907906 #[ cfg( feature = "alloc" ) ]
908- fn multiscalar_alloc_mul < I , J > ( scalars : I , points : J ) -> EdwardsPoint
907+ fn multiscalar_alloc_mul < I , P , S > ( points_and_scalars : I ) -> EdwardsPoint
909908 where
910- I : IntoIterator ,
911- I :: Item : Borrow < Scalar > ,
912- J : IntoIterator ,
913- J :: Item : Borrow < EdwardsPoint > ,
909+ I : IntoIterator < Item = ( P , S ) > ,
910+ P : Borrow < Self :: Point > ,
911+ S : Borrow < Scalar > ,
914912 {
915- // Sanity-check lengths of input iterators
916- let mut scalars = scalars. into_iter ( ) ;
917- let mut points = points. into_iter ( ) ;
918-
919- // Lower and upper bounds on iterators
920- let ( s_lo, s_hi) = scalars. by_ref ( ) . size_hint ( ) ;
921- let ( p_lo, p_hi) = points. by_ref ( ) . size_hint ( ) ;
922-
923- // They should all be equal
924- assert_eq ! ( s_lo, p_lo) ;
925- assert_eq ! ( s_hi, Some ( s_lo) ) ;
926- assert_eq ! ( p_hi, Some ( p_lo) ) ;
927-
928- // Now we know there's a single size. When we do
929- // size-dependent algorithm dispatch, use this as the hint.
930- let _size = s_lo;
931-
932- crate :: backend:: straus_multiscalar_alloc_mul ( scalars, points)
913+ crate :: backend:: straus_multiscalar_alloc_mul ( points_and_scalars)
933914 }
934915}
935916
@@ -2202,7 +2183,7 @@ mod test {
22022183 let Gs = xs. iter ( ) . map ( EdwardsPoint :: mul_base) . collect :: < Vec < _ > > ( ) ;
22032184
22042185 // Compute H1 = <xs, Gs> (consttime)
2205- let H1 = EdwardsPoint :: multiscalar_alloc_mul ( & xs, & Gs ) ;
2186+ let H1 = EdwardsPoint :: multiscalar_alloc_mul ( Gs . iter ( ) . zip ( & xs) ) ;
22062187 // Compute H2 = <xs, Gs> (vartime)
22072188 let H2 = EdwardsPoint :: vartime_multiscalar_mul ( & xs, & Gs ) ;
22082189 // Compute H3 = <xs, Gs> = sum(xi^2) * B
@@ -2360,8 +2341,9 @@ mod test {
23602341 & [ A , constants:: ED25519_BASEPOINT_POINT ] ,
23612342 ) ;
23622343 let result_consttime = EdwardsPoint :: multiscalar_alloc_mul (
2363- & [ A_SCALAR , B_SCALAR ] ,
2364- & [ A , constants:: ED25519_BASEPOINT_POINT ] ,
2344+ [ A , constants:: ED25519_BASEPOINT_POINT ]
2345+ . into_iter ( )
2346+ . zip ( [ A_SCALAR , B_SCALAR ] ) ,
23652347 ) ;
23662348
23672349 assert_eq ! ( result_vartime. compress( ) , result_consttime. compress( ) ) ;
0 commit comments