From 9da24d8afaf0b9443664604d3272dd336cf99c88 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Thu, 5 Oct 2017 02:15:28 +0000 Subject: [PATCH] Add test for Montgomery ladder with a scalar with high bit set. --- src/montgomery.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/montgomery.rs b/src/montgomery.rs index bb6a9ad..37f447a 100644 --- a/src/montgomery.rs +++ b/src/montgomery.rs @@ -545,6 +545,19 @@ mod test { assert_eq!(result.compress(), expected.to_montgomery().compress()); } + + #[test] + #[should_panic(expected = "assertion failed: self[31] <= 127")] + fn ladder_matches_scalarmult_with_scalar_high_bit_set() { + let mut s: Scalar = Scalar::one(); + + s[31] = 255; + + let result: MontgomeryPoint = &BASE_COMPRESSED_MONTGOMERY.decompress() * &s; + let expected: ExtendedPoint = &constants::ED25519_BASEPOINT_TABLE * &s; + + assert_eq!(result.compress(), expected.to_montgomery().compress()) + } } #[cfg(all(test, feature = "bench"))]