mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-12 10:05:47 +00:00
Some test cleanups.
This commit is contained in:
parent
bcb4925c6d
commit
7c48792511
@ -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(¶ms.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(¶ms.edwards_d);
|
||||
tmp = tmp.inverse().unwrap();
|
||||
tmp.mul_assign(&Fr::from_str("4").unwrap());
|
||||
tmp = tmp.sqrt().unwrap();
|
||||
assert_eq!(tmp, params.scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user