mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-12 18:15:49 +00:00
Some test cleanups.
This commit is contained in:
parent
bcb4925c6d
commit
7c48792511
@ -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(¶ms.edwards_d);
|
tmp.sub_assign(¶ms.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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user