2022-05-06 07:57:45 -07:00
|
|
|
use core::convert::TryFrom;
|
2020-01-17 10:12:34 -08:00
|
|
|
|
|
|
|
use jubjub::{AffinePoint, Fq};
|
|
|
|
|
2021-03-01 06:38:25 -08:00
|
|
|
use reddsa::*;
|
2020-01-17 10:12:34 -08:00
|
|
|
|
|
|
|
#[test]
|
2021-11-18 10:53:35 -08:00
|
|
|
fn identity_publickey_passes() {
|
|
|
|
let identity = AffinePoint::identity();
|
2022-10-14 18:27:47 -07:00
|
|
|
assert!(<bool>::from(identity.is_small_order()));
|
2021-11-18 10:53:35 -08:00
|
|
|
let bytes = identity.to_bytes();
|
2021-03-01 07:29:07 -08:00
|
|
|
let pk_bytes = VerificationKeyBytes::<sapling::SpendAuth>::from(bytes);
|
|
|
|
assert!(VerificationKey::<sapling::SpendAuth>::try_from(pk_bytes).is_ok());
|
2021-11-18 10:53:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn smallorder_publickey_passes() {
|
2020-01-17 10:12:34 -08:00
|
|
|
// (1,0) is a point of order 4 on any Edwards curve
|
|
|
|
let order4 = AffinePoint::from_raw_unchecked(Fq::one(), Fq::zero());
|
2022-10-14 18:27:47 -07:00
|
|
|
assert!(<bool>::from(order4.is_small_order()));
|
2020-01-17 10:12:34 -08:00
|
|
|
let bytes = order4.to_bytes();
|
2021-03-01 07:29:07 -08:00
|
|
|
let pk_bytes = VerificationKeyBytes::<sapling::SpendAuth>::from(bytes);
|
|
|
|
assert!(VerificationKey::<sapling::SpendAuth>::try_from(pk_bytes).is_ok());
|
2020-01-17 10:12:34 -08:00
|
|
|
}
|