Add test that public keys of small order are rejected.

This commit is contained in:
Henry de Valence 2020-01-17 10:12:34 -08:00
parent b7dfb77cf1
commit 5d3dfc0ff2
1 changed files with 15 additions and 0 deletions

15
tests/smallorder.rs Normal file
View File

@ -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!(<bool>::from(order4.is_small_order()), true);
let bytes = order4.to_bytes();
let pk_bytes = PublicKeyBytes::<SpendAuth>::from(bytes);
assert!(PublicKey::<SpendAuth>::try_from(pk_bytes).is_err());
}