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 {
553
553
/// Generic scalar multiplication to compute s*P
554
554
pub fn scalar_mul ( & self , scalar : & EdwardsScalar ) -> Self {
555
555
// 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 ( ) ;
558
557
559
558
// Use isogeny and dual isogeny to compute phi^-1((s/4) * phi(P))
560
559
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> {
661
661
/// Divides a scalar by four without reducing mod p
662
662
/// This is used in the 2-isogeny when mapping points from Ed448-Goldilocks
663
663
/// 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 ( )
678
666
}
679
667
680
668
// This method was modified from Curve25519-Dalek codebase. [scalar.rs]
You can’t perform that action at this time.
0 commit comments