Some test cleanups.

This commit is contained in:
Sean Bowe 2017-12-06 10:21:56 -07:00
parent bcb4925c6d
commit 7c48792511
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
2 changed files with 27 additions and 22 deletions

View File

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

View File

@ -518,13 +518,12 @@ mod test {
}
#[test]
fn test_awkward_points() {
fn test_low_order_points() {
use super::edwards;
//let rng = &mut XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
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| {
@ -533,7 +532,7 @@ mod test {
assert!(is_on_curve(x, y, params));
awkward_points.push(Point {
low_order_points.push(Point {
x: x,
y: y,
infinity: false,
@ -587,9 +586,9 @@ mod test {
}
// 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 mut ed_tmp = ed.clone();
let mut mont_tmp = point.clone();