From 0585af6c68f3b3b8a96fcfe13692254b2a2fc03d Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Tue, 7 Mar 2017 00:03:59 -0800 Subject: [PATCH] Move sqrt(-(A+2)) test to constants.rs --- src/constants.rs | 10 ++++++++++ src/curve.rs | 11 ----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 8b43ceb..6c4b53b 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1625,6 +1625,16 @@ mod test { assert_eq!(one, &two * &constants::HALF); } + #[test] + /// Test that the constant for sqrt(-486664) really is a square + /// root of -486664. + fn sqrt_minus_aplus2() { + let minus_aplus2 = FieldElement([-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 and MSQRT_M1 are square roots of -1 fn test_sqrt_minus_one() { diff --git a/src/curve.rs b/src/curve.rs index 6ae073a..74a4862 100644 --- a/src/curve.rs +++ b/src/curve.rs @@ -1074,17 +1074,6 @@ mod test { 0xc0, 0x46, 0x83, 0x43, 0xde, 0x70, 0x4b, 0x85, 0x09, 0x6f, 0xfe, 0x35, 0x4f, 0x13, 0x2b, 0x42]); - #[test] - /// Test that the constant for sqrt(-486664) really is a square - /// root of -486664. - /// XXX this should be a test in constants.rs ?? - fn sqrt_minus_aplus2() { - let minus_aplus2 = FieldElement([-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 Montgomery conversion against the X25519 basepoint. #[test] fn basepoint_to_montgomery() {