Browse Source

Some test cleanups.

master
Sean Bowe 7 years ago
parent
commit
7c48792511
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
  1. 6
      src/jubjub/mod.rs
  2. 11
      src/jubjub/montgomery.rs

6
src/jubjub/mod.rs

@ -78,17 +78,22 @@ mod test {
assert!(a.legendre() == LegendreSymbol::QuadraticResidue); assert!(a.legendre() == LegendreSymbol::QuadraticResidue);
} }
{
// Check that A^2 - 4 is nonsquare: // Check that A^2 - 4 is nonsquare:
let mut tmp = params.montgomery_a; let mut tmp = params.montgomery_a;
tmp.square(); tmp.square();
tmp.sub_assign(&Fr::from_str("4").unwrap()); tmp.sub_assign(&Fr::from_str("4").unwrap());
assert!(tmp.legendre() == LegendreSymbol::QuadraticNonResidue); assert!(tmp.legendre() == LegendreSymbol::QuadraticNonResidue);
}
{
// Check that A - 2 is nonsquare: // Check that A - 2 is nonsquare:
let mut tmp = params.montgomery_a; let mut tmp = params.montgomery_a;
tmp.sub_assign(&Fr::from_str("2").unwrap()); tmp.sub_assign(&Fr::from_str("2").unwrap());
assert!(tmp.legendre() == LegendreSymbol::QuadraticNonResidue); assert!(tmp.legendre() == LegendreSymbol::QuadraticNonResidue);
}
{
// Check the validity of the scaling factor // Check the validity of the scaling factor
let mut tmp = a; let mut tmp = a;
tmp.sub_assign(&params.edwards_d); tmp.sub_assign(&params.edwards_d);
@ -97,4 +102,5 @@ mod test {
tmp = tmp.sqrt().unwrap(); tmp = tmp.sqrt().unwrap();
assert_eq!(tmp, params.scale); assert_eq!(tmp, params.scale);
} }
}
} }

11
src/jubjub/montgomery.rs

@ -518,13 +518,12 @@ mod test {
} }
#[test] #[test]
fn test_awkward_points() { fn test_low_order_points() {
use super::edwards; use super::edwards;
//let rng = &mut XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let params = &JubjubParams::new(); let params = &JubjubParams::new();
let mut awkward_points: Vec<Point<Bls12, Unknown>> = vec![]; let mut low_order_points: Vec<Point<Bls12, Unknown>> = vec![];
{ {
let mut push_point = |x, y| { let mut push_point = |x, y| {
@ -533,7 +532,7 @@ mod test {
assert!(is_on_curve(x, y, params)); assert!(is_on_curve(x, y, params));
awkward_points.push(Point { low_order_points.push(Point {
x: x, x: x,
y: y, y: y,
infinity: false, infinity: false,
@ -587,9 +586,9 @@ mod test {
} }
// push 8p (point at infinity) // push 8p (point at infinity)
awkward_points.push(Point::zero()); low_order_points.push(Point::zero());
for point in &awkward_points { for point in &low_order_points {
let ed = edwards::Point::from_montgomery(point, params); let ed = edwards::Point::from_montgomery(point, params);
let mut ed_tmp = ed.clone(); let mut ed_tmp = ed.clone();
let mut mont_tmp = point.clone(); let mut mont_tmp = point.clone();

Loading…
Cancel
Save