mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-08 15:01:29 +01:00
Update for scalar mul change
This commit is contained in:
@@ -5,7 +5,7 @@ use ark_ec::{
|
|||||||
short_weierstrass::{Affine, SWCurveConfig},
|
short_weierstrass::{Affine, SWCurveConfig},
|
||||||
AffineCurve, ProjectiveCurve,
|
AffineCurve, ProjectiveCurve,
|
||||||
};
|
};
|
||||||
use ark_ff::{biginteger::BigInteger256, Field, MontFp, Zero};
|
use ark_ff::{Field, MontFp, Zero};
|
||||||
use ark_std::ops::Neg;
|
use ark_std::ops::Neg;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
@@ -50,17 +50,15 @@ impl SWCurveConfig for Parameters {
|
|||||||
//
|
//
|
||||||
// Check that endomorphism_p(P) == -[X^2]P
|
// Check that endomorphism_p(P) == -[X^2]P
|
||||||
|
|
||||||
let x = BigInteger256::new([crate::Parameters::X[0], 0, 0, 0]);
|
|
||||||
|
|
||||||
// An early-out optimization described in Section 6.
|
// An early-out optimization described in Section 6.
|
||||||
// If uP == P but P != point of infinity, then the point is not in the right
|
// If uP == P but P != point of infinity, then the point is not in the right
|
||||||
// subgroup.
|
// subgroup.
|
||||||
let x_times_p = p.mul(x);
|
let x_times_p = p.mul_bigint(crate::Parameters::X);
|
||||||
if x_times_p.eq(p) && !p.infinity {
|
if x_times_p.eq(p) && !p.infinity {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let minus_x_squared_times_p = x_times_p.mul(x).neg();
|
let minus_x_squared_times_p = x_times_p.mul_bigint(crate::Parameters::X).neg();
|
||||||
let endomorphism_p = endomorphism(p);
|
let endomorphism_p = endomorphism(p);
|
||||||
minus_x_squared_times_p.eq(&endomorphism_p)
|
minus_x_squared_times_p.eq(&endomorphism_p)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use ark_ec::{
|
|||||||
short_weierstrass::{Affine, SWCurveConfig},
|
short_weierstrass::{Affine, SWCurveConfig},
|
||||||
AffineCurve,
|
AffineCurve,
|
||||||
};
|
};
|
||||||
use ark_ff::{BigInt, Field, MontFp, Zero};
|
use ark_ff::{Field, MontFp, Zero};
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ impl SWCurveConfig for Parameters {
|
|||||||
//
|
//
|
||||||
// Checks that [p]P = [X]P
|
// Checks that [p]P = [X]P
|
||||||
|
|
||||||
let mut x_times_point = point.mul(BigInt::new([crate::Parameters::X[0], 0, 0, 0]));
|
let mut x_times_point = point.mul_bigint(crate::Parameters::X);
|
||||||
if crate::Parameters::X_IS_NEGATIVE {
|
if crate::Parameters::X_IS_NEGATIVE {
|
||||||
x_times_point = -x_times_point;
|
x_times_point = -x_times_point;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ fn test_g1_subgroup_non_membership_via_endomorphism() {
|
|||||||
let greatest = rng.gen();
|
let greatest = rng.gen();
|
||||||
|
|
||||||
if let Some(p) = G1Affine::get_point_from_x(x, greatest) {
|
if let Some(p) = G1Affine::get_point_from_x(x, greatest) {
|
||||||
if !p.into_projective().mul(Fr::characteristic()).is_zero() {
|
if !p.into_projective().mul_bigint(Fr::characteristic()).is_zero() {
|
||||||
assert!(!p.is_in_correct_subgroup_assuming_on_curve());
|
assert!(!p.is_in_correct_subgroup_assuming_on_curve());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ fn test_g2_subgroup_non_membership_via_endomorphism() {
|
|||||||
let greatest = rng.gen();
|
let greatest = rng.gen();
|
||||||
|
|
||||||
if let Some(p) = G2Affine::get_point_from_x(x, greatest) {
|
if let Some(p) = G2Affine::get_point_from_x(x, greatest) {
|
||||||
if !p.into_projective().mul(Fr::characteristic()).is_zero() {
|
if !p.into_projective().mul_bigint(Fr::characteristic()).is_zero() {
|
||||||
assert!(!p.is_in_correct_subgroup_assuming_on_curve());
|
assert!(!p.is_in_correct_subgroup_assuming_on_curve());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user