diff --git a/src/constants.rs b/src/constants.rs index c0e6cc2..1821f9a 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -159,12 +159,13 @@ pub const l: Scalar = Scalar([ 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 ]); -/// `lminus1` is the order of base point minus one, i.e. 2^252 + +/// `l_minus_1` is the order of base point minus one, i.e. 2^252 + /// 27742317777372353535851937790883648493 - 1, in little-endian form -pub const lminus1: Scalar = Scalar([ 0xec, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, - 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 ]); +pub const l_minus_1: Scalar = Scalar([ 0xec, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, + 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 ]); + /// The 8-torsion subgroup Ɛ[8]. /// /// In the case of Curve25519, it is cyclic; the `i`th element of the diff --git a/src/scalar.rs b/src/scalar.rs index d97efc1..c64b59b 100644 --- a/src/scalar.rs +++ b/src/scalar.rs @@ -106,7 +106,8 @@ impl Neg for Scalar { /// Negate this scalar by computing (l - 1) * self - 0 (mod l). fn neg(self) -> Scalar { - Scalar::multiply_add(&constants::lminus1, &self, &Scalar::zero()) + // XXX this could be more efficient + Scalar::multiply_add(&constants::l_minus_1, &self, &Scalar::zero()) } }