diff --git a/src/backend/u32/constants.rs b/src/backend/u32/constants.rs index 94702d7..f68f662 100644 --- a/src/backend/u32/constants.rs +++ b/src/backend/u32/constants.rs @@ -46,22 +46,11 @@ pub(crate) const SQRT_M1: FieldElement32 = FieldElement32([ 33281959, 41962654, 31548777, 326685, 11406482, ]); -/// In Montgomery form y² = x³+Ax²+x, Curve25519 has A=486662. -pub(crate) const MONTGOMERY_A: FieldElement32 = FieldElement32([ - 486662, 0, 0, 0, 0, 0, 0, 0, 0, 0, -]); - /// `APLUS2_OVER_FOUR` is (A+2)/4. (This is used internally within the Montgomery ladder.) pub(crate) const APLUS2_OVER_FOUR: FieldElement32 = FieldElement32([ 121666, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]); -/// `SQRT_MINUS_APLUS2` is sqrt(-486664) -pub(crate) const SQRT_MINUS_APLUS2: FieldElement32 = FieldElement32([ - 54885894, 25242303, 55597453, 9067496, 51808079, - 33312638, 25456129, 14121551, 54921728, 3972023, -]); - /// `L` is the order of base point, i.e. 2^252 + /// 27742317777372353535851937790883648493 pub(crate) const L: Scalar32 = Scalar32([ 0x1cf5d3ed, 0x009318d2, 0x1de73596, 0x1df3bd45, diff --git a/src/backend/u64/constants.rs b/src/backend/u64/constants.rs index 254c81c..1cc23fa 100644 --- a/src/backend/u64/constants.rs +++ b/src/backend/u64/constants.rs @@ -33,15 +33,9 @@ pub(crate) const INVSQRT_A_MINUS_D: FieldElement64 = FieldElement64([ /// Precomputed value of one of the square roots of -1 (mod p) pub(crate) const SQRT_M1: FieldElement64 = FieldElement64([1718705420411056, 234908883556509, 2233514472574048, 2117202627021982, 765476049583133]); -/// In Montgomery form y² = x³+Ax²+x, Curve25519 has A=486662. -pub(crate) const MONTGOMERY_A: FieldElement64 = FieldElement64([486662, 0, 0, 0, 0]); - /// `APLUS2_OVER_FOUR` is (A+2)/4. (This is used internally within the Montgomery ladder.) pub(crate) const APLUS2_OVER_FOUR: FieldElement64 = FieldElement64([121666, 0, 0, 0, 0]); -/// `SQRT_MINUS_APLUS2` is sqrt(-486664) -pub(crate) const SQRT_MINUS_APLUS2: FieldElement64 = FieldElement64([1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600]); - /// `L` is the order of base point, i.e. 2^252 + 27742317777372353535851937790883648493 pub(crate) const L: Scalar64 = Scalar64([ 0x0002631a5cf5d3ed, 0x000dea2f79cd6581, 0x000000000014def9, 0x0000000000000000, 0x0000100000000000 ]); diff --git a/src/constants.rs b/src/constants.rs index 9da0800..c8cf1c1 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -129,30 +129,6 @@ mod test { } } - /// Test that the constant for sqrt(-486664) really is a square - /// root of -486664. - #[test] - #[cfg(feature="radix_51")] - fn sqrt_minus_aplus2() { - use backend::u64::field::FieldElement64; - let minus_aplus2 = -&FieldElement64([486664,0,0,0,0]); - let sqrt = constants::SQRT_MINUS_APLUS2; - let sq = &sqrt * &sqrt; - assert_eq!(sq, minus_aplus2); - } - - /// Test that the constant for sqrt(-486664) really is a square - /// root of -486664. - #[test] - #[cfg(not(feature="radix_51"))] - fn sqrt_minus_aplus2() { - use backend::u32::field::FieldElement32; - let minus_aplus2 = -&FieldElement32([486664,0,0,0,0,0,0,0,0,0]); - let sqrt = constants::SQRT_MINUS_APLUS2; - let sq = &sqrt * &sqrt; - assert_eq!(sq, minus_aplus2); - } - #[test] /// Test that SQRT_M1 is a square root of -1 fn test_sqrt_minus_one() { diff --git a/src/montgomery.rs b/src/montgomery.rs index 8ba7670..81337c5 100644 --- a/src/montgomery.rs +++ b/src/montgomery.rs @@ -50,13 +50,12 @@ use core::ops::{Mul, MulAssign}; -use constants; use constants::APLUS2_OVER_FOUR; use field::FieldElement; use edwards::{EdwardsPoint, CompressedEdwardsY}; use scalar::Scalar; -use traits::{Identity, ValidityCheck}; +use traits::Identity; use subtle::ConditionallyAssignable; use subtle::ConditionallySwappable; @@ -277,8 +276,7 @@ impl Mul for Scalar { #[cfg(test)] mod test { - use constants::X25519_BASEPOINT; - use traits::Identity; + use constants; use super::*; use rand::OsRng; diff --git a/src/scalar.rs b/src/scalar.rs index c2b177b..34e1776 100644 --- a/src/scalar.rs +++ b/src/scalar.rs @@ -715,24 +715,6 @@ mod test { 0xe8, 0xef, 0x7a, 0xc3, 0x1f, 0x35, 0xbb, 0x05, ], }; - /// z = 5033871415930814945849241457262266927579821285980625165479289807629491019013 - pub static Z: Scalar = Scalar{ - bytes: [ - 0x05, 0x9d, 0x3e, 0x0b, 0x09, 0x26, 0x50, 0x3d, - 0xa3, 0x84, 0xa1, 0x3c, 0x92, 0x7a, 0xc2, 0x06, - 0x41, 0x98, 0xcf, 0x34, 0x3a, 0x24, 0xd5, 0xb7, - 0xeb, 0x33, 0x6a, 0x2d, 0xfc, 0x11, 0x21, 0x0b, - ], - }; - /// w = 3486911242272497535104403593250518247409663771668155364040899665266216860804 - static W: Scalar = Scalar{ - bytes: [ - 0x84, 0xfc, 0xbc, 0x4f, 0x78, 0x12, 0xa0, 0x06, - 0xd7, 0x91, 0xd9, 0x7a, 0x3a, 0x27, 0xdd, 0x1e, - 0x21, 0x43, 0x45, 0xf7, 0xb1, 0xb9, 0x56, 0x7a, - 0x81, 0x30, 0x73, 0x44, 0x96, 0x85, 0xb5, 0x07, - ], - }; /// x*y = 5690045403673944803228348699031245560686958845067437804563560795922180092780 static X_TIMES_Y: Scalar = Scalar{