From d25abb0ff61f6c3eade60b3d4b70eb5b88e15883 Mon Sep 17 00:00:00 2001 From: Pratyush Mishra Date: Thu, 15 Dec 2022 20:53:19 -0500 Subject: [PATCH 1/6] Rename all `*Parameters` to `*Config` --- ec/src/hashing/tests/suites.rs | 16 +++---- ec/src/models/bls12/g1.rs | 28 +++++------ ec/src/models/bls12/g2.rs | 46 +++++++++--------- ec/src/models/bls12/mod.rs | 18 +++---- ec/src/models/bn/g1.rs | 28 +++++------ ec/src/models/bn/g2.rs | 48 +++++++++---------- ec/src/models/bn/mod.rs | 18 +++---- ec/src/models/bw6/g1.rs | 30 ++++++------ ec/src/models/bw6/g2.rs | 40 ++++++++-------- ec/src/models/bw6/mod.rs | 18 +++---- ec/src/models/mnt4/g1.rs | 28 +++++------ ec/src/models/mnt4/g2.rs | 48 +++++++++---------- ec/src/models/mnt4/mod.rs | 18 +++---- ec/src/models/mnt6/g1.rs | 28 +++++------ ec/src/models/mnt6/g2.rs | 48 +++++++++---------- ec/src/models/mnt6/mod.rs | 18 +++---- ec/src/scalar_mul/glv.rs | 2 +- test-curves/src/bls12_381/g1.rs | 18 +++---- test-curves/src/bls12_381/g1_swu_iso.rs | 14 +++--- test-curves/src/bls12_381/g2.rs | 34 ++++++------- test-curves/src/bls12_381/g2_swu_iso.rs | 14 +++--- test-curves/src/bls12_381/mod.rs | 16 +++---- test-curves/src/bn384_small_two_adicity/g1.rs | 10 ++-- test-curves/src/mnt4_753/g1.rs | 10 ++-- test-curves/src/secp256k1/g1.rs | 10 ++-- 25 files changed, 302 insertions(+), 304 deletions(-) diff --git a/ec/src/hashing/tests/suites.rs b/ec/src/hashing/tests/suites.rs index c71ce02dd..20cc30d89 100644 --- a/ec/src/hashing/tests/suites.rs +++ b/ec/src/hashing/tests/suites.rs @@ -13,9 +13,7 @@ use ark_test_curves::{ }; use ark_ff::{Field, PrimeField}; -use ark_test_curves::bls12_381::{ - g1::Parameters as G1Parameters, g2::Parameters as G2Parameters, Fq, Fq2, -}; +use ark_test_curves::bls12_381::{g1::Config as G1Config, g2::Config as G2Config, Fq, Fq2}; use sha2::Sha256; #[test] @@ -38,15 +36,15 @@ fn run_test_w(data: &SuiteVector) -> Result<(), Failed> { let hasher; let m; let g1_mapper = MapToCurveBasedHasher::< - Projective, + Projective, DefaultFieldHasher, - WBMap, + WBMap, >::new(dst) .unwrap(); let g2_mapper = MapToCurveBasedHasher::< - Projective, + Projective, DefaultFieldHasher, - WBMap, + WBMap, >::new(dst) .unwrap(); match data.curve.as_str() { @@ -85,7 +83,7 @@ fn run_test_w(data: &SuiteVector) -> Result<(), Failed> { match data.curve.as_str() { "BLS12-381 G1" => { let got = g1_mapper.hash(&v.msg.as_bytes()).unwrap(); - let want = Affine::::new_unchecked( + let want = Affine::::new_unchecked( Fq::from_base_prime_field_elems(&x[..]).unwrap(), Fq::from_base_prime_field_elems(&y[..]).unwrap(), ); @@ -103,7 +101,7 @@ fn run_test_w(data: &SuiteVector) -> Result<(), Failed> { }, "BLS12-381 G2" => { let got = g2_mapper.hash(&v.msg.as_bytes()).unwrap(); - let want = Affine::::new_unchecked( + let want = Affine::::new_unchecked( Fq2::from_base_prime_field_elems(&x[..]).unwrap(), Fq2::from_base_prime_field_elems(&y[..]).unwrap(), ); diff --git a/ec/src/models/bls12/g1.rs b/ec/src/models/bls12/g1.rs index 8358265aa..2c229beb2 100644 --- a/ec/src/models/bls12/g1.rs +++ b/ec/src/models/bls12/g1.rs @@ -1,54 +1,54 @@ use crate::{ - bls12::Bls12Parameters, + bls12::Bls12Config, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; use ark_serialize::*; use ark_std::vec::Vec; -pub type G1Affine

= Affine<

::G1Parameters>; -pub type G1Projective

= Projective<

::G1Parameters>; +pub type G1Affine

= Affine<

::G1Config>; +pub type G1Projective

= Projective<

::G1Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: Bls12Parameters"), - Debug(bound = "P: Bls12Parameters"), - PartialEq(bound = "P: Bls12Parameters"), - Eq(bound = "P: Bls12Parameters") + Clone(bound = "P: Bls12Config"), + Debug(bound = "P: Bls12Config"), + PartialEq(bound = "P: Bls12Config"), + Eq(bound = "P: Bls12Config") )] -pub struct G1Prepared(pub G1Affine

); +pub struct G1Prepared(pub G1Affine

); -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(other: G1Affine

) -> Self { G1Prepared(other) } } -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(q: G1Projective

) -> Self { q.into_affine().into() } } -impl<'a, P: Bls12Parameters> From<&'a G1Affine

> for G1Prepared

{ +impl<'a, P: Bls12Config> From<&'a G1Affine

> for G1Prepared

{ fn from(other: &'a G1Affine

) -> Self { G1Prepared(*other) } } -impl<'a, P: Bls12Parameters> From<&'a G1Projective

> for G1Prepared

{ +impl<'a, P: Bls12Config> From<&'a G1Projective

> for G1Prepared

{ fn from(q: &'a G1Projective

) -> Self { q.into_affine().into() } } -impl G1Prepared

{ +impl G1Prepared

{ pub fn is_zero(&self) -> bool { self.0.is_zero() } } -impl Default for G1Prepared

{ +impl Default for G1Prepared

{ fn default() -> Self { G1Prepared(G1Affine::

::generator()) } diff --git a/ec/src/models/bls12/g2.rs b/ec/src/models/bls12/g2.rs index 4dfefd4dc..661486351 100644 --- a/ec/src/models/bls12/g2.rs +++ b/ec/src/models/bls12/g2.rs @@ -3,23 +3,23 @@ use ark_serialize::*; use ark_std::{vec::Vec, One}; use crate::{ - bls12::{Bls12Parameters, TwistType}, + bls12::{Bls12Config, TwistType}, models::short_weierstrass::SWCurveConfig, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; -pub type G2Affine

= Affine<

::G2Parameters>; -pub type G2Projective

= Projective<

::G2Parameters>; +pub type G2Affine

= Affine<

::G2Config>; +pub type G2Projective

= Projective<

::G2Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: Bls12Parameters"), - Debug(bound = "P: Bls12Parameters"), - PartialEq(bound = "P: Bls12Parameters"), - Eq(bound = "P: Bls12Parameters") + Clone(bound = "P: Bls12Config"), + Debug(bound = "P: Bls12Config"), + PartialEq(bound = "P: Bls12Config"), + Eq(bound = "P: Bls12Config") )] -pub struct G2Prepared { +pub struct G2Prepared { // Stores the coefficients of the line evaluations as calculated in // https://eprint.iacr.org/2013/722.pdf pub ell_coeffs: Vec>, @@ -27,30 +27,30 @@ pub struct G2Prepared { } pub(crate) type EllCoeff

= ( - Fp2<

::Fp2Config>, - Fp2<

::Fp2Config>, - Fp2<

::Fp2Config>, + Fp2<

::Fp2Config>, + Fp2<

::Fp2Config>, + Fp2<

::Fp2Config>, ); #[derive(Derivative)] #[derivative( - Clone(bound = "P: Bls12Parameters"), - Copy(bound = "P: Bls12Parameters"), - Debug(bound = "P: Bls12Parameters") + Clone(bound = "P: Bls12Config"), + Copy(bound = "P: Bls12Config"), + Debug(bound = "P: Bls12Config") )] -struct G2HomProjective { +struct G2HomProjective { x: Fp2, y: Fp2, z: Fp2, } -impl Default for G2Prepared

{ +impl Default for G2Prepared

{ fn default() -> Self { Self::from(G2Affine::

::generator()) } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(q: G2Affine

) -> Self { let two_inv = P::Fp::one().double().inverse().unwrap(); let zero = G2Prepared { @@ -81,31 +81,31 @@ impl From> for G2Prepared

{ } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(q: G2Projective

) -> Self { q.into_affine().into() } } -impl<'a, P: Bls12Parameters> From<&'a G2Affine

> for G2Prepared

{ +impl<'a, P: Bls12Config> From<&'a G2Affine

> for G2Prepared

{ fn from(other: &'a G2Affine

) -> Self { (*other).into() } } -impl<'a, P: Bls12Parameters> From<&'a G2Projective

> for G2Prepared

{ +impl<'a, P: Bls12Config> From<&'a G2Projective

> for G2Prepared

{ fn from(q: &'a G2Projective

) -> Self { q.into_affine().into() } } -impl G2Prepared

{ +impl G2Prepared

{ pub fn is_zero(&self) -> bool { self.infinity } } -impl G2HomProjective

{ +impl G2HomProjective

{ fn double_in_place(&mut self, two_inv: &P::Fp) -> EllCoeff

{ // Formula for line function when working with // homogeneous projective coordinates. @@ -114,7 +114,7 @@ impl G2HomProjective

{ a.mul_assign_by_fp(two_inv); let b = self.y.square(); let c = self.z.square(); - let e = P::G2Parameters::COEFF_B * &(c.double() + &c); + let e = P::G2Config::COEFF_B * &(c.double() + &c); let f = e.double() + &e; let mut g = b + &f; g.mul_assign_by_fp(two_inv); diff --git a/ec/src/models/bls12/mod.rs b/ec/src/models/bls12/mod.rs index 3feca4080..56956bc8c 100644 --- a/ec/src/models/bls12/mod.rs +++ b/ec/src/models/bls12/mod.rs @@ -25,7 +25,7 @@ pub enum TwistType { D, } -pub trait Bls12Parameters: 'static + Sized { +pub trait Bls12Config: 'static + Sized { /// Parameterizes the BLS12 family. const X: &'static [u64]; /// Is `Self::X` negative? @@ -37,10 +37,10 @@ pub trait Bls12Parameters: 'static + Sized { type Fp2Config: Fp2Config; type Fp6Config: Fp6Config; type Fp12Config: Fp12Config; - type G1Parameters: SWCurveConfig; - type G2Parameters: SWCurveConfig< + type G1Config: SWCurveConfig; + type G2Config: SWCurveConfig< BaseField = Fp2, - ScalarField = ::ScalarField, + ScalarField = ::ScalarField, >; fn multi_miller_loop( @@ -166,9 +166,9 @@ pub use self::{ #[derive(Derivative)] #[derivative(Copy, Clone, PartialEq, Eq, Debug, Hash)] -pub struct Bls12(PhantomData P>); +pub struct Bls12(PhantomData P>); -impl Bls12

{ +impl Bls12

{ // Evaluate the line function at point p. fn ell(f: &mut Fp12, coeffs: &g2::EllCoeff

, p: &G1Affine

) { let mut c0 = coeffs.0; @@ -199,9 +199,9 @@ impl Bls12

{ } } -impl Pairing for Bls12

{ - type BaseField = ::BaseField; - type ScalarField = ::ScalarField; +impl Pairing for Bls12

{ + type BaseField = ::BaseField; + type ScalarField = ::ScalarField; type G1 = G1Projective

; type G1Affine = G1Affine

; type G1Prepared = G1Prepared

; diff --git a/ec/src/models/bn/g1.rs b/ec/src/models/bn/g1.rs index e23f96a5b..4a6ea65b8 100644 --- a/ec/src/models/bn/g1.rs +++ b/ec/src/models/bn/g1.rs @@ -1,54 +1,54 @@ use crate::{ - bn::BnParameters, + bn::BnConfig, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; use ark_serialize::*; use ark_std::vec::Vec; -pub type G1Affine

= Affine<

::G1Parameters>; -pub type G1Projective

= Projective<

::G1Parameters>; +pub type G1Affine

= Affine<

::G1Config>; +pub type G1Projective

= Projective<

::G1Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: BnParameters"), - Debug(bound = "P: BnParameters"), - PartialEq(bound = "P: BnParameters"), - Eq(bound = "P: BnParameters") + Clone(bound = "P: BnConfig"), + Debug(bound = "P: BnConfig"), + PartialEq(bound = "P: BnConfig"), + Eq(bound = "P: BnConfig") )] -pub struct G1Prepared(pub G1Affine

); +pub struct G1Prepared(pub G1Affine

); -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(other: G1Affine

) -> Self { G1Prepared(other) } } -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(q: G1Projective

) -> Self { q.into_affine().into() } } -impl<'a, P: BnParameters> From<&'a G1Affine

> for G1Prepared

{ +impl<'a, P: BnConfig> From<&'a G1Affine

> for G1Prepared

{ fn from(other: &'a G1Affine

) -> Self { G1Prepared(*other) } } -impl<'a, P: BnParameters> From<&'a G1Projective

> for G1Prepared

{ +impl<'a, P: BnConfig> From<&'a G1Projective

> for G1Prepared

{ fn from(q: &'a G1Projective

) -> Self { q.into_affine().into() } } -impl G1Prepared

{ +impl G1Prepared

{ pub fn is_zero(&self) -> bool { self.0.infinity } } -impl Default for G1Prepared

{ +impl Default for G1Prepared

{ fn default() -> Self { G1Prepared(G1Affine::

::generator()) } diff --git a/ec/src/models/bn/g2.rs b/ec/src/models/bn/g2.rs index 0afe39043..0e05fb8de 100644 --- a/ec/src/models/bn/g2.rs +++ b/ec/src/models/bn/g2.rs @@ -4,23 +4,23 @@ use ark_std::vec::Vec; use num_traits::One; use crate::{ - bn::{BnParameters, TwistType}, + bn::{BnConfig, TwistType}, models::short_weierstrass::SWCurveConfig, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; -pub type G2Affine

= Affine<

::G2Parameters>; -pub type G2Projective

= Projective<

::G2Parameters>; +pub type G2Affine

= Affine<

::G2Config>; +pub type G2Projective

= Projective<

::G2Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: BnParameters"), - Debug(bound = "P: BnParameters"), - PartialEq(bound = "P: BnParameters"), - Eq(bound = "P: BnParameters") + Clone(bound = "P: BnConfig"), + Debug(bound = "P: BnConfig"), + PartialEq(bound = "P: BnConfig"), + Eq(bound = "P: BnConfig") )] -pub struct G2Prepared { +pub struct G2Prepared { // Stores the coefficients of the line evaluations as calculated in // https://eprint.iacr.org/2013/722.pdf pub ell_coeffs: Vec>, @@ -28,24 +28,24 @@ pub struct G2Prepared { } pub(crate) type EllCoeff

= ( - Fp2<

::Fp2Config>, - Fp2<

::Fp2Config>, - Fp2<

::Fp2Config>, + Fp2<

::Fp2Config>, + Fp2<

::Fp2Config>, + Fp2<

::Fp2Config>, ); #[derive(Derivative)] #[derivative( - Clone(bound = "P: BnParameters"), - Copy(bound = "P: BnParameters"), - Debug(bound = "P: BnParameters") + Clone(bound = "P: BnConfig"), + Copy(bound = "P: BnConfig"), + Debug(bound = "P: BnConfig") )] -struct G2HomProjective { +struct G2HomProjective { x: Fp2, y: Fp2, z: Fp2, } -impl G2HomProjective

{ +impl G2HomProjective

{ fn double_in_place(&mut self, two_inv: &P::Fp) -> EllCoeff

{ // Formula for line function when working with // homogeneous projective coordinates. @@ -54,7 +54,7 @@ impl G2HomProjective

{ a.mul_assign_by_fp(two_inv); let b = self.y.square(); let c = self.z.square(); - let e = P::G2Parameters::COEFF_B * &(c.double() + &c); + let e = P::G2Config::COEFF_B * &(c.double() + &c); let f = e.double() + &e; let mut g = b + &f; g.mul_assign_by_fp(two_inv); @@ -95,13 +95,13 @@ impl G2HomProjective

{ } } -impl Default for G2Prepared

{ +impl Default for G2Prepared

{ fn default() -> Self { Self::from(G2Affine::

::generator()) } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(q: G2Affine

) -> Self { if q.infinity { G2Prepared { @@ -149,31 +149,31 @@ impl From> for G2Prepared

{ } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(q: G2Projective

) -> Self { q.into_affine().into() } } -impl<'a, P: BnParameters> From<&'a G2Affine

> for G2Prepared

{ +impl<'a, P: BnConfig> From<&'a G2Affine

> for G2Prepared

{ fn from(other: &'a G2Affine

) -> Self { (*other).into() } } -impl<'a, P: BnParameters> From<&'a G2Projective

> for G2Prepared

{ +impl<'a, P: BnConfig> From<&'a G2Projective

> for G2Prepared

{ fn from(q: &'a G2Projective

) -> Self { q.into_affine().into() } } -impl G2Prepared

{ +impl G2Prepared

{ pub fn is_zero(&self) -> bool { self.infinity } } -fn mul_by_char(r: G2Affine

) -> G2Affine

{ +fn mul_by_char(r: G2Affine

) -> G2Affine

{ // multiply by field characteristic let mut s = r; diff --git a/ec/src/models/bn/mod.rs b/ec/src/models/bn/mod.rs index c1933a7fc..8b4bc1e05 100644 --- a/ec/src/models/bn/mod.rs +++ b/ec/src/models/bn/mod.rs @@ -23,7 +23,7 @@ pub enum TwistType { D, } -pub trait BnParameters: 'static { +pub trait BnConfig: 'static { /// The absolute value of the BN curve parameter `X` /// (as in `q = 36 X^4 + 36 X^3 + 24 X^2 + 6 X + 1`). const X: &'static [u64]; @@ -41,10 +41,10 @@ pub trait BnParameters: 'static { type Fp2Config: Fp2Config; type Fp6Config: Fp6Config; type Fp12Config: Fp12Config; - type G1Parameters: SWCurveConfig; - type G2Parameters: SWCurveConfig< + type G1Config: SWCurveConfig; + type G2Config: SWCurveConfig< BaseField = Fp2, - ScalarField = ::ScalarField, + ScalarField = ::ScalarField, >; } @@ -58,9 +58,9 @@ pub use self::{ #[derive(Derivative)] #[derivative(Copy, Clone, PartialEq, Eq, Debug, Hash)] -pub struct Bn(PhantomData P>); +pub struct Bn(PhantomData P>); -impl Bn

{ +impl Bn

{ /// Evaluates the line function at point p. fn ell(f: &mut Fp12, coeffs: &g2::EllCoeff

, p: &G1Affine

) { let mut c0 = coeffs.0; @@ -90,9 +90,9 @@ impl Bn

{ } } -impl Pairing for Bn

{ - type BaseField = ::BaseField; - type ScalarField = ::ScalarField; +impl Pairing for Bn

{ + type BaseField = ::BaseField; + type ScalarField = ::ScalarField; type G1 = G1Projective

; type G1Affine = G1Affine

; type G1Prepared = G1Prepared

; diff --git a/ec/src/models/bw6/g1.rs b/ec/src/models/bw6/g1.rs index aaf732258..6960d19d7 100644 --- a/ec/src/models/bw6/g1.rs +++ b/ec/src/models/bw6/g1.rs @@ -1,55 +1,55 @@ use crate::{ - bw6::BW6Parameters, + bw6::BW6Config, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; use ark_serialize::*; use ark_std::vec::Vec; -pub type G1Affine

= Affine<

::G1Parameters>; -pub type G1Projective

= Projective<

::G1Parameters>; +pub type G1Affine

= Affine<

::G1Config>; +pub type G1Projective

= Projective<

::G1Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Copy(bound = "P: BW6Parameters"), - Clone(bound = "P: BW6Parameters"), - Debug(bound = "P: BW6Parameters"), - PartialEq(bound = "P: BW6Parameters"), - Eq(bound = "P: BW6Parameters") + Copy(bound = "P: BW6Config"), + Clone(bound = "P: BW6Config"), + Debug(bound = "P: BW6Config"), + PartialEq(bound = "P: BW6Config"), + Eq(bound = "P: BW6Config") )] -pub struct G1Prepared(pub G1Affine

); +pub struct G1Prepared(pub G1Affine

); -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(other: G1Affine

) -> Self { G1Prepared(other) } } -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(q: G1Projective

) -> Self { q.into_affine().into() } } -impl<'a, P: BW6Parameters> From<&'a G1Affine

> for G1Prepared

{ +impl<'a, P: BW6Config> From<&'a G1Affine

> for G1Prepared

{ fn from(other: &'a G1Affine

) -> Self { G1Prepared(*other) } } -impl<'a, P: BW6Parameters> From<&'a G1Projective

> for G1Prepared

{ +impl<'a, P: BW6Config> From<&'a G1Projective

> for G1Prepared

{ fn from(q: &'a G1Projective

) -> Self { q.into_affine().into() } } -impl G1Prepared

{ +impl G1Prepared

{ pub fn is_zero(&self) -> bool { self.0.infinity } } -impl Default for G1Prepared

{ +impl Default for G1Prepared

{ fn default() -> Self { G1Prepared(G1Affine::

::generator()) } diff --git a/ec/src/models/bw6/g2.rs b/ec/src/models/bw6/g2.rs index 2196fd56b..02430bead 100644 --- a/ec/src/models/bw6/g2.rs +++ b/ec/src/models/bw6/g2.rs @@ -4,23 +4,23 @@ use ark_std::vec::Vec; use num_traits::One; use crate::{ - bw6::{BW6Parameters, TwistType}, + bw6::{BW6Config, TwistType}, models::short_weierstrass::SWCurveConfig, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; -pub type G2Affine

= Affine<

::G2Parameters>; -pub type G2Projective

= Projective<

::G2Parameters>; +pub type G2Affine

= Affine<

::G2Config>; +pub type G2Projective

= Projective<

::G2Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: BW6Parameters"), - Debug(bound = "P: BW6Parameters"), - PartialEq(bound = "P: BW6Parameters"), - Eq(bound = "P: BW6Parameters") + Clone(bound = "P: BW6Config"), + Debug(bound = "P: BW6Config"), + PartialEq(bound = "P: BW6Config"), + Eq(bound = "P: BW6Config") )] -pub struct G2Prepared { +pub struct G2Prepared { // Stores the coefficients of the line evaluations as calculated in // https://eprint.iacr.org/2013/722.pdf pub ell_coeffs_1: Vec<(P::Fp, P::Fp, P::Fp)>, @@ -30,23 +30,23 @@ pub struct G2Prepared { #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: BW6Parameters"), - Copy(bound = "P: BW6Parameters"), - Debug(bound = "P: BW6Parameters") + Clone(bound = "P: BW6Config"), + Copy(bound = "P: BW6Config"), + Debug(bound = "P: BW6Config") )] -struct G2HomProjective { +struct G2HomProjective { x: P::Fp, y: P::Fp, z: P::Fp, } -impl Default for G2Prepared

{ +impl Default for G2Prepared

{ fn default() -> Self { Self::from(G2Affine::

::generator()) } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(q: G2Affine

) -> Self { if q.infinity { return Self { @@ -100,31 +100,31 @@ impl From> for G2Prepared

{ } } -impl<'a, P: BW6Parameters> From<&'a G2Affine

> for G2Prepared

{ +impl<'a, P: BW6Config> From<&'a G2Affine

> for G2Prepared

{ fn from(q: &'a G2Affine

) -> Self { (*q).into() } } -impl<'a, P: BW6Parameters> From<&'a G2Projective

> for G2Prepared

{ +impl<'a, P: BW6Config> From<&'a G2Projective

> for G2Prepared

{ fn from(q: &'a G2Projective

) -> Self { q.into_affine().into() } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(q: G2Projective

) -> Self { q.into_affine().into() } } -impl G2Prepared

{ +impl G2Prepared

{ pub fn is_zero(&self) -> bool { self.infinity } } -impl G2HomProjective

{ +impl G2HomProjective

{ fn double_in_place(&mut self) -> (P::Fp, P::Fp, P::Fp) { // Formula for line function when working with // homogeneous projective coordinates, as described in https://eprint.iacr.org/2013/722.pdf. @@ -133,7 +133,7 @@ impl G2HomProjective

{ let b = self.y.square(); let b4 = b.double().double(); let c = self.z.square(); - let e = P::G2Parameters::COEFF_B * &(c.double() + &c); + let e = P::G2Config::COEFF_B * &(c.double() + &c); let f = e.double() + &e; let g = b + &f; let h = (self.y + &self.z).square() - &(b + &c); diff --git a/ec/src/models/bw6/mod.rs b/ec/src/models/bw6/mod.rs index 0608173bf..1167c9b36 100644 --- a/ec/src/models/bw6/mod.rs +++ b/ec/src/models/bw6/mod.rs @@ -23,7 +23,7 @@ pub enum TwistType { D, } -pub trait BW6Parameters: 'static + Eq + PartialEq { +pub trait BW6Config: 'static + Eq + PartialEq { const X: ::BigInt; const X_IS_NEGATIVE: bool; const ATE_LOOP_COUNT_1: &'static [u64]; @@ -34,10 +34,10 @@ pub trait BW6Parameters: 'static + Eq + PartialEq { type Fp: PrimeField + Into<::BigInt>; type Fp3Config: Fp3Config; type Fp6Config: Fp6Config; - type G1Parameters: SWCurveConfig; - type G2Parameters: SWCurveConfig< + type G1Config: SWCurveConfig; + type G2Config: SWCurveConfig< BaseField = Self::Fp, - ScalarField = ::ScalarField, + ScalarField = ::ScalarField, >; } @@ -51,9 +51,9 @@ pub use self::{ #[derive(Derivative)] #[derivative(Copy, Clone, PartialEq, Eq, Debug, Hash)] -pub struct BW6(PhantomData P>); +pub struct BW6(PhantomData P>); -impl BW6

{ +impl BW6

{ // Evaluate the line function at point p. fn ell(f: &mut Fp6, coeffs: &(P::Fp, P::Fp, P::Fp), p: &G1Affine

) { let mut c0 = coeffs.0; @@ -210,9 +210,9 @@ impl BW6

{ } } -impl Pairing for BW6

{ - type BaseField = ::BaseField; - type ScalarField = ::ScalarField; +impl Pairing for BW6

{ + type BaseField = ::BaseField; + type ScalarField = ::ScalarField; type G1 = G1Projective

; type G1Affine = G1Affine

; type G1Prepared = G1Prepared

; diff --git a/ec/src/models/mnt4/g1.rs b/ec/src/models/mnt4/g1.rs index 0d6a25bcb..98ece3c61 100644 --- a/ec/src/models/mnt4/g1.rs +++ b/ec/src/models/mnt4/g1.rs @@ -1,5 +1,5 @@ use crate::{ - mnt4::MNT4Parameters, + mnt4::MNT4Config, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; @@ -7,25 +7,25 @@ use ark_ff::Fp2; use ark_serialize::*; use ark_std::vec::Vec; -pub type G1Affine

= Affine<

::G1Parameters>; -pub type G1Projective

= Projective<

::G1Parameters>; +pub type G1Affine

= Affine<

::G1Config>; +pub type G1Projective

= Projective<

::G1Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Copy(bound = "P: MNT4Parameters"), - Clone(bound = "P: MNT4Parameters"), - Debug(bound = "P: MNT4Parameters"), - PartialEq(bound = "P: MNT4Parameters"), - Eq(bound = "P: MNT4Parameters") + Copy(bound = "P: MNT4Config"), + Clone(bound = "P: MNT4Config"), + Debug(bound = "P: MNT4Config"), + PartialEq(bound = "P: MNT4Config"), + Eq(bound = "P: MNT4Config") )] -pub struct G1Prepared { +pub struct G1Prepared { pub x: P::Fp, pub y: P::Fp, pub x_twist: Fp2, pub y_twist: Fp2, } -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(g1: G1Affine

) -> Self { let mut x_twist = P::TWIST; x_twist.mul_assign_by_fp(&g1.x); @@ -42,24 +42,24 @@ impl From> for G1Prepared

{ } } -impl<'a, P: MNT4Parameters> From<&'a G1Affine

> for G1Prepared

{ +impl<'a, P: MNT4Config> From<&'a G1Affine

> for G1Prepared

{ fn from(g1: &'a G1Affine

) -> Self { (*g1).into() } } -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(g1: G1Projective

) -> Self { g1.into_affine().into() } } -impl<'a, P: MNT4Parameters> From<&'a G1Projective

> for G1Prepared

{ +impl<'a, P: MNT4Config> From<&'a G1Projective

> for G1Prepared

{ fn from(g1: &'a G1Projective

) -> Self { (*g1).into() } } -impl Default for G1Prepared

{ +impl Default for G1Prepared

{ fn default() -> Self { Self::from(G1Affine::

::generator()) } diff --git a/ec/src/models/mnt4/g2.rs b/ec/src/models/mnt4/g2.rs index 439d88133..a27167769 100644 --- a/ec/src/models/mnt4/g2.rs +++ b/ec/src/models/mnt4/g2.rs @@ -1,7 +1,7 @@ use ark_std::ops::Neg; use crate::{ - mnt4::MNT4Parameters, + mnt4::MNT4Config, models::mnt4::MNT4, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, @@ -11,17 +11,17 @@ use ark_serialize::*; use ark_std::vec::Vec; use num_traits::One; -pub type G2Affine

= Affine<

::G2Parameters>; -pub type G2Projective

= Projective<

::G2Parameters>; +pub type G2Affine

= Affine<

::G2Config>; +pub type G2Projective

= Projective<

::G2Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: MNT4Parameters"), - Debug(bound = "P: MNT4Parameters"), - PartialEq(bound = "P: MNT4Parameters"), - Eq(bound = "P: MNT4Parameters") + Clone(bound = "P: MNT4Config"), + Debug(bound = "P: MNT4Config"), + PartialEq(bound = "P: MNT4Config"), + Eq(bound = "P: MNT4Config") )] -pub struct G2Prepared { +pub struct G2Prepared { pub x: Fp2, pub y: Fp2, pub x_over_twist: Fp2, @@ -30,13 +30,13 @@ pub struct G2Prepared { pub addition_coefficients: Vec>, } -impl Default for G2Prepared

{ +impl Default for G2Prepared

{ fn default() -> Self { Self::from(G2Affine::

::generator()) } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(g: G2Affine

) -> Self { let twist_inv = P::TWIST.inverse().unwrap(); @@ -92,24 +92,24 @@ impl From> for G2Prepared

{ } } -impl<'a, P: MNT4Parameters> From<&'a G2Affine

> for G2Prepared

{ +impl<'a, P: MNT4Config> From<&'a G2Affine

> for G2Prepared

{ fn from(g2: &'a G2Affine

) -> Self { (*g2).into() } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(g2: G2Projective

) -> Self { g2.into_affine().into() } } -impl<'a, P: MNT4Parameters> From<&'a G2Projective

> for G2Prepared

{ +impl<'a, P: MNT4Config> From<&'a G2Projective

> for G2Prepared

{ fn from(g2: &'a G2Projective

) -> Self { (*g2).into() } } -pub(super) struct G2ProjectiveExtended { +pub(super) struct G2ProjectiveExtended { pub(crate) x: Fp2, pub(crate) y: Fp2, pub(crate) z: Fp2, @@ -118,12 +118,12 @@ pub(super) struct G2ProjectiveExtended { #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: MNT4Parameters"), - Debug(bound = "P: MNT4Parameters"), - PartialEq(bound = "P: MNT4Parameters"), - Eq(bound = "P: MNT4Parameters") + Clone(bound = "P: MNT4Config"), + Debug(bound = "P: MNT4Config"), + PartialEq(bound = "P: MNT4Config"), + Eq(bound = "P: MNT4Config") )] -pub struct AteDoubleCoefficients { +pub struct AteDoubleCoefficients { pub c_h: Fp2, pub c_4c: Fp2, pub c_j: Fp2, @@ -132,12 +132,12 @@ pub struct AteDoubleCoefficients { #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: MNT4Parameters"), - Debug(bound = "P: MNT4Parameters"), - PartialEq(bound = "P: MNT4Parameters"), - Eq(bound = "P: MNT4Parameters") + Clone(bound = "P: MNT4Config"), + Debug(bound = "P: MNT4Config"), + PartialEq(bound = "P: MNT4Config"), + Eq(bound = "P: MNT4Config") )] -pub struct AteAdditionCoefficients { +pub struct AteAdditionCoefficients { pub c_l1: Fp2, pub c_rz: Fp2, } diff --git a/ec/src/models/mnt4/mod.rs b/ec/src/models/mnt4/mod.rs index 60991be4d..2f0159482 100644 --- a/ec/src/models/mnt4/mod.rs +++ b/ec/src/models/mnt4/mod.rs @@ -26,7 +26,7 @@ pub use self::{ pub type GT

= Fp4

; -pub trait MNT4Parameters: 'static { +pub trait MNT4Config: 'static { const TWIST: Fp2; const TWIST_COEFF_A: Fp2; const ATE_LOOP_COUNT: &'static [i8]; @@ -38,18 +38,18 @@ pub trait MNT4Parameters: 'static { type Fr: PrimeField + Into<::BigInt>; type Fp2Config: Fp2Config; type Fp4Config: Fp4Config; - type G1Parameters: SWCurveConfig; - type G2Parameters: SWCurveConfig< + type G1Config: SWCurveConfig; + type G2Config: SWCurveConfig< BaseField = Fp2, - ScalarField = ::ScalarField, + ScalarField = ::ScalarField, >; } #[derive(Derivative)] #[derivative(Copy, Clone, PartialEq, Eq, Debug, Hash)] -pub struct MNT4(PhantomData P>); +pub struct MNT4(PhantomData P>); -impl MNT4

{ +impl MNT4

{ fn doubling_for_flipped_miller_loop( r: &G2ProjectiveExtended

, ) -> (G2ProjectiveExtended

, AteDoubleCoefficients

) { @@ -196,9 +196,9 @@ impl MNT4

{ } } -impl Pairing for MNT4

{ - type BaseField = ::BaseField; - type ScalarField = ::ScalarField; +impl Pairing for MNT4

{ + type BaseField = ::BaseField; + type ScalarField = ::ScalarField; type G1 = G1Projective

; type G1Affine = G1Affine

; type G1Prepared = G1Prepared

; diff --git a/ec/src/models/mnt6/g1.rs b/ec/src/models/mnt6/g1.rs index 824aa7885..c66ed5af7 100644 --- a/ec/src/models/mnt6/g1.rs +++ b/ec/src/models/mnt6/g1.rs @@ -1,5 +1,5 @@ use crate::{ - mnt6::MNT6Parameters, + mnt6::MNT6Config, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, }; @@ -7,25 +7,25 @@ use ark_ff::Fp3; use ark_serialize::*; use ark_std::vec::Vec; -pub type G1Affine

= Affine<

::G1Parameters>; -pub type G1Projective

= Projective<

::G1Parameters>; +pub type G1Affine

= Affine<

::G1Config>; +pub type G1Projective

= Projective<

::G1Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Copy(bound = "P: MNT6Parameters"), - Clone(bound = "P: MNT6Parameters"), - Debug(bound = "P: MNT6Parameters"), - PartialEq(bound = "P: MNT6Parameters"), - Eq(bound = "P: MNT6Parameters") + Copy(bound = "P: MNT6Config"), + Clone(bound = "P: MNT6Config"), + Debug(bound = "P: MNT6Config"), + PartialEq(bound = "P: MNT6Config"), + Eq(bound = "P: MNT6Config") )] -pub struct G1Prepared { +pub struct G1Prepared { pub x: P::Fp, pub y: P::Fp, pub x_twist: Fp3, pub y_twist: Fp3, } -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(g1: G1Affine

) -> Self { let mut x_twist = P::TWIST; x_twist.mul_assign_by_fp(&g1.x); @@ -42,24 +42,24 @@ impl From> for G1Prepared

{ } } -impl<'a, P: MNT6Parameters> From<&'a G1Affine

> for G1Prepared

{ +impl<'a, P: MNT6Config> From<&'a G1Affine

> for G1Prepared

{ fn from(g1: &'a G1Affine

) -> Self { (*g1).into() } } -impl From> for G1Prepared

{ +impl From> for G1Prepared

{ fn from(g1: G1Projective

) -> Self { g1.into_affine().into() } } -impl<'a, P: MNT6Parameters> From<&'a G1Projective

> for G1Prepared

{ +impl<'a, P: MNT6Config> From<&'a G1Projective

> for G1Prepared

{ fn from(g1: &'a G1Projective

) -> Self { (*g1).into() } } -impl Default for G1Prepared

{ +impl Default for G1Prepared

{ fn default() -> Self { Self::from(G1Affine::

::generator()) } diff --git a/ec/src/models/mnt6/g2.rs b/ec/src/models/mnt6/g2.rs index 0a62247fd..0a79a270a 100644 --- a/ec/src/models/mnt6/g2.rs +++ b/ec/src/models/mnt6/g2.rs @@ -1,7 +1,7 @@ use core::ops::Neg; use crate::{ - mnt6::MNT6Parameters, + mnt6::MNT6Config, models::mnt6::MNT6, short_weierstrass::{Affine, Projective}, AffineRepr, CurveGroup, @@ -11,17 +11,17 @@ use ark_serialize::*; use ark_std::vec::Vec; use num_traits::One; -pub type G2Affine

= Affine<

::G2Parameters>; -pub type G2Projective

= Projective<

::G2Parameters>; +pub type G2Affine

= Affine<

::G2Config>; +pub type G2Projective

= Projective<

::G2Config>; #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: MNT6Parameters"), - Debug(bound = "P: MNT6Parameters"), - PartialEq(bound = "P: MNT6Parameters"), - Eq(bound = "P: MNT6Parameters") + Clone(bound = "P: MNT6Config"), + Debug(bound = "P: MNT6Config"), + PartialEq(bound = "P: MNT6Config"), + Eq(bound = "P: MNT6Config") )] -pub struct G2Prepared { +pub struct G2Prepared { pub x: Fp3, pub y: Fp3, pub x_over_twist: Fp3, @@ -30,13 +30,13 @@ pub struct G2Prepared { pub addition_coefficients: Vec>, } -impl Default for G2Prepared

{ +impl Default for G2Prepared

{ fn default() -> Self { Self::from(G2Affine::

::generator()) } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(g: G2Affine

) -> Self { let twist_inv = P::TWIST.inverse().unwrap(); @@ -89,24 +89,24 @@ impl From> for G2Prepared

{ } } -impl<'a, P: MNT6Parameters> From<&'a G2Affine

> for G2Prepared

{ +impl<'a, P: MNT6Config> From<&'a G2Affine

> for G2Prepared

{ fn from(g2: &'a G2Affine

) -> Self { (*g2).into() } } -impl From> for G2Prepared

{ +impl From> for G2Prepared

{ fn from(g2: G2Projective

) -> Self { g2.into_affine().into() } } -impl<'a, P: MNT6Parameters> From<&'a G2Projective

> for G2Prepared

{ +impl<'a, P: MNT6Config> From<&'a G2Projective

> for G2Prepared

{ fn from(g2: &'a G2Projective

) -> Self { (*g2).into() } } -pub(super) struct G2ProjectiveExtended { +pub(super) struct G2ProjectiveExtended { pub(crate) x: Fp3, pub(crate) y: Fp3, pub(crate) z: Fp3, @@ -115,12 +115,12 @@ pub(super) struct G2ProjectiveExtended { #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: MNT6Parameters"), - Debug(bound = "P: MNT6Parameters"), - PartialEq(bound = "P: MNT6Parameters"), - Eq(bound = "P: MNT6Parameters") + Clone(bound = "P: MNT6Config"), + Debug(bound = "P: MNT6Config"), + PartialEq(bound = "P: MNT6Config"), + Eq(bound = "P: MNT6Config") )] -pub struct AteDoubleCoefficients { +pub struct AteDoubleCoefficients { pub c_h: Fp3, pub c_4c: Fp3, pub c_j: Fp3, @@ -129,12 +129,12 @@ pub struct AteDoubleCoefficients { #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] #[derivative( - Clone(bound = "P: MNT6Parameters"), - Debug(bound = "P: MNT6Parameters"), - PartialEq(bound = "P: MNT6Parameters"), - Eq(bound = "P: MNT6Parameters") + Clone(bound = "P: MNT6Config"), + Debug(bound = "P: MNT6Config"), + PartialEq(bound = "P: MNT6Config"), + Eq(bound = "P: MNT6Config") )] -pub struct AteAdditionCoefficients { +pub struct AteAdditionCoefficients { pub c_l1: Fp3, pub c_rz: Fp3, } diff --git a/ec/src/models/mnt6/mod.rs b/ec/src/models/mnt6/mod.rs index 89ef7e24e..f49dab433 100644 --- a/ec/src/models/mnt6/mod.rs +++ b/ec/src/models/mnt6/mod.rs @@ -26,7 +26,7 @@ pub use self::{ pub type GT

= Fp6

; -pub trait MNT6Parameters: 'static { +pub trait MNT6Config: 'static { const TWIST: Fp3; const TWIST_COEFF_A: Fp3; const ATE_LOOP_COUNT: &'static [i8]; @@ -38,18 +38,18 @@ pub trait MNT6Parameters: 'static { type Fr: PrimeField + Into<::BigInt>; type Fp3Config: Fp3Config; type Fp6Config: Fp6Config; - type G1Parameters: SWCurveConfig; - type G2Parameters: SWCurveConfig< + type G1Config: SWCurveConfig; + type G2Config: SWCurveConfig< BaseField = Fp3, - ScalarField = ::ScalarField, + ScalarField = ::ScalarField, >; } #[derive(Derivative)] #[derivative(Copy, Clone, PartialEq, Eq, Debug, Hash)] -pub struct MNT6(PhantomData P>); +pub struct MNT6(PhantomData P>); -impl MNT6

{ +impl MNT6

{ fn doubling_for_flipped_miller_loop( r: &G2ProjectiveExtended

, ) -> (G2ProjectiveExtended

, AteDoubleCoefficients

) { @@ -202,9 +202,9 @@ impl MNT6

{ } } -impl Pairing for MNT6

{ - type BaseField = ::BaseField; - type ScalarField = ::ScalarField; +impl Pairing for MNT6

{ + type BaseField = ::BaseField; + type ScalarField = ::ScalarField; type G1 = G1Projective

; type G1Affine = G1Affine

; type G1Prepared = G1Prepared

; diff --git a/ec/src/scalar_mul/glv.rs b/ec/src/scalar_mul/glv.rs index 7feb60693..87f86176a 100644 --- a/ec/src/scalar_mul/glv.rs +++ b/ec/src/scalar_mul/glv.rs @@ -1,7 +1,7 @@ use crate::{CurveConfig, CurveGroup}; /// The GLV parameters for computing the endomorphism and scalar decomposition. -pub trait GLVParameters: Send + Sync + 'static + CurveConfig { +pub trait GLVConfig: Send + Sync + 'static + CurveConfig { /// A representation of curve points that enables efficient arithmetic by /// avoiding inversions. type Curve: CurveGroup; diff --git a/test-curves/src/bls12_381/g1.rs b/test-curves/src/bls12_381/g1.rs index e37b7c9c9..0c76986cc 100644 --- a/test-curves/src/bls12_381/g1.rs +++ b/test-curves/src/bls12_381/g1.rs @@ -6,13 +6,13 @@ use ark_ec::{ }; use ark_ff::{MontFp, Zero}; -pub type G1Affine = Affine; -pub type G1Projective = Projective; +pub type G1Affine = Affine; +pub type G1Projective = Projective; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq; type ScalarField = Fr; @@ -25,7 +25,7 @@ impl CurveConfig for Parameters { const COFACTOR_INV: Fr = MontFp!("52435875175126190458656871551744051925719901746859129887267498875565241663483"); } -impl short_weierstrass::SWCurveConfig for Parameters { +impl short_weierstrass::SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = MontFp!("0"); @@ -49,13 +49,13 @@ impl short_weierstrass::SWCurveConfig for Parameters { // It is enough to multiply by (x - 1), instead of (x - 1)^2 / 3 // sqrt(76329603384216526031706109802092473003*3) = 15132376222941642753 let h_eff: &[u64] = &[0xd201000000010001]; - Parameters::mul_affine(p, h_eff).into() + Config::mul_affine(p, h_eff).into() } } -// Parameters from the [IETF draft v16, section E.2](https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html#name-11-isogeny-map-for-bls12-381). -impl WBParams for Parameters { - type IsogenousCurve = g1_swu_iso::SwuIsoParameters; +// Config from the [IETF draft v16, section E.2](https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html#name-11-isogeny-map-for-bls12-381). +impl WBParams for Config { + type IsogenousCurve = g1_swu_iso::SwuIsoConfig; const ISOGENY_MAP: IsogenyMap<'static, Self::IsogenousCurve, Self> = g1_swu_iso::ISOGENY_MAP_TO_G1; diff --git a/test-curves/src/bls12_381/g1_swu_iso.rs b/test-curves/src/bls12_381/g1_swu_iso.rs index 9757a89df..12da8e81c 100644 --- a/test-curves/src/bls12_381/g1_swu_iso.rs +++ b/test-curves/src/bls12_381/g1_swu_iso.rs @@ -8,12 +8,12 @@ use ark_ec::{ }; use ark_ff::MontFp; -type G1Affine = Affine; +type G1Affine = Affine; #[derive(Clone, Default, PartialEq, Eq)] -pub struct SwuIsoParameters; +pub struct SwuIsoConfig; -impl CurveConfig for SwuIsoParameters { +impl CurveConfig for SwuIsoConfig { type BaseField = Fq; type ScalarField = Fr; @@ -36,7 +36,7 @@ impl CurveConfig for SwuIsoParameters { // - A' = 12190336318893619529228877361869031420615612348429846051986726275283378313155663745811710833465465981901188123677 // - B' = 2906670324641927570491258158026293881577086121416628140204402091718288198173574630967936031029026176254968826637280 // * Z: 11 -impl SWCurveConfig for SwuIsoParameters { +impl SWCurveConfig for SwuIsoConfig { const COEFF_A: Fq = MontFp!("12190336318893619529228877361869031420615612348429846051986726275283378313155663745811710833465465981901188123677"); #[rustfmt::skip] @@ -53,12 +53,12 @@ impl SWCurveConfig for SwuIsoParameters { const G1_GENERATOR_X: Fq = MontFp!("1677416608493238977774703213729589714082762656433187746258164626835771660734158898989765932111853529350617333597651"); const G1_GENERATOR_Y: Fq = MontFp!("1405098061573104639413728190240719229571583960971553962991897960445246185035342568402755187331334546673157015627211"); -impl SWUParams for SwuIsoParameters { +impl SWUParams for SwuIsoConfig { // ZETA = 0xb as per the IETF draft. const ZETA: Fq = MontFp!("11"); } -pub const ISOGENY_MAP_TO_G1 : IsogenyMap<'_, SwuIsoParameters, g1::Parameters, > = IsogenyMap { +pub const ISOGENY_MAP_TO_G1 : IsogenyMap<'_, SwuIsoConfig, g1::Config, > = IsogenyMap { x_map_numerator : &[ MontFp!("2712959285290305970661081772124144179193819192423276218370281158706191519995889425075952244140278856085036081760695"), MontFp!("3564859427549639835253027846704205725951033235539816243131874237388832081954622352624080767121604606753339903542203"), @@ -133,7 +133,7 @@ mod test { #[test] fn test_gen() { - let gen: G1Affine = SwuIsoParameters::GENERATOR; + let gen: G1Affine = SwuIsoConfig::GENERATOR; assert!(gen.is_on_curve()); assert!(gen.is_in_correct_subgroup_assuming_on_curve()); } diff --git a/test-curves/src/bls12_381/g2.rs b/test-curves/src/bls12_381/g2.rs index ab61c0a16..2f28ea19e 100644 --- a/test-curves/src/bls12_381/g2.rs +++ b/test-curves/src/bls12_381/g2.rs @@ -2,7 +2,7 @@ use core::ops::Neg; use crate::bls12_381::*; use ark_ec::{ - bls12::{self, Bls12Parameters}, + bls12::{self, Bls12Config}, hashing::curve_maps::wb::{IsogenyMap, WBParams}, models::CurveConfig, short_weierstrass::{self, *}, @@ -10,13 +10,13 @@ use ark_ec::{ }; use ark_ff::{BigInt, Field, MontFp, Zero}; -pub type G2Affine = bls12::G2Affine; -pub type G2Projective = bls12::G2Projective; +pub type G2Affine = bls12::G2Affine; +pub type G2Projective = bls12::G2Projective; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq2; type ScalarField = Fr; @@ -43,12 +43,12 @@ impl CurveConfig for Parameters { ); } -impl short_weierstrass::SWCurveConfig for Parameters { +impl short_weierstrass::SWCurveConfig for Config { /// COEFF_A = [0, 0] - const COEFF_A: Fq2 = Fq2::new(g1::Parameters::COEFF_A, g1::Parameters::COEFF_A); + const COEFF_A: Fq2 = Fq2::new(g1::Config::COEFF_A, g1::Config::COEFF_A); /// COEFF_B = [4, 4] - const COEFF_B: Fq2 = Fq2::new(g1::Parameters::COEFF_B, g1::Parameters::COEFF_B); + const COEFF_B: Fq2 = Fq2::new(g1::Config::COEFF_B, g1::Config::COEFF_B); /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y) const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); @@ -64,8 +64,8 @@ impl short_weierstrass::SWCurveConfig for Parameters { // Checks that [p]P = [X]P let mut x_times_point = - point.mul_bigint(BigInt::new([crate::bls12_381::Parameters::X[0], 0, 0, 0])); - if crate::bls12_381::Parameters::X_IS_NEGATIVE { + point.mul_bigint(BigInt::new([crate::bls12_381::Config::X[0], 0, 0, 0])); + if crate::bls12_381::Config::X_IS_NEGATIVE { x_times_point = -x_times_point; } @@ -83,11 +83,11 @@ impl short_weierstrass::SWCurveConfig for Parameters { // When multiplying, use -c1 instead, and then negate the result. That's much // more efficient, since the scalar -c1 has less limbs and a much lower Hamming // weight. - let x: &'static [u64] = crate::bls12_381::Parameters::X; + let x: &'static [u64] = crate::bls12_381::Config::X; let p_projective = p.into_group(); // [x]P - let x_p = Parameters::mul_affine(p, x).neg(); + let x_p = Config::mul_affine(p, x).neg(); // ψ(P) let psi_p = p_power_endomorphism(p); // (ψ^2)(2P) @@ -151,7 +151,7 @@ pub const DOUBLE_P_POWER_ENDOMORPHISM: Fq2 = Fq2::new( FQ_ZERO ); -pub fn p_power_endomorphism(p: &Affine) -> Affine { +pub fn p_power_endomorphism(p: &Affine) -> Affine { // The p-power endomorphism for G2 is defined as follows: // 1. Note that G2 is defined on curve E': y^2 = x^3 + 4(u+1). To map a point // (x, y) in E' to (s, t) in E, one set s = x / ((u+1) ^ (1/3)), t = y / @@ -177,7 +177,7 @@ pub fn p_power_endomorphism(p: &Affine) -> Affine { } /// For a p-power endomorphism psi(P), compute psi(psi(P)) -pub fn double_p_power_endomorphism(p: &Projective) -> Projective { +pub fn double_p_power_endomorphism(p: &Projective) -> Projective { let mut res = *p; res.x *= DOUBLE_P_POWER_ENDOMORPHISM; @@ -186,9 +186,9 @@ pub fn double_p_power_endomorphism(p: &Projective) -> Projective = g2_swu_iso::ISOGENY_MAP_TO_G2; diff --git a/test-curves/src/bls12_381/g2_swu_iso.rs b/test-curves/src/bls12_381/g2_swu_iso.rs index e850858a5..31eb620e3 100644 --- a/test-curves/src/bls12_381/g2_swu_iso.rs +++ b/test-curves/src/bls12_381/g2_swu_iso.rs @@ -7,12 +7,12 @@ use ark_ff::MontFp; use ark_ec::hashing::curve_maps::{swu::SWUParams, wb::IsogenyMap}; -type G2Affine = Affine; +type G2Affine = Affine; #[derive(Clone, Default, PartialEq, Eq)] -pub struct SwuIsoParameters; +pub struct SwuIsoConfig; -impl CurveConfig for SwuIsoParameters { +impl CurveConfig for SwuIsoConfig { type BaseField = Fq2; type ScalarField = Fr; @@ -48,7 +48,7 @@ impl CurveConfig for SwuIsoParameters { // - B' = 1012 * (1 + I) // // * Z: -(2 + I) -impl SWCurveConfig for SwuIsoParameters { +impl SWCurveConfig for SwuIsoConfig { /// COEFF_A = 240 * I const COEFF_A: Fq2 = Fq2::new(MontFp!("0"), MontFp!("240")); @@ -71,12 +71,12 @@ const G2_GENERATOR_X_C1: Fq = MontFp!("10370797385975734067653557740066018506336 const G2_GENERATOR_Y_C0: Fq = MontFp!("3927929472994661655038722055497331445175131868678630546921475383290711810401295661250673209427965906654429357114487"); const G2_GENERATOR_Y_C1: Fq = MontFp!("3300326318345570015758639333209189167876318321385223785506096497597561910823001330832964776707374262378602791224889"); -impl SWUParams for SwuIsoParameters { +impl SWUParams for SwuIsoConfig { // ZETA = -(2 + u) as per IETF draft. const ZETA: Fq2 = Fq2::new(MontFp!("-2"), MontFp!("-1")); } -pub const ISOGENY_MAP_TO_G2 : IsogenyMap<'_, SwuIsoParameters, g2::Parameters> = IsogenyMap { +pub const ISOGENY_MAP_TO_G2 : IsogenyMap<'_, SwuIsoConfig, g2::Config> = IsogenyMap { x_map_numerator: &[ Fq2::new( MontFp!("889424345604814976315064405719089812568196182208668418962679585805340366775741747653930584250892369786198727235542"), @@ -141,7 +141,7 @@ mod test { #[test] fn test_gen() { - let gen: G2Affine = g2_swu_iso::SwuIsoParameters::GENERATOR; + let gen: G2Affine = g2_swu_iso::SwuIsoConfig::GENERATOR; assert!(gen.is_on_curve()); assert!(gen.is_in_correct_subgroup_assuming_on_curve()); } diff --git a/test-curves/src/bls12_381/mod.rs b/test-curves/src/bls12_381/mod.rs index b4b000ed3..c297ac580 100644 --- a/test-curves/src/bls12_381/mod.rs +++ b/test-curves/src/bls12_381/mod.rs @@ -28,13 +28,13 @@ pub use pairing::*; #[cfg(feature = "bls12_381_curve")] mod pairing { use super::*; - use ark_ec::bls12::{Bls12, Bls12Parameters, TwistType}; + use ark_ec::bls12::{Bls12, Bls12Config, TwistType}; - pub type Bls12_381 = Bls12; + pub type Bls12_381 = Bls12; - pub struct Parameters; + pub struct Config; - impl Bls12Parameters for Parameters { + impl Bls12Config for Config { const X: &'static [u64] = &[0xd201000000010000]; const X_IS_NEGATIVE: bool = true; const TWIST_TYPE: TwistType = TwistType::M; @@ -42,10 +42,10 @@ mod pairing { type Fp2Config = Fq2Config; type Fp6Config = Fq6Config; type Fp12Config = Fq12Config; - type G1Parameters = self::g1::Parameters; - type G2Parameters = self::g2::Parameters; + type G1Config = self::g1::Config; + type G2Config = self::g2::Config; } - pub type G1Prepared = ark_ec::bls12::G1Prepared; - pub type G2Prepared = ark_ec::bls12::G2Prepared; + pub type G1Prepared = ark_ec::bls12::G1Prepared; + pub type G2Prepared = ark_ec::bls12::G2Prepared; } diff --git a/test-curves/src/bn384_small_two_adicity/g1.rs b/test-curves/src/bn384_small_two_adicity/g1.rs index a8ee2f34a..82704be8e 100644 --- a/test-curves/src/bn384_small_two_adicity/g1.rs +++ b/test-curves/src/bn384_small_two_adicity/g1.rs @@ -6,13 +6,13 @@ use ark_ff::Zero; use crate::bn384_small_two_adicity::{Fq, Fr, FR_ONE}; -pub type G1Affine = Affine; -pub type G1Projective = Projective; +pub type G1Affine = Affine; +pub type G1Projective = Projective; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq; type ScalarField = Fr; @@ -23,7 +23,7 @@ impl CurveConfig for Parameters { const COFACTOR_INV: Fr = FR_ONE; } -impl short_weierstrass::SWCurveConfig for Parameters { +impl short_weierstrass::SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = ark_ff::MontFp!("0"); diff --git a/test-curves/src/mnt4_753/g1.rs b/test-curves/src/mnt4_753/g1.rs index 278e4410f..2a329a56c 100644 --- a/test-curves/src/mnt4_753/g1.rs +++ b/test-curves/src/mnt4_753/g1.rs @@ -6,13 +6,13 @@ use ark_ff::MontFp; use crate::mnt4_753::{Fq, Fr, FR_ONE}; -pub type G1Affine = Affine; -pub type G1Projective = Projective; +pub type G1Affine = Affine; +pub type G1Projective = Projective; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq; type ScalarField = Fr; @@ -24,7 +24,7 @@ impl CurveConfig for Parameters { const COFACTOR_INV: Fr = FR_ONE; } -impl short_weierstrass::SWCurveConfig for Parameters { +impl short_weierstrass::SWCurveConfig for Config { /// COEFF_A = 2 #[rustfmt::skip] const COEFF_A: Fq = MontFp!("2"); diff --git a/test-curves/src/secp256k1/g1.rs b/test-curves/src/secp256k1/g1.rs index 1b7b586ad..9e7e4de24 100644 --- a/test-curves/src/secp256k1/g1.rs +++ b/test-curves/src/secp256k1/g1.rs @@ -2,13 +2,13 @@ use crate::secp256k1::{Fq, Fr}; use ark_ec::{models::CurveConfig, short_weierstrass::*}; use ark_ff::{Field, MontFp, Zero}; -pub type G1Affine = Affine; -pub type G1Projective = Projective; +pub type G1Affine = Affine; +pub type G1Projective = Projective; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq; type ScalarField = Fr; @@ -20,7 +20,7 @@ impl CurveConfig for Parameters { const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO; From 23bdc70a6c3d2645c3e0d07158e76cf90a9f845f Mon Sep 17 00:00:00 2001 From: Pratyush Mishra Date: Thu, 15 Dec 2022 23:58:30 -0800 Subject: [PATCH 2/6] `Params` -> `Config` --- ec/src/hashing/curve_maps/swu/mod.rs | 22 +++++++------- ec/src/hashing/curve_maps/wb/mod.rs | 40 ++++++++++++------------- ff/src/fields/models/cubic_extension.rs | 4 +-- test-curves/src/bls12_381/g1.rs | 4 +-- test-curves/src/bls12_381/g1_swu_iso.rs | 4 +-- test-curves/src/bls12_381/g2.rs | 4 +-- test-curves/src/bls12_381/g2_swu_iso.rs | 4 +-- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/ec/src/hashing/curve_maps/swu/mod.rs b/ec/src/hashing/curve_maps/swu/mod.rs index c3a100b15..3b0960777 100644 --- a/ec/src/hashing/curve_maps/swu/mod.rs +++ b/ec/src/hashing/curve_maps/swu/mod.rs @@ -13,7 +13,7 @@ use crate::{ /// y^2 = x^3 + a*x + b where ab != 0. From [\[WB2019\]] /// /// - [\[WB2019\]] -pub trait SWUParams: SWCurveConfig { +pub trait SWUConfig: SWCurveConfig { /// An element of the base field that is not a square root see \[WB2019, Section 4\]. /// It is also convenient to have $g(b/ZETA * a)$ to be square. In general /// we use a `ZETA` with low absolute value coefficients when they are @@ -22,7 +22,7 @@ pub trait SWUParams: SWCurveConfig { } /// Represents the SWU hash-to-curve map defined by `P`. -pub struct SWUMap { +pub struct SWUMap { curve_params: PhantomData P>, } @@ -36,7 +36,7 @@ pub fn parity(element: &F) -> bool { .map_or(false, |x| x.into_bigint().is_odd()) } -impl MapToCurve> for SWUMap

{ +impl MapToCurve> for SWUMap

{ /// Constructs a new map if `P` represents a valid map. fn new() -> Result { // Verifying that ZETA is a non-square @@ -175,9 +175,9 @@ mod test { const F127_ONE: F127 = MontFp!("1"); - struct TestSWUMapToCurveParams; + struct TestSWUMapToCurveConfig; - impl CurveConfig for TestSWUMapToCurveParams { + impl CurveConfig for TestSWUMapToCurveConfig { const COFACTOR: &'static [u64] = &[1]; #[rustfmt::skip] @@ -200,7 +200,7 @@ mod test { /// pass /// /// y^2 = x^3 + x + 63 - impl SWCurveConfig for TestSWUMapToCurveParams { + impl SWCurveConfig for TestSWUMapToCurveConfig { /// COEFF_A = 1 const COEFF_A: F127 = F127_ONE; @@ -212,7 +212,7 @@ mod test { const GENERATOR: Affine = Affine::new_unchecked(MontFp!("62"), MontFp!("70")); } - impl SWUParams for TestSWUMapToCurveParams { + impl SWUConfig for TestSWUMapToCurveConfig { const ZETA: F127 = MontFp!("-1"); } @@ -241,9 +241,9 @@ mod test { #[test] fn hash_arbitary_string_to_curve_swu() { let test_swu_to_curve_hasher = MapToCurveBasedHasher::< - Projective, + Projective, DefaultFieldHasher, - SWUMap, + SWUMap, >::new(&[1]) .unwrap(); @@ -260,9 +260,9 @@ mod test { /// elements should be mapped to curve successfully. everything can be mapped #[test] fn map_field_to_curve_swu() { - let test_map_to_curve = SWUMap::::new().unwrap(); + let test_map_to_curve = SWUMap::::new().unwrap(); - let mut map_range: Vec> = vec![]; + let mut map_range: Vec> = vec![]; for current_field_element in 0..127 { map_range.push( test_map_to_curve diff --git a/ec/src/hashing/curve_maps/wb/mod.rs b/ec/src/hashing/curve_maps/wb/mod.rs index d2836e356..5960cc12e 100644 --- a/ec/src/hashing/curve_maps/wb/mod.rs +++ b/ec/src/hashing/curve_maps/wb/mod.rs @@ -10,7 +10,7 @@ use crate::{ AffineRepr, }; -use super::swu::{SWUMap, SWUParams}; +use super::swu::{SWUConfig, SWUMap}; type BaseField = ::BaseField; /// [`IsogenyMap`] defines an isogeny between curves of @@ -70,20 +70,20 @@ where /// From [\[WB2019\]] /// /// - [\[WB2019\]] -pub trait WBParams: SWCurveConfig + Sized { +pub trait WBConfig: SWCurveConfig + Sized { // The isogenous curve should be defined over the same base field but it can have // different scalar field type IsogenousCurveScalarField : - type IsogenousCurve: SWUParams>; + type IsogenousCurve: SWUConfig>; const ISOGENY_MAP: IsogenyMap<'static, Self::IsogenousCurve, Self>; } -pub struct WBMap { +pub struct WBMap { swu_field_curve_hasher: SWUMap, curve_params: PhantomData P>, } -impl MapToCurve> for WBMap

{ +impl MapToCurve> for WBMap

{ /// Constructs a new map if `P` represents a valid map. fn new() -> Result { match P::ISOGENY_MAP.apply(P::IsogenousCurve::GENERATOR) { @@ -119,8 +119,8 @@ mod test { use crate::{ hashing::{ curve_maps::{ - swu::SWUParams, - wb::{IsogenyMap, WBMap, WBParams}, + swu::SWUConfig, + wb::{IsogenyMap, WBConfig, WBMap}, }, map_to_curve_hasher::MapToCurveBasedHasher, HashToCurve, @@ -141,9 +141,9 @@ mod test { const F127_ONE: F127 = MontFp!("1"); /// The struct defining our parameters for the target curve of hashing - struct TestWBF127MapToCurveParams; + struct TestWBF127MapToCurveConfig; - impl CurveConfig for TestWBF127MapToCurveParams { + impl CurveConfig for TestWBF127MapToCurveConfig { const COFACTOR: &'static [u64] = &[1]; #[rustfmt::skip] @@ -155,7 +155,7 @@ mod test { /// E: Elliptic Curve defined by y^2 = x^3 + 3 over Finite /// Field of size 127 - impl SWCurveConfig for TestWBF127MapToCurveParams { + impl SWCurveConfig for TestWBF127MapToCurveConfig { /// COEFF_A = 0 const COEFF_A: F127 = F127_ZERO; @@ -171,12 +171,12 @@ mod test { /// E_isogenous : Elliptic Curve defined by y^2 = x^3 + 109*x + 124 over Finite /// Field of size 127 /// Isogenous to E : y^2 = x^3 + 3 - struct TestSWU127MapToIsogenousCurveParams; + struct TestSWU127MapToIsogenousCurveConfig; /// First we define the isogenous curve /// sage: E_isogenous.order() /// 127 - impl CurveConfig for TestSWU127MapToIsogenousCurveParams { + impl CurveConfig for TestSWU127MapToIsogenousCurveConfig { const COFACTOR: &'static [u64] = &[1]; #[rustfmt::skip] @@ -188,7 +188,7 @@ mod test { /// E_isogenous : Elliptic Curve defined by y^2 = x^3 + 109*x + 124 over Finite /// Field of size 127 - impl SWCurveConfig for TestSWU127MapToIsogenousCurveParams { + impl SWCurveConfig for TestSWU127MapToIsogenousCurveConfig { /// COEFF_A = 109 const COEFF_A: F127 = MontFp!("109"); @@ -201,7 +201,7 @@ mod test { } /// SWU parameters for E_isogenous - impl SWUParams for TestSWU127MapToIsogenousCurveParams { + impl SWUConfig for TestSWU127MapToIsogenousCurveConfig { /// NON-SQUARE = - 1 const ZETA: F127 = MontFp!("-1"); } @@ -223,8 +223,8 @@ mod test { /// - 46*x^8 - 61*x^7 - 16*x^6 - 55*x^5 + 18*x^4 + 23*x^3 - 24*x^2 - 18*x + 32) const ISOGENY_MAP_TESTWBF127: IsogenyMap< '_, - TestSWU127MapToIsogenousCurveParams, - TestWBF127MapToCurveParams, + TestSWU127MapToIsogenousCurveConfig, + TestWBF127MapToCurveConfig, > = IsogenyMap { x_map_numerator: &[ MontFp!("4"), @@ -303,8 +303,8 @@ mod test { MontFp!("1"), ], }; - impl WBParams for TestWBF127MapToCurveParams { - type IsogenousCurve = TestSWU127MapToIsogenousCurveParams; + impl WBConfig for TestWBF127MapToCurveConfig { + type IsogenousCurve = TestSWU127MapToIsogenousCurveConfig; const ISOGENY_MAP: super::IsogenyMap<'static, Self::IsogenousCurve, Self> = ISOGENY_MAP_TESTWBF127; @@ -316,9 +316,9 @@ mod test { fn hash_arbitrary_string_to_curve_wb() { use sha2::Sha256; let test_wb_to_curve_hasher = MapToCurveBasedHasher::< - Projective, + Projective, DefaultFieldHasher, - WBMap, + WBMap, >::new(&[1]) .unwrap(); diff --git a/ff/src/fields/models/cubic_extension.rs b/ff/src/fields/models/cubic_extension.rs index 3f9a3f669..88c8db3c5 100644 --- a/ff/src/fields/models/cubic_extension.rs +++ b/ff/src/fields/models/cubic_extension.rs @@ -111,9 +111,9 @@ impl CubicExtField

{ /// let c0: Fp2 = Fp2::rand(&mut test_rng()); /// let c1: Fp2 = Fp2::rand(&mut test_rng()); /// let c2: Fp2 = Fp2::rand(&mut test_rng()); - /// # type Params = Fp6ConfigWrapper; + /// # type Config = Fp6ConfigWrapper; /// // `Fp6` a degree-3 extension over `Fp2`. - /// let c: CubicExtField = Fp6::new(c0, c1, c2); + /// let c: CubicExtField = Fp6::new(c0, c1, c2); /// ``` pub const fn new(c0: P::BaseField, c1: P::BaseField, c2: P::BaseField) -> Self { Self { c0, c1, c2 } diff --git a/test-curves/src/bls12_381/g1.rs b/test-curves/src/bls12_381/g1.rs index 0c76986cc..f653e6f7a 100644 --- a/test-curves/src/bls12_381/g1.rs +++ b/test-curves/src/bls12_381/g1.rs @@ -1,6 +1,6 @@ use crate::bls12_381::*; use ark_ec::{ - hashing::curve_maps::wb::{IsogenyMap, WBParams}, + hashing::curve_maps::wb::{IsogenyMap, WBConfig}, models::CurveConfig, short_weierstrass::{self, *}, }; @@ -54,7 +54,7 @@ impl short_weierstrass::SWCurveConfig for Config { } // Config from the [IETF draft v16, section E.2](https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html#name-11-isogeny-map-for-bls12-381). -impl WBParams for Config { +impl WBConfig for Config { type IsogenousCurve = g1_swu_iso::SwuIsoConfig; const ISOGENY_MAP: IsogenyMap<'static, Self::IsogenousCurve, Self> = diff --git a/test-curves/src/bls12_381/g1_swu_iso.rs b/test-curves/src/bls12_381/g1_swu_iso.rs index 12da8e81c..8532422eb 100644 --- a/test-curves/src/bls12_381/g1_swu_iso.rs +++ b/test-curves/src/bls12_381/g1_swu_iso.rs @@ -1,6 +1,6 @@ use crate::bls12_381::*; use ark_ec::{ - hashing::curve_maps::{swu::SWUParams, wb::IsogenyMap}, + hashing::curve_maps::{swu::SWUConfig, wb::IsogenyMap}, models::{ short_weierstrass::{Affine, SWCurveConfig}, CurveConfig, @@ -53,7 +53,7 @@ impl SWCurveConfig for SwuIsoConfig { const G1_GENERATOR_X: Fq = MontFp!("1677416608493238977774703213729589714082762656433187746258164626835771660734158898989765932111853529350617333597651"); const G1_GENERATOR_Y: Fq = MontFp!("1405098061573104639413728190240719229571583960971553962991897960445246185035342568402755187331334546673157015627211"); -impl SWUParams for SwuIsoConfig { +impl SWUConfig for SwuIsoConfig { // ZETA = 0xb as per the IETF draft. const ZETA: Fq = MontFp!("11"); } diff --git a/test-curves/src/bls12_381/g2.rs b/test-curves/src/bls12_381/g2.rs index 2f28ea19e..21427afc3 100644 --- a/test-curves/src/bls12_381/g2.rs +++ b/test-curves/src/bls12_381/g2.rs @@ -3,7 +3,7 @@ use core::ops::Neg; use crate::bls12_381::*; use ark_ec::{ bls12::{self, Bls12Config}, - hashing::curve_maps::wb::{IsogenyMap, WBParams}, + hashing::curve_maps::wb::{IsogenyMap, WBConfig}, models::CurveConfig, short_weierstrass::{self, *}, AffineRepr, CurveGroup, Group, @@ -187,7 +187,7 @@ pub fn double_p_power_endomorphism(p: &Projective) -> Projective } // Config from the [IETF draft v16, section E.3](https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html#name-3-isogeny-map-for-bls12-381). -impl WBParams for Config { +impl WBConfig for Config { type IsogenousCurve = g2_swu_iso::SwuIsoConfig; const ISOGENY_MAP: IsogenyMap<'static, Self::IsogenousCurve, Self> = diff --git a/test-curves/src/bls12_381/g2_swu_iso.rs b/test-curves/src/bls12_381/g2_swu_iso.rs index 31eb620e3..0790cf99f 100644 --- a/test-curves/src/bls12_381/g2_swu_iso.rs +++ b/test-curves/src/bls12_381/g2_swu_iso.rs @@ -5,7 +5,7 @@ use ark_ec::models::{ }; use ark_ff::MontFp; -use ark_ec::hashing::curve_maps::{swu::SWUParams, wb::IsogenyMap}; +use ark_ec::hashing::curve_maps::{swu::SWUConfig, wb::IsogenyMap}; type G2Affine = Affine; @@ -71,7 +71,7 @@ const G2_GENERATOR_X_C1: Fq = MontFp!("10370797385975734067653557740066018506336 const G2_GENERATOR_Y_C0: Fq = MontFp!("3927929472994661655038722055497331445175131868678630546921475383290711810401295661250673209427965906654429357114487"); const G2_GENERATOR_Y_C1: Fq = MontFp!("3300326318345570015758639333209189167876318321385223785506096497597561910823001330832964776707374262378602791224889"); -impl SWUParams for SwuIsoConfig { +impl SWUConfig for SwuIsoConfig { // ZETA = -(2 + u) as per IETF draft. const ZETA: Fq2 = Fq2::new(MontFp!("-2"), MontFp!("-1")); } From b628d76759f267dd41f484a2376239598f90defe Mon Sep 17 00:00:00 2001 From: Weikeng Chen Date: Fri, 16 Dec 2022 08:51:31 -0800 Subject: [PATCH 3/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6032800d9..ff96a346c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -141,6 +141,7 @@ - Adds `impl<'a, 'b> Add/Sub/Mul/Div<&'a F> for &'b F` - [\#517](https://github.com/arkworks-rs/algebra/pull/517) (`ark-ec`) Move the definition of the isogeny map of WB hash-to-curve to a separate struct - [\#519](https://github.com/arkworks-rs/algebra/pull/519) (`ark-ec`) Refactor variable-base MSM to be checked by default, returning a `Result` if the lengths of the bases and scalars do not match. +- [\#545](https://github.com/arkworks-rs/algebra/pull/545) (`ark-ec`, `ark-ff`) Rename all `*Parameters` or `*Params` to `*Config`, including `SWUParams`, `WBParams`, `Bls12Parameters`, `G1Parameters`, `G2Parameters`, `BnParameters`, `BW6Parameters`, `MNT4Parameters`, `MNT6Parameters`, and `GLVParameters`. ### Features From f206227371815765e83d972d9b38819a71da17be Mon Sep 17 00:00:00 2001 From: Weikeng Chen Date: Fri, 16 Dec 2022 08:56:34 -0800 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff96a346c..56d9ab648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -141,7 +141,17 @@ - Adds `impl<'a, 'b> Add/Sub/Mul/Div<&'a F> for &'b F` - [\#517](https://github.com/arkworks-rs/algebra/pull/517) (`ark-ec`) Move the definition of the isogeny map of WB hash-to-curve to a separate struct - [\#519](https://github.com/arkworks-rs/algebra/pull/519) (`ark-ec`) Refactor variable-base MSM to be checked by default, returning a `Result` if the lengths of the bases and scalars do not match. -- [\#545](https://github.com/arkworks-rs/algebra/pull/545) (`ark-ec`, `ark-ff`) Rename all `*Parameters` or `*Params` to `*Config`, including `SWUParams`, `WBParams`, `Bls12Parameters`, `G1Parameters`, `G2Parameters`, `BnParameters`, `BW6Parameters`, `MNT4Parameters`, `MNT6Parameters`, and `GLVParameters`. +- [\#545](https://github.com/arkworks-rs/algebra/pull/545) (`ark-ec`, `ark-ff`) Rename all `*Parameters` or `*Params` to `*Config`, including: + - `SWUParams` → `SWUConfig` + - `WBParams` → `WBConfig` + - `Bls12Parameters` → `Bls12Config` + - `G1Parameters` → `G1Config` + - `G2Parameters` → `G2Config` + - `BnParameters` → `BnConfig` + - `BW6Parameters` → `BW6Config` + - `MNT4Parameters` → `MNT4Config` + - `MNT6Parameters` → `MNT6Config` + - `GLVParameters` → `GLVConfig` ### Features From c372c64a48db4a73e65e6dcad6be39e74ecf7872 Mon Sep 17 00:00:00 2001 From: Pratyush Mishra Date: Fri, 16 Dec 2022 08:57:11 -0800 Subject: [PATCH 5/6] Update CHANGELOG --- CHANGELOG.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6032800d9..1210b9489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,6 @@ ## Pending -- [\#528](https://github.com/arkworks-rs/algebra/pull/528) (`ark-ec`) Allow to overwrite the default implementation of the `msm` function provided by the `VariableBaseMSM` trait by a specialized version in `SWCurveConfig`. -- [\#521](https://github.com/arkworks-rs/algebra/pull/521) (`ark-poly`) Change `DensePolynomial::evaluate_over_domain` to not truncate terms higher than the size of the domain. - ### Breaking changes - [\#300](https://github.com/arkworks-rs/algebra/pull/300) (`ark-ec`) Change the implementation of `Hash` trait of `GroupProjective` to use the affine coordinates. @@ -34,7 +31,7 @@ - [\#386](https://github.com/arkworks-rs/algebra/pull/386) (`ark-ff`) Remove `PrimeField::GENERATOR`, since it already exists on `FftField`. - [\#393](https://github.com/arkworks-rs/algebra/pull/393) (`ark-ec`, `ark-ff`) Rename `FpXParams` to `FpXConfig` and `FpXParamsWrapper` to `FpXConfigWrapper`. - [\#396](https://github.com/arkworks-rs/algebra/pull/396) (`ark-ec`) Remove `mul_bits` feature, and remove default implementations of `mul` and `mul_by_cofactor_to_projective`. -- [\#408](https://github.com/arkworks-rs/algebra/pull/408) (`ark-ff`) Change the output of `Display` formatting for BigInt & Fp from hex to decimal. +- [\#408](https://github.com/arkworks-rs/algebra/pull/408) (`ark-ff`) Change the output of `Display` formatting for `BigInt` and `Fp` from hex to decimal. - [\#412](https://github.com/arkworks-rs/algebra/pull/412) (`ark-poly`) Rename UV/MVPolynomial to DenseUV/MVPolynomial. - [\#417](https://github.com/arkworks-rs/algebra/pull/417) (`ark-ff`) Remove `ToBytes` and `FromBytes`. - [\#418](https://github.com/arkworks-rs/algebra/pull/418) (`ark-ff`) Add `sums_of_products` to `Field` and `Fp` @@ -93,7 +90,7 @@ - `miller_loop` → `multi_miller_loop` - `pairing` → `multi_pairing` - Change method signatures: - - `product_of_pairings` -> `multi_pairing` + - `product_of_pairings` → `multi_pairing` - take two references to element iterators instead of an iterator of tuples. - `miller_loop` and `multi_miller_loop` now - take two iterators over `impl Into` and `impl Into` as input, and @@ -142,6 +139,8 @@ - [\#517](https://github.com/arkworks-rs/algebra/pull/517) (`ark-ec`) Move the definition of the isogeny map of WB hash-to-curve to a separate struct - [\#519](https://github.com/arkworks-rs/algebra/pull/519) (`ark-ec`) Refactor variable-base MSM to be checked by default, returning a `Result` if the lengths of the bases and scalars do not match. +- [\#545](https://github.com/arkworks-rs/algebra/pull/545) (`ark-ec`) Rename all `*Parameters` to `*Config` for consistency. + ### Features - [\#301](https://github.com/arkworks-rs/algebra/pull/301) (`ark-ec`) Add `GLVParameters` trait definition. @@ -166,6 +165,7 @@ - Add convenience method `get_coset`. - Add methods `coset_offset`, `coset_offset_inv` and `coset_offset_pow_size`. - [\#539](https://github.com/arkworks-rs/algebra/pull/539) (`ark-ec`) Implement wNAF-based MSM, resulting in 5-10% speedups. +- [\#528](https://github.com/arkworks-rs/algebra/pull/528) (`ark-ec`) Allow to overwrite the default implementation of the `msm` function provided by the `VariableBaseMSM` trait by a specialized version in `SWCurveConfig`. ### Improvements @@ -185,6 +185,7 @@ - [\#394](https://github.com/arkworks-rs/algebra/pull/394) (`ark-ff`, `ark-serialize`) Remove `EmptyFlags` construction checks. - [\#442](https://github.com/arkworks-rs/algebra/pull/442) (`ark-ff`) Fix deserialization for modulo with 64 shaving bits. - [\#460](https://github.com/arkworks-rs/algebra/pull/460) (`ark-ec`) Fix a corner case for ate pairing in BLS12 and BW6 models. +- [\#521](https://github.com/arkworks-rs/algebra/pull/521) (`ark-poly`) Change `DensePolynomial::evaluate_over_domain` to not truncate terms higher than the size of the domain. - [\#526](https://github.com/arkworks-rs/algebra/pull/526) (`ark-ff`) Fix squaring for `Fp128`. ## v0.3.0 From 8068b548c049aa3705ef70dacd267e9303020dc2 Mon Sep 17 00:00:00 2001 From: Pratyush Mishra Date: Fri, 16 Dec 2022 08:58:07 -0800 Subject: [PATCH 6/6] Fix CHANGELOG.md --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a6287db1..8c330e894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -150,8 +150,6 @@ - `MNT6Parameters` → `MNT6Config` - `GLVParameters` → `GLVConfig` -- [\#545](https://github.com/arkworks-rs/algebra/pull/545) (`ark-ec`) Rename all `*Parameters` to `*Config` for consistency. - ### Features - [\#301](https://github.com/arkworks-rs/algebra/pull/301) (`ark-ec`) Add `GLVParameters` trait definition.