File tree Expand file tree Collapse file tree 2 files changed +3
-16
lines changed Expand file tree Collapse file tree 2 files changed +3
-16
lines changed Original file line number Diff line number Diff line change @@ -553,8 +553,7 @@ impl EdwardsPoint {
553553 /// Generic scalar multiplication to compute s*P
554554 pub fn scalar_mul ( & self , scalar : & EdwardsScalar ) -> Self {
555555 // Compute floor(s/4)
556- let mut scalar_div_four = * scalar;
557- scalar_div_four. div_by_four ( ) ;
556+ let scalar_div_four = scalar. div_by_four ( ) ;
558557
559558 // Use isogeny and dual isogeny to compute phi^-1((s/4) * phi(P))
560559 variable_base ( & self . to_twisted ( ) , & scalar_div_four) . to_untwisted ( )
Original file line number Diff line number Diff line change @@ -661,20 +661,8 @@ impl<C: CurveWithScalar> Scalar<C> {
661661 /// Divides a scalar by four without reducing mod p
662662 /// This is used in the 2-isogeny when mapping points from Ed448-Goldilocks
663663 /// to Twisted-Goldilocks
664- pub ( crate ) fn div_by_four ( & mut self ) {
665- let s_mod_4 = self [ 0 ] & 3 ;
666-
667- let s_plus_l = self . scalar + ORDER ;
668- let s_plus_2l = s_plus_l + ORDER ;
669- let s_plus_3l = s_plus_2l + ORDER ;
670-
671- self . scalar . conditional_assign ( & s_plus_l, s_mod_4. ct_eq ( & 1 ) ) ;
672- self . scalar
673- . conditional_assign ( & s_plus_2l, s_mod_4. ct_eq ( & 2 ) ) ;
674- self . scalar
675- . conditional_assign ( & s_plus_3l, s_mod_4. ct_eq ( & 3 ) ) ;
676-
677- self . scalar >>= 2 ;
664+ pub ( crate ) fn div_by_four ( & self ) -> Self {
665+ self . halve ( ) . halve ( )
678666 }
679667
680668 // This method was modified from Curve25519-Dalek codebase. [scalar.rs]
You can’t perform that action at this time.
0 commit comments