mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-08 23:11:29 +01:00
Upgrade for algebra/365 (#92)
* Upgrade for algebra/365 * Merge fix * Fix
This commit is contained in:
@@ -18,6 +18,14 @@ pub struct Parameters;
|
||||
impl ModelParameters for Parameters {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
/// COFACTOR = (x - 1)^2 / 3 = 76329603384216526031706109802092473003
|
||||
const COFACTOR: &'static [u64] = &[0x8c00aaab0000aaab, 0x396c8c005555e156];
|
||||
|
||||
/// COFACTOR_INV = COFACTOR^{-1} mod r
|
||||
/// = 52435875175126190458656871551744051925719901746859129887267498875565241663483
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "52435875175126190458656871551744051925719901746859129887267498875565241663483");
|
||||
}
|
||||
|
||||
impl SWModelParameters for Parameters {
|
||||
@@ -28,14 +36,6 @@ impl SWModelParameters for Parameters {
|
||||
#[rustfmt::skip]
|
||||
const COEFF_B: Fq = field_new!(Fq, "4");
|
||||
|
||||
/// COFACTOR = (x - 1)^2 / 3 = 76329603384216526031706109802092473003
|
||||
const COFACTOR: &'static [u64] = &[0x8c00aaab0000aaab, 0x396c8c005555e156];
|
||||
|
||||
/// COFACTOR_INV = COFACTOR^{-1} mod r
|
||||
/// = 52435875175126190458656871551744051925719901746859129887267498875565241663483
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "52435875175126190458656871551744051925719901746859129887267498875565241663483");
|
||||
|
||||
/// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
|
||||
(G1_GENERATOR_X, G1_GENERATOR_Y);
|
||||
@@ -45,7 +45,8 @@ impl SWModelParameters for Parameters {
|
||||
Self::BaseField::zero()
|
||||
}
|
||||
|
||||
fn is_in_correct_subgroup_assuming_on_curve(p: &GroupAffine<Parameters>) -> bool {
|
||||
#[inline]
|
||||
fn is_in_correct_subgroup_assuming_on_curve(p: &G1Affine) -> bool {
|
||||
// Algorithm from Section 6 of https://eprint.iacr.org/2021/1130.
|
||||
//
|
||||
// Check that endomorphism_p(P) == -[X^2]P
|
||||
|
||||
@@ -17,14 +17,6 @@ pub struct Parameters;
|
||||
impl ModelParameters for Parameters {
|
||||
type BaseField = Fq2;
|
||||
type ScalarField = Fr;
|
||||
}
|
||||
|
||||
impl SWModelParameters for Parameters {
|
||||
/// COEFF_A = [0, 0]
|
||||
const COEFF_A: Fq2 = field_new!(Fq2, g1::Parameters::COEFF_A, g1::Parameters::COEFF_A,);
|
||||
|
||||
/// COEFF_B = [4, 4]
|
||||
const COEFF_B: Fq2 = field_new!(Fq2, g1::Parameters::COEFF_B, g1::Parameters::COEFF_B,);
|
||||
|
||||
/// COFACTOR = (x^8 - 4 x^7 + 5 x^6) - (4 x^4 + 6 x^3 - 4 x^2 - 4 x + 13) //
|
||||
/// 9
|
||||
@@ -45,6 +37,14 @@ impl SWModelParameters for Parameters {
|
||||
/// 26652489039290660355457965112010883481355318854675681319708643586776743290055
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "26652489039290660355457965112010883481355318854675681319708643586776743290055");
|
||||
}
|
||||
|
||||
impl SWModelParameters for Parameters {
|
||||
/// COEFF_A = [0, 0]
|
||||
const COEFF_A: Fq2 = field_new!(Fq2, g1::Parameters::COEFF_A, g1::Parameters::COEFF_A,);
|
||||
|
||||
/// COEFF_B = [4, 4]
|
||||
const COEFF_B: Fq2 = field_new!(Fq2, g1::Parameters::COEFF_B, g1::Parameters::COEFF_B,);
|
||||
|
||||
/// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
|
||||
@@ -55,7 +55,7 @@ impl SWModelParameters for Parameters {
|
||||
Self::BaseField::zero()
|
||||
}
|
||||
|
||||
fn is_in_correct_subgroup_assuming_on_curve(point: &GroupAffine<Parameters>) -> bool {
|
||||
fn is_in_correct_subgroup_assuming_on_curve(point: &G2Affine) -> bool {
|
||||
// Algorithm from Section 4 of https://eprint.iacr.org/2021/1130.
|
||||
//
|
||||
// Checks that [p]P = [X]P
|
||||
|
||||
Reference in New Issue
Block a user