From 5d3dfc0ff238efdaf17bcde8a97dbb9bbfedaf8b Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Fri, 17 Jan 2020 10:12:34 -0800 Subject: [PATCH] Add test that public keys of small order are rejected. --- tests/smallorder.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/smallorder.rs diff --git a/tests/smallorder.rs b/tests/smallorder.rs new file mode 100644 index 0000000..88665e5 --- /dev/null +++ b/tests/smallorder.rs @@ -0,0 +1,15 @@ +use std::convert::TryFrom; + +use jubjub::{AffinePoint, Fq}; + +use redjubjub::*; + +#[test] +fn smallorder_publickey_fails() { + // (1,0) is a point of order 4 on any Edwards curve + let order4 = AffinePoint::from_raw_unchecked(Fq::one(), Fq::zero()); + assert_eq!(::from(order4.is_small_order()), true); + let bytes = order4.to_bytes(); + let pk_bytes = PublicKeyBytes::::from(bytes); + assert!(PublicKey::::try_from(pk_bytes).is_err()); +}