Rename all `*Parameters` to `*Config` (#136) * Rename all `*Parameters` to `*Config` * Tweak
jump to
@@ -65,5 +65,6 @@ debug = true
[patch.crates-io] ark-ff = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } +ark-ec = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } ark-poly = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" }
@@ -1,45 +1,39 @@
-use ark_ec::{bls12::Bls12Parameters, CurveConfig}; +use ark_ec::{bls12::Bls12Config, CurveConfig}; use ark_r1cs_std::{ fields::fp::FpVar, groups::{bls12, curves::twisted_edwards::AffineVar as TEAffineVar}, }; -use crate::Parameters; +use crate::Config; /// An element of G1 in the BLS12-377 bilinear group. -pub type G1Var = bls12::G1Var<Parameters>; +pub type G1Var = bls12::G1Var<Config>; /// An element of G2 in the BLS12-377 bilinear group. -pub type G2Var = bls12::G2Var<Parameters>; +pub type G2Var = bls12::G2Var<Config>; /// An element of G1 (in TE Affine form) in the BLS12-377 bilinear group. pub type G1TEAffineVar = TEAffineVar< - <Parameters as Bls12Parameters>::G1Parameters, - FpVar<<<Parameters as Bls12Parameters>::G1Parameters as CurveConfig>::BaseField>, + <Config as Bls12Config>::G1Config, + FpVar<<<Config as Bls12Config>::G1Config as CurveConfig>::BaseField>, >; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. -pub type G1PreparedVar = bls12::G1PreparedVar<Parameters>; +pub type G1PreparedVar = bls12::G1PreparedVar<Config>; /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. -pub type G2PreparedVar = bls12::G2PreparedVar<Parameters>; +pub type G2PreparedVar = bls12::G2PreparedVar<Config>; #[test] fn test() { - use ark_ec::models::bls12::Bls12Parameters; - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as Bls12Parameters>::G1Parameters, - G1Var, - >() - .unwrap(); + use ark_ec::models::bls12::Bls12Config; + ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G1Config, G1Var>() + .unwrap(); ark_curve_constraint_tests::curves::te_test::< - <Parameters as Bls12Parameters>::G1Parameters, + <Config as Bls12Config>::G1Config, G1TEAffineVar, >() .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as Bls12Parameters>::G2Parameters, - G2Var, - >() - .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G2Config, G2Var>() + .unwrap(); }
@@ -1,8 +1,8 @@
-use crate::Parameters; +use crate::Config; /// Specifies the constraints for computing a pairing in the BLS12-377 bilinear /// group. -pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Parameters>; +pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Config>; #[test] fn test() {
@@ -11,9 +11,9 @@
use crate::{Fq, Fr}; #[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 @@ /// = 5285428838741532253824584287042945485047145357130994810877
const COFACTOR_INV: Fr = MontFp!("5285428838741532253824584287042945485047145357130994810877"); } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;@@ -41,9 +41,9 @@ Self::BaseField::zero()
} } -pub type G1SWAffine = SWAffine<Parameters>; -pub type G1TEAffine = TEAffine<Parameters>; -pub type G1TEProjective = TEProjective<Parameters>; +pub type G1SWAffine = SWAffine<Config>; +pub type G1TEAffine = TEAffine<Config>; +pub type G1TEProjective = TEProjective<Config>; /// Bls12_377::G1 also has a twisted Edwards form. /// It can be obtained via the following script, implementing@@ -92,7 +92,7 @@ /// TE2a = Fp(-1)
/// # b = -TE1d/TE1a /// TE2d = Fp(122268283598675559488486339158635529096981886914877139579534153582033676785385790730042363341236035746924960903179) /// ``` -impl TECurveConfig for Parameters { +impl TECurveConfig for Config { /// COEFF_A = -1 const COEFF_A: Fq = MontFp!("-1");@@ -102,7 +102,7 @@
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) const GENERATOR: G1TEAffine = G1TEAffine::new_unchecked(TE_GENERATOR_X, TE_GENERATOR_Y); - type MontCurveConfig = Parameters; + type MontCurveConfig = Config; /// Multiplication by `a` is multiply by `-1`. #[inline(always)]@@ -140,14 +140,14 @@ // MA=Fp(228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384)
// # MB = s // MB=Fp(10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931) // ``` -impl MontCurveConfig for Parameters { +impl MontCurveConfig for Config { /// COEFF_A = 228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384 const COEFF_A: Fq = MontFp!("228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384"); /// COEFF_B = 10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931 const COEFF_B: Fq = MontFp!("10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931"); - type TECurveConfig = Parameters; + type TECurveConfig = Config; } /// G1_GENERATOR_X =
@@ -6,11 +6,11 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{g1, Fq, Fq2, Fr}; -pub type G2Affine = Affine<Parameters>; +pub type G2Affine = Affine<Config>; #[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;@@ -34,9 +34,9 @@ const COFACTOR_INV: Fr =
MontFp!("6764900296503390671038341982857278410319949526107311149686707033187604810669"); } -impl SWCurveConfig for Parameters { +impl 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); // As per https://eprint.iacr.org/2012/072.pdf, // this curve has b' = b/i, where b is the COEFF_B of G1, and x^6 -i is
@@ -1,6 +1,6 @@
use ark_ec::{ bls12, - bls12::{Bls12, Bls12Parameters, TwistType}, + bls12::{Bls12, Bls12Config, TwistType}, }; use crate::*;@@ -11,9 +11,9 @@
#[cfg(test)] mod tests; -pub struct Parameters; +pub struct Config; -impl Bls12Parameters for Parameters { +impl Bls12Config for Config { const X: &'static [u64] = &[0x8508c00000000001]; /// `x` is positive. const X_IS_NEGATIVE: bool = false;@@ -22,15 +22,15 @@ type Fp = Fq;
type Fp2Config = Fq2Config; type Fp6Config = Fq6Config; type Fp12Config = Fq12Config; - type G1Parameters = g1::Parameters; - type G2Parameters = g2::Parameters; + type G1Config = g1::Config; + type G2Config = g2::Config; } -pub type Bls12_377 = Bls12<Parameters>; +pub type Bls12_377 = Bls12<Config>; -pub type G1Affine = bls12::G1Affine<Parameters>; -pub type G1Projective = bls12::G1Projective<Parameters>; -pub type G2Affine = bls12::G2Affine<Parameters>; -pub type G2Projective = bls12::G2Projective<Parameters>; +pub type G1Affine = bls12::G1Affine<Config>; +pub type G1Projective = bls12::G1Projective<Config>; +pub type G2Affine = bls12::G2Affine<Config>; +pub type G2Projective = bls12::G2Projective<Config>; pub use g1::{G1TEAffine, G1TEProjective};
@@ -1,7 +1,7 @@
use crate::*; use ark_ec::{ bls12, - bls12::Bls12Parameters, + bls12::Bls12Config, models::CurveConfig, short_weierstrass::{Affine, SWCurveConfig}, AffineRepr, Group,@@ -14,13 +14,13 @@ use crate::util::{
read_g1_compressed, read_g1_uncompressed, serialize_fq, EncodingFlags, G1_SERIALIZED_SIZE, }; -pub type G1Affine = bls12::G1Affine<crate::Parameters>; -pub type G1Projective = bls12::G1Projective<crate::Parameters>; +pub type G1Affine = bls12::G1Affine<crate::Config>; +pub type G1Projective = bls12::G1Projective<crate::Config>; #[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;@@ -33,7 +33,7 @@ const COFACTOR_INV: Fr =
MontFp!("52435875175126190458656871551744051925719901746859129887267498875565241663483"); } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;@@ -57,12 +57,12 @@
// An early-out optimization described in Section 6. // If uP == P but P != point of infinity, then the point is not in the right // subgroup. - let x_times_p = p.mul_bigint(crate::Parameters::X); + let x_times_p = p.mul_bigint(crate::Config::X); if x_times_p.eq(p) && !p.infinity { return false; } - let minus_x_squared_times_p = x_times_p.mul_bigint(crate::Parameters::X).neg(); + let minus_x_squared_times_p = x_times_p.mul_bigint(crate::Config::X).neg(); let endomorphism_p = endomorphism(p); minus_x_squared_times_p.eq(&endomorphism_p) }@@ -74,7 +74,7 @@ // Section 5 of https://eprint.iacr.org/2019/403.pdf.
// // It is enough to multiply by (1 - x), instead of (x - 1)^2 / 3 let h_eff = one_minus_x().into_bigint(); - Parameters::mul_affine(&p, h_eff.as_ref()).into() + Config::mul_affine(&p, h_eff.as_ref()).into() } fn deserialize_with_mode<R: ark_serialize::Read>(@@ -139,7 +139,7 @@ }
} fn one_minus_x() -> Fr { - const X: Fr = Fr::from_sign_and_limbs(!crate::Parameters::X_IS_NEGATIVE, crate::Parameters::X); + const X: Fr = Fr::from_sign_and_limbs(!crate::Config::X_IS_NEGATIVE, crate::Config::X); Fr::one() - X }@@ -154,7 +154,7 @@
/// BETA is a non-trivial cubic root of unity in Fq. pub const BETA: Fq = MontFp!("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"); -pub fn endomorphism(p: &Affine<Parameters>) -> Affine<Parameters> { +pub fn endomorphism(p: &Affine<Config>) -> Affine<Config> { // Endomorphism of the points on the curve. // endomorphism_p(x,y) = (BETA * x, y) // where BETA is a non-trivial cubic root of unity in Fq.@@ -169,7 +169,7 @@
use super::*; use ark_std::{rand::Rng, UniformRand}; - fn sample_unchecked() -> Affine<g1::Parameters> { + fn sample_unchecked() -> Affine<g1::Config> { let mut rng = ark_std::test_rng(); loop { let x = Fq::rand(&mut rng);@@ -185,7 +185,7 @@ #[test]
fn test_cofactor_clearing() { const SAMPLES: usize = 100; for _ in 0..SAMPLES { - let p: Affine<g1::Parameters> = sample_unchecked(); + let p: Affine<g1::Config> = sample_unchecked(); let p = p.clear_cofactor(); assert!(p.is_on_curve()); assert!(p.is_in_correct_subgroup_assuming_on_curve());
@@ -2,7 +2,7 @@ use ark_std::ops::Neg;
use ark_ec::{ bls12, - bls12::Bls12Parameters, + bls12::Bls12Config, models::CurveConfig, short_weierstrass::{Affine, Projective, SWCurveConfig}, AffineRepr, CurveGroup, Group,@@ -16,13 +16,13 @@ util::{read_g2_compressed, read_g2_uncompressed},
*, }; -pub type G2Affine = bls12::G2Affine<crate::Parameters>; -pub type G2Projective = bls12::G2Projective<crate::Parameters>; +pub type G2Affine = bls12::G2Affine<crate::Config>; +pub type G2Projective = bls12::G2Projective<crate::Config>; #[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;@@ -47,12 +47,12 @@ const COFACTOR_INV: Fr =
MontFp!("26652489039290660355457965112010883481355318854675681319708643586776743290055"); } -impl SWCurveConfig for Parameters { +impl 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);@@ -67,8 +67,8 @@ // Algorithm from Section 4 of https://eprint.iacr.org/2021/1130.
// // Checks that [p]P = [X]P - let mut x_times_point = point.mul_bigint(crate::Parameters::X); - if crate::Parameters::X_IS_NEGATIVE { + let mut x_times_point = point.mul_bigint(crate::Config::X); + if crate::Config::X_IS_NEGATIVE { x_times_point = -x_times_point; }@@ -86,11 +86,11 @@ // x = -15132376222941642752
// 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::Parameters::X; + let x: &'static [u64] = crate::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)@@ -101,7 +101,7 @@ let mut tmp = x_p.clone();
tmp += &psi_p; // tmp2 = [x^2]P + [x]ψ(P) - let mut tmp2: Projective<Parameters> = tmp; + let mut tmp2: Projective<Config> = tmp; tmp2 = tmp2.mul_bigint(x).neg(); // add up all the terms@@ -224,7 +224,7 @@ MontFp!("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"),
Fq::ZERO ); -pub fn p_power_endomorphism(p: &Affine<Parameters>) -> Affine<Parameters> { +pub fn p_power_endomorphism(p: &Affine<Config>) -> Affine<Config> { // 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,@@ -252,7 +252,7 @@ res
} /// For a p-power endomorphism psi(P), compute psi(psi(P)) -pub fn double_p_power_endomorphism(p: &Projective<Parameters>) -> Projective<Parameters> { +pub fn double_p_power_endomorphism(p: &Projective<Config>) -> Projective<Config> { let mut res = *p; res.x *= DOUBLE_P_POWER_ENDOMORPHISM;@@ -287,9 +287,9 @@
let mut rng = ark_std::test_rng(); const SAMPLES: usize = 10; for _ in 0..SAMPLES { - let p = Affine::<g2::Parameters>::rand(&mut rng); + let p = Affine::<g2::Config>::rand(&mut rng); let optimised = p.clear_cofactor().into_group(); - let naive = g2::Parameters::mul_affine(&p, h_eff); + let naive = g2::Config::mul_affine(&p, h_eff); assert_eq!(optimised, naive); } }
@@ -1,4 +1,4 @@
-use ark_ec::bls12::{Bls12, Bls12Parameters, TwistType}; +use ark_ec::bls12::{Bls12, Bls12Config, TwistType}; use crate::{Fq, Fq12Config, Fq2Config, Fq6Config};@@ -14,11 +14,11 @@ g1::{G1Affine, G1Projective},
g2::{G2Affine, G2Projective}, }; -pub type Bls12_381 = Bls12<Parameters>; +pub type Bls12_381 = Bls12<Config>; -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;@@ -26,6 +26,6 @@ type Fp = Fq;
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; }
@@ -2,9 +2,7 @@ use ark_ec::{short_weierstrass::Affine, AffineRepr};
use ark_ff::{BigInteger384, PrimeField}; use ark_serialize::SerializationError; -use crate::{ - g1::Parameters as G1Parameters, g2::Parameters as G2Parameters, Fq, Fq2, G1Affine, G2Affine, -}; +use crate::{g1::Config as G1Config, g2::Config as G2Config, Fq, Fq2, G1Affine, G2Affine}; pub const G1_SERIALIZED_SIZE: usize = 48; pub const G2_SERIALIZED_SIZE: usize = 96;@@ -91,7 +89,7 @@ }
pub(crate) fn read_g1_compressed<R: ark_serialize::Read>( mut reader: R, -) -> Result<Affine<G1Parameters>, ark_serialize::SerializationError> { +) -> Result<Affine<G1Config>, ark_serialize::SerializationError> { let mut bytes = [0u8; G1_SERIALIZED_SIZE]; reader .read_exact(&mut bytes)@@ -121,7 +119,7 @@ }
pub(crate) fn read_g1_uncompressed<R: ark_serialize::Read>( mut reader: R, -) -> Result<Affine<G1Parameters>, ark_serialize::SerializationError> { +) -> Result<Affine<G1Config>, ark_serialize::SerializationError> { let mut bytes = [0u8; 2 * G1_SERIALIZED_SIZE]; reader .read_exact(&mut bytes)@@ -151,7 +149,7 @@ }
pub(crate) fn read_g2_compressed<R: ark_serialize::Read>( mut reader: R, -) -> Result<Affine<G2Parameters>, ark_serialize::SerializationError> { +) -> Result<Affine<G2Config>, ark_serialize::SerializationError> { let mut bytes = [0u8; G2_SERIALIZED_SIZE]; reader .read_exact(&mut bytes)@@ -183,7 +181,7 @@ }
pub(crate) fn read_g2_uncompressed<R: ark_serialize::Read>( mut reader: R, -) -> Result<Affine<G2Parameters>, ark_serialize::SerializationError> { +) -> Result<Affine<G2Config>, ark_serialize::SerializationError> { let mut bytes = [0u8; 2 * G2_SERIALIZED_SIZE]; reader .read_exact(&mut bytes)
@@ -7,11 +7,11 @@
use crate::{Fq, Fr}; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -pub type G1Affine = Affine<Parameters>; +pub type G1Affine = Affine<Config>; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq; type ScalarField = Fr;@@ -22,7 +22,7 @@ /// COFACTOR_INV = COFACTOR^{-1} mod r = 1
const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;
@@ -6,12 +6,12 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{Fq, Fq2, Fr}; -pub type G2Affine = Affine<Parameters>; +pub type G2Affine = Affine<Config>; #[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;@@ -30,7 +30,7 @@ const COFACTOR_INV: Fr =
MontFp!("10944121435919637613327163357776759465618812564592884533313067514031822496649"); } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = [0, 0] const COEFF_A: Fq2 = Fq2::ZERO;
@@ -1,6 +1,6 @@
use ark_ec::{ bn, - bn::{Bn, BnParameters, TwistType}, + bn::{Bn, BnConfig, TwistType}, }; use ark_ff::MontFp;@@ -12,9 +12,9 @@
#[cfg(test)] mod tests; -pub struct Parameters; +pub struct Config; -impl BnParameters for Parameters { +impl BnConfig for Config { const X: &'static [u64] = &[4965661367192848881]; /// `x` is positive. const X_IS_NEGATIVE: bool = false;@@ -37,13 +37,13 @@ type Fp = Fq;
type Fp2Config = Fq2Config; type Fp6Config = Fq6Config; type Fp12Config = Fq12Config; - type G1Parameters = g1::Parameters; - type G2Parameters = g2::Parameters; + type G1Config = g1::Config; + type G2Config = g2::Config; } -pub type Bn254 = Bn<Parameters>; +pub type Bn254 = Bn<Config>; -pub type G1Affine = bn::G1Affine<Parameters>; -pub type G1Projective = bn::G1Projective<Parameters>; -pub type G2Affine = bn::G2Affine<Parameters>; -pub type G2Projective = bn::G2Projective<Parameters>; +pub type G1Affine = bn::G1Affine<Config>; +pub type G1Projective = bn::G1Projective<Config>; +pub type G2Affine = bn::G2Affine<Config>; +pub type G2Projective = bn::G2Projective<Config>;
@@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; -pub type G1Affine = Affine<Parameters>; -pub type G1Projective = Projective<Parameters>; +pub type G1Affine = Affine<Config>; +pub type G1Projective = Projective<Config>; #[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;@@ -33,7 +33,7 @@ /// 91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804
const COFACTOR_INV: Fr = MontFp!("91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804"); } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;
@@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; -pub type G2Affine = Affine<Parameters>; -pub type G2Projective = Projective<Parameters>; +pub type G2Affine = Affine<Config>; +pub type G2Projective = Projective<Config>; #[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;@@ -33,7 +33,7 @@ /// 214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124
const COFACTOR_INV: Fr = MontFp!("214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124"); } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;
@@ -1,6 +1,6 @@
use ark_ec::{ bw6, - bw6::{BW6Parameters, TwistType, BW6}, + bw6::{BW6Config, TwistType, BW6}, }; use ark_ff::{biginteger::BigInteger768 as BigInteger, BigInt};@@ -13,9 +13,9 @@ #[cfg(test)]
mod tests; #[derive(PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl BW6Parameters for Parameters { +impl BW6Config for Config { const X: BigInteger = BigInt::new([ 0x8508c00000000001, 0x0,@@ -50,13 +50,13 @@ const TWIST_TYPE: TwistType = TwistType::M;
type Fp = Fq; type Fp3Config = Fq3Config; type Fp6Config = Fq6Config; - type G1Parameters = g1::Parameters; - type G2Parameters = g2::Parameters; + type G1Config = g1::Config; + type G2Config = g2::Config; } -pub type BW6_761 = BW6<Parameters>; +pub type BW6_761 = BW6<Config>; -pub type G1Affine = bw6::G1Affine<Parameters>; -pub type G1Projective = bw6::G1Projective<Parameters>; -pub type G2Affine = bw6::G2Affine<Parameters>; -pub type G2Projective = bw6::G2Projective<Parameters>; +pub type G1Affine = bw6::G1Affine<Config>; +pub type G1Projective = bw6::G1Projective<Config>; +pub type G2Affine = bw6::G2Affine<Config>; +pub type G2Projective = bw6::G2Projective<Config>;
@@ -9,8 +9,8 @@ use ark_std::vec::Vec;
use crate::{Fq, Fr}; -pub type G1Affine = Affine<Parameters>; -pub type G1Projective = Projective<Parameters>; +pub type G1Affine = Affine<Config>; +pub type G1Projective = Projective<Config>; #[derive(Clone, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)] pub struct G1Prepared(pub G1Affine);@@ -52,9 +52,9 @@ }
} #[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;@@ -76,7 +76,7 @@ /// 163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788
const COFACTOR_INV: Fr = MontFp!("163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788"); } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 5 const COEFF_A: Fq = MontFp!("5");
@@ -9,8 +9,8 @@ use ark_std::vec::Vec;
use crate::{Fq, Fq3, Fr}; -pub type G2Affine = Affine<Parameters>; -pub type G2Projective = Projective<Parameters>; +pub type G2Affine = Affine<Config>; +pub type G2Projective = Projective<Config>; #[derive(Clone, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)] pub struct G2Prepared(pub G2Affine);@@ -52,9 +52,9 @@ }
} #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq3; type ScalarField = Fr;@@ -100,7 +100,7 @@ /// 45586359457219724873147353901735745013467692594291916855200979604570630929674383405372210802279573887880950375598
const COFACTOR_INV: Fr = MontFp!("45586359457219724873147353901735745013467692594291916855200979604570630929674383405372210802279573887880950375598"); } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = (0, 0, COEFF_A * TWIST^2) = (0, 0, 5) const COEFF_A: Fq3 = Fq3::new(Fq::ZERO, Fq::ZERO, MontFp!("5"));
@@ -78,7 +78,7 @@ old_ry = ry;
let old_rx_square = old_rx.square(); let old_rx_square_3 = old_rx_square.double() + &old_rx_square; - let old_rx_square_3_a = old_rx_square_3 + &g2::Parameters::COEFF_A; + let old_rx_square_3_a = old_rx_square_3 + &g2::Config::COEFF_A; let old_ry_double_inverse = old_ry.double().inverse().unwrap(); let gamma = old_rx_square_3_a * &old_ry_double_inverse;
@@ -3,9 +3,9 @@
use crate::{constraints::FqVar, *}; /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>; +pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap(); }
@@ -8,13 +8,13 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<EdwardsParameters>; -pub type EdwardsProjective = Projective<EdwardsParameters>; +pub type EdwardsAffine = Affine<EdwardsConfig>; +pub type EdwardsProjective = Projective<EdwardsConfig>; #[derive(Clone, Default, PartialEq, Eq)] -pub struct EdwardsParameters; +pub struct EdwardsConfig; -impl CurveConfig for EdwardsParameters { +impl CurveConfig for EdwardsConfig { type BaseField = Fq; type ScalarField = Fr;@@ -27,7 +27,7 @@ const COFACTOR_INV: Fr =
MontFp!("2713877091499598330239944961141122840321418634767465352250731601857045344121"); } -impl TECurveConfig for EdwardsParameters { +impl TECurveConfig for EdwardsConfig { /// COEFF_A = -1 const COEFF_A: Fq = MontFp!("-1");@@ -38,7 +38,7 @@
/// Standard generators from <https://neuromancer.sk/std/other/Ed25519>. const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y); - type MontCurveConfig = EdwardsParameters; + type MontCurveConfig = EdwardsConfig; /// Multiplication by `a` is just negation. #[inline(always)]@@ -48,7 +48,7 @@ }
} // We want to emphasize that this Montgomery curve is not Curve25519. -impl MontCurveConfig for EdwardsParameters { +impl MontCurveConfig for EdwardsConfig { /// COEFF_A = 486662 const COEFF_A: Fq = MontFp!("486662");@@ -57,7 +57,7 @@ /// This is not one, because ed25519 != curve25519
const COEFF_B: Fq = MontFp!("57896044618658097711785492504343953926634992332820282019728792003956564333285"); - type TECurveConfig = EdwardsParameters; + type TECurveConfig = EdwardsConfig; } /// GENERATOR_X =
@@ -3,9 +3,9 @@
use crate::{constraints::FqVar, *}; /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>; +pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap(); }
@@ -9,13 +9,13 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<EdwardsParameters>; -pub type EdwardsProjective = Projective<EdwardsParameters>; +pub type EdwardsAffine = Affine<EdwardsConfig>; +pub type EdwardsProjective = Projective<EdwardsConfig>; #[derive(Clone, Default, PartialEq, Eq)] -pub struct EdwardsParameters; +pub struct EdwardsConfig; -impl CurveConfig for EdwardsParameters { +impl CurveConfig for EdwardsConfig { type BaseField = Fq; type ScalarField = Fr;@@ -28,7 +28,7 @@ const COFACTOR_INV: Fr =
MontFp!("527778859339273151515551558673846658209717731602102048798421311598680340096"); } -impl TECurveConfig for EdwardsParameters { +impl TECurveConfig for EdwardsConfig { /// COEFF_A = -1 const COEFF_A: Fq = MontFp!("-1");@@ -38,7 +38,7 @@
/// Generated randomly const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y); - type MontCurveConfig = EdwardsParameters; + type MontCurveConfig = EdwardsConfig; /// Multiplication by `a` is just negation. /// Is `a` 1 or -1?@@ -48,7 +48,7 @@ -elem
} } -impl MontCurveConfig for EdwardsParameters { +impl MontCurveConfig for EdwardsConfig { /// COEFF_A = 0x8D26E3FADA9010A26949031ECE3971B93952AD84D4753DDEDB748DA37E8F552 /// = 3990301581132929505568273333084066329187552697088022219156688740916631500114 const COEFF_A: Fq =@@ -59,7 +59,7 @@ /// = 4454160168295440918680551605697480202188346638066041608778544715000777738925
const COEFF_B: Fq = MontFp!("4454160168295440918680551605697480202188346638066041608778544715000777738925"); - type TECurveConfig = EdwardsParameters; + type TECurveConfig = EdwardsConfig; } /// GENERATOR_X =
@@ -3,10 +3,10 @@
use crate::{constraints::FqVar, *}; /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar<JubjubParameters, FqVar>; +pub type EdwardsVar = AffineVar<JubjubConfig, FqVar>; /// A variable that is the R1CS equivalent of `crate::SWProjective` -pub type SWVar = ProjectiveVar<JubjubParameters, FqVar>; +pub type SWVar = ProjectiveVar<JubjubConfig, FqVar>; #[test] fn test() {
@@ -10,10 +10,10 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<JubjubParameters>; -pub type EdwardsProjective = Projective<JubjubParameters>; -pub type SWAffine = short_weierstrass::Affine<JubjubParameters>; -pub type SWProjective = short_weierstrass::Projective<JubjubParameters>; +pub type EdwardsAffine = Affine<JubjubConfig>; +pub type EdwardsProjective = Projective<JubjubConfig>; +pub type SWAffine = short_weierstrass::Affine<JubjubConfig>; +pub type SWProjective = short_weierstrass::Projective<JubjubConfig>; /// `JubJub` is a twisted Edwards curve. These curves have equations of the /// form: ax² + y² = 1 - dx²y².@@ -49,11 +49,11 @@ /// We can use the script available
/// [here](https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/jubjub.sage) /// to convert between the different representations. #[derive(Clone, Default, PartialEq, Eq)] -pub struct JubjubParameters; -pub type EdwardsParameters = JubjubParameters; -pub type SWParameters = JubjubParameters; +pub struct JubjubConfig; +pub type EdwardsConfig = JubjubConfig; +pub type SWConfig = JubjubConfig; -impl CurveConfig for JubjubParameters { +impl CurveConfig for JubjubConfig { type BaseField = Fq; type ScalarField = Fr;@@ -66,7 +66,7 @@ const COFACTOR_INV: Fr =
MontFp!("819310549611346726241370945440405716213240158234039660170669895299022906775"); } -impl TECurveConfig for JubjubParameters { +impl TECurveConfig for JubjubConfig { /// COEFF_A = -1 const COEFF_A: Fq = MontFp!("-1");@@ -77,7 +77,7 @@
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y); - type MontCurveConfig = JubjubParameters; + type MontCurveConfig = JubjubConfig; /// Multiplication by `a` is simply negation here. #[inline(always)]@@ -86,14 +86,14 @@ -elem
} } -impl MontCurveConfig for JubjubParameters { +impl MontCurveConfig for JubjubConfig { /// COEFF_A = 40962 const COEFF_A: Fq = MontFp!("40962"); /// COEFF_B = -40964 const COEFF_B: Fq = MontFp!("-40964"); - type TECurveConfig = JubjubParameters; + type TECurveConfig = JubjubConfig; } const GENERATOR_X: Fq =@@ -102,7 +102,7 @@
const GENERATOR_Y: Fq = MontFp!("13262374693698910701929044844600465831413122818447359594527400194675274060458"); -impl SWCurveConfig for JubjubParameters { +impl SWCurveConfig for JubjubConfig { /// COEFF_A = 52296097456646850916096512823759002727550416093741407922227928430486925478210 const COEFF_A: Self::BaseField = MontFp!("52296097456646850916096512823759002727550416093741407922227928430486925478210");
@@ -2,11 +2,11 @@ use ark_r1cs_std::groups::curves::{short_weierstrass::ProjectiveVar, twisted_edwards::AffineVar};
use crate::{constraints::FqVar, *}; -/// A variable that is the R1CS equivalent of `crate::BandersnatchParameters`. -pub type EdwardsVar = AffineVar<BandersnatchParameters, FqVar>; +/// A variable that is the R1CS equivalent of `crate::BandersnatchConfig`. +pub type EdwardsVar = AffineVar<BandersnatchConfig, FqVar>; /// A variable that is the R1CS equivalent of `crate::SWProjective` -pub type SWVar = ProjectiveVar<BandersnatchParameters, FqVar>; +pub type SWVar = ProjectiveVar<BandersnatchConfig, FqVar>; #[test] fn test() {
@@ -10,11 +10,11 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<BandersnatchParameters>; -pub type EdwardsProjective = Projective<BandersnatchParameters>; +pub type EdwardsAffine = Affine<BandersnatchConfig>; +pub type EdwardsProjective = Projective<BandersnatchConfig>; -pub type SWAffine = short_weierstrass::Affine<BandersnatchParameters>; -pub type SWProjective = short_weierstrass::Projective<BandersnatchParameters>; +pub type SWAffine = short_weierstrass::Affine<BandersnatchConfig>; +pub type SWProjective = short_weierstrass::Projective<BandersnatchConfig>; /// `bandersnatch` is an incomplete twisted Edwards curve. These curves have /// equations of the form: ax² + y² = 1 + dx²y².@@ -49,12 +49,12 @@ ///
/// Script to transfer between different curves are available /// <https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/bandersnatch.sage> #[derive(Clone, Default, PartialEq, Eq)] -pub struct BandersnatchParameters; +pub struct BandersnatchConfig; -pub type EdwardsParameters = BandersnatchParameters; -pub type SWParameters = BandersnatchParameters; +pub type EdwardsConfig = BandersnatchConfig; +pub type SWConfig = BandersnatchConfig; -impl CurveConfig for BandersnatchParameters { +impl CurveConfig for BandersnatchConfig { type BaseField = Fq; type ScalarField = Fr;@@ -67,7 +67,7 @@ const COFACTOR_INV: Fr =
MontFp!("9831726595336160714896451345284868594481866920080427688839802480047265754601"); } -impl TECurveConfig for BandersnatchParameters { +impl TECurveConfig for BandersnatchConfig { /// COEFF_A = -5 const COEFF_A: Fq = MontFp!("-5");@@ -79,7 +79,7 @@
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(TE_GENERATOR_X, TE_GENERATOR_Y); - type MontCurveConfig = BandersnatchParameters; + type MontCurveConfig = BandersnatchConfig; /// Multiplication by `a` is multiply by `-5`. #[inline(always)]@@ -88,7 +88,7 @@ -(elem.double().double() + elem)
} } -impl MontCurveConfig for BandersnatchParameters { +impl MontCurveConfig for BandersnatchConfig { /// COEFF_A = 29978822694968839326280996386011761570173833766074948509196803838190355340952 const COEFF_A: Fq = MontFp!("29978822694968839326280996386011761570173833766074948509196803838190355340952");@@ -97,7 +97,7 @@ /// COEFF_B = 25465760566081946422412445027709227188579564747101592991722834452325077642517
const COEFF_B: Fq = MontFp!("25465760566081946422412445027709227188579564747101592991722834452325077642517"); - type TECurveConfig = BandersnatchParameters; + type TECurveConfig = BandersnatchConfig; } // The TE form generator is generated following Zcash's fashion:@@ -125,7 +125,7 @@ /// y coordinate for SW curve generator
const SW_GENERATOR_Y: Fq = MontFp!("12663882780877899054958035777720958383845500985908634476792678820121468453298"); -impl SWCurveConfig for BandersnatchParameters { +impl SWCurveConfig for BandersnatchConfig { /// COEFF_A = 10773120815616481058602537765553212789256758185246796157495669123169359657269 const COEFF_A: Self::BaseField = MontFp!("10773120815616481058602537765553212789256758185246796157495669123169359657269");
@@ -3,7 +3,7 @@
use crate::{constraints::FqVar, *}; /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>; +pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>; #[test] fn test() {
@@ -9,8 +9,8 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<EdwardsParameters>; -pub type EdwardsProjective = Projective<EdwardsParameters>; +pub type EdwardsAffine = Affine<EdwardsConfig>; +pub type EdwardsProjective = Projective<EdwardsConfig>; /// `Baby-JubJub` is a twisted Edwards curve. These curves have equations of the /// form: ax² + y² = 1 + dx²y².@@ -20,9 +20,9 @@ /// Baby-JubJub's curve equation: x² + y² = 1 + (168696/168700)x²y²
/// /// q = 21888242871839275222246405745257275088548364400416034343698204186575808495617 #[derive(Clone, Default, PartialEq, Eq)] -pub struct EdwardsParameters; +pub struct EdwardsConfig; -impl CurveConfig for EdwardsParameters { +impl CurveConfig for EdwardsConfig { type BaseField = Fq; type ScalarField = Fr;@@ -35,7 +35,7 @@ const COFACTOR_INV: Fr =
MontFp!("2394026564107420727433200628387514462817212225638746351800188703329891451411"); } -impl TECurveConfig for EdwardsParameters { +impl TECurveConfig for EdwardsConfig { /// COEFF_A = 1 const COEFF_A: Fq = Fq::ONE;@@ -52,16 +52,16 @@
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y); - type MontCurveConfig = EdwardsParameters; + type MontCurveConfig = EdwardsConfig; } -impl MontCurveConfig for EdwardsParameters { +impl MontCurveConfig for EdwardsConfig { /// COEFF_A = 168698 const COEFF_A: Fq = MontFp!("168698"); /// COEFF_B = 168700 const COEFF_B: Fq = MontFp!("168700"); - type TECurveConfig = EdwardsParameters; + type TECurveConfig = EdwardsConfig; } const GENERATOR_X: Fq =
@@ -3,9 +3,9 @@
use crate::{constraints::FqVar, *}; /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>; +pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap(); }
@@ -9,13 +9,13 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<EdwardsParameters>; -pub type EdwardsProjective = Projective<EdwardsParameters>; +pub type EdwardsAffine = Affine<EdwardsConfig>; +pub type EdwardsProjective = Projective<EdwardsConfig>; #[derive(Clone, Default, PartialEq, Eq)] -pub struct EdwardsParameters; +pub struct EdwardsConfig; -impl CurveConfig for EdwardsParameters { +impl CurveConfig for EdwardsConfig { type BaseField = Fq; type ScalarField = Fr;@@ -27,7 +27,7 @@ /// 12124894969357926281749346891948134384518445910386624712788431705725441736421489799867521238554906438478484045560
const COFACTOR_INV: Fr = MontFp!("12124894969357926281749346891948134384518445910386624712788431705725441736421489799867521238554906438478484045560"); } -impl TECurveConfig for EdwardsParameters { +impl TECurveConfig for EdwardsConfig { /// COEFF_A = -1 = const COEFF_A: Fq = MontFp!("-1");@@ -37,7 +37,7 @@
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y); - type MontCurveConfig = EdwardsParameters; + type MontCurveConfig = EdwardsConfig; /// Multiplication by `a` is just negation. #[inline(always)]@@ -46,14 +46,14 @@ -elem
} } -impl MontCurveConfig for EdwardsParameters { +impl MontCurveConfig for EdwardsConfig { /// COEFF_A = 0x95D53EB3F6AC3F7A53C26020144439DC6073BCAE513E03FD06B6B3BAA390F25E51534B26719E33F4CD906D4DA9B535 const COEFF_A: Fq = MontFp!("90083623084271891037116870487743067984710080209539149685414147055329063590616489392386084989619674926965747987765"); /// COEFF_B = 0x118650763CE64AB4BE743604C8D05013DC2663652A3D58B21ECAB7BFF65B70DB8BA09F9098E61CC903B2F92B2564ACA const COEFF_B: Fq = MontFp!("168580802928697202973535863207150465551683432545375510854470115611391404757724333382582803149953685197474573470410"); - type TECurveConfig = EdwardsParameters; + type TECurveConfig = EdwardsConfig; } /// GENERATOR_X =
@@ -3,9 +3,9 @@
use crate::{constraints::fields::FqVar, *}; /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>; +pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap(); }
@@ -9,13 +9,13 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<EdwardsParameters>; -pub type EdwardsProjective = Projective<EdwardsParameters>; +pub type EdwardsAffine = Affine<EdwardsConfig>; +pub type EdwardsProjective = Projective<EdwardsConfig>; #[derive(Clone, Default, PartialEq, Eq)] -pub struct EdwardsParameters; +pub struct EdwardsConfig; -impl CurveConfig for EdwardsParameters { +impl CurveConfig for EdwardsConfig { type BaseField = Fq; type ScalarField = Fr;@@ -34,7 +34,7 @@ // discussed below. Some useful numbers:
// R for Fq: 223364648326281414938801705359223029554923725549792420683051274872200260503540791531766876 // R for Fr: 104384076783966083500464392945960916666734135485183910065100558776489954102951241798239545 -impl TECurveConfig for EdwardsParameters { +impl TECurveConfig for EdwardsConfig { /// COEFF_A = -1 /// Needs to be in the Montgomery residue form in Fq /// I.e., -1 * R for Fq@@ -50,7 +50,7 @@
/// Generated randomly const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y); - type MontCurveConfig = EdwardsParameters; + type MontCurveConfig = EdwardsConfig; /// Multiplication by `a` is just negation. #[inline(always)]@@ -59,14 +59,14 @@ -elem
} } -impl MontCurveConfig for EdwardsParameters { +impl MontCurveConfig for EdwardsConfig { /// COEFF_A = 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204 const COEFF_A: Fq = MontFp!("203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204"); /// COEFF_B = 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931 const COEFF_B: Fq = MontFp!("272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931"); - type TECurveConfig = EdwardsParameters; + type TECurveConfig = EdwardsConfig; } /// GENERATOR_X =
@@ -3,9 +3,9 @@
use crate::{constraints::fields::FqVar, *}; /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>; +pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap(); }
@@ -9,13 +9,13 @@
#[cfg(test)] mod tests; -pub type EdwardsAffine = Affine<EdwardsParameters>; -pub type EdwardsProjective = Projective<EdwardsParameters>; +pub type EdwardsAffine = Affine<EdwardsConfig>; +pub type EdwardsProjective = Projective<EdwardsConfig>; #[derive(Clone, Default, PartialEq, Eq)] -pub struct EdwardsParameters; +pub struct EdwardsConfig; -impl CurveConfig for EdwardsParameters { +impl CurveConfig for EdwardsConfig { type BaseField = Fq; type ScalarField = Fr;@@ -27,7 +27,7 @@ /// 4582647449616135528381398492791944685893671397494963179726320631987147963874964803303316505414568319530101512550297775574042810022553679071007001162683923594233560231270043634777390699589793776691858866199511300853468155295505
const COFACTOR_INV: Fr = MontFp!("4582647449616135528381398492791944685893671397494963179726320631987147963874964803303316505414568319530101512550297775574042810022553679071007001162683923594233560231270043634777390699589793776691858866199511300853468155295505"); } -impl TECurveConfig for EdwardsParameters { +impl TECurveConfig for EdwardsConfig { /// COEFF_A = -1 const COEFF_A: Fq = MontFp!("-1");@@ -37,7 +37,7 @@
/// Generated randomly const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y); - type MontCurveConfig = EdwardsParameters; + type MontCurveConfig = EdwardsConfig; /// Multiplication by `a` is just negation. #[inline(always)]@@ -46,14 +46,14 @@ -elem
} } -impl MontCurveConfig for EdwardsParameters { +impl MontCurveConfig for EdwardsConfig { /// COEFF_A = 40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419 const COEFF_A: Fq = MontFp!("40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419"); /// COEFF_B = 1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580 const COEFF_B: Fq = MontFp!("1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580"); - type TECurveConfig = EdwardsParameters; + type TECurveConfig = EdwardsConfig; } /// GENERATOR_X =
@@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt4; -use crate::Parameters; +use crate::Config; /// An element of G1 in the MNT4-298 bilinear group. -pub type G1Var = mnt4::G1Var<Parameters>; +pub type G1Var = mnt4::G1Var<Config>; /// An element of G2 in the MNT4-298 bilinear group. -pub type G2Var = mnt4::G2Var<Parameters>; +pub type G2Var = mnt4::G2Var<Config>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. -pub type G1PreparedVar = mnt4::G1PreparedVar<Parameters>; +pub type G1PreparedVar = mnt4::G1PreparedVar<Config>; /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. -pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>; +pub type G2PreparedVar = mnt4::G2PreparedVar<Config>; #[test] fn test() { - use ark_ec::models::mnt4::MNT4Parameters; - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT4Parameters>::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT4Parameters>::G2Parameters, - G2Var, - >() - .unwrap(); + use ark_ec::models::mnt4::MNT4Config; + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G1Config, G1Var>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G2Config, G2Var>() + .unwrap(); }
@@ -1,8 +1,8 @@
-use crate::Parameters; +use crate::Config; /// Specifies the constraints for computing a pairing in the MNT4-298 bilinear /// group. -pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>; +pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>; #[test] fn test() {
@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; -pub type G1Affine = mnt4::G1Affine<crate::Parameters>; -pub type G1Projective = mnt4::G1Projective<crate::Parameters>; -pub type G1Prepared = mnt4::G1Prepared<crate::Parameters>; +pub type G1Affine = mnt4::G1Affine<crate::Config>; +pub type G1Projective = mnt4::G1Projective<crate::Config>; +pub type G1Prepared = mnt4::G1Prepared<crate::Config>; #[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 @@ /// 1
const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 2 /// Reference: <https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L116> const COEFF_A: Fq = MontFp!("2");
@@ -1,20 +1,20 @@
use ark_ec::{ mnt4, - mnt4::MNT4Parameters, + mnt4::MNT4Config, models::{short_weierstrass::SWCurveConfig, CurveConfig}, }; use ark_ff::{Field, MontFp}; use crate::{Fq, Fq2, Fr, G1_COEFF_A_NON_RESIDUE}; -pub type G2Affine = mnt4::G2Affine<crate::Parameters>; -pub type G2Projective = mnt4::G2Projective<crate::Parameters>; -pub type G2Prepared = mnt4::G2Prepared<crate::Parameters>; +pub type G2Affine = mnt4::G2Affine<crate::Config>; +pub type G2Projective = mnt4::G2Projective<crate::Config>; +pub type G2Prepared = mnt4::G2Prepared<crate::Config>; #[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;@@ -40,8 +40,8 @@
/// MUL_BY_A_C1 = NONRESIDUE * COEFF_A pub const MUL_BY_A_C1: Fq = G1_COEFF_A_NON_RESIDUE; -impl SWCurveConfig for Parameters { - const COEFF_A: Fq2 = crate::Parameters::TWIST_COEFF_A; +impl SWCurveConfig for Config { + const COEFF_A: Fq2 = crate::Config::TWIST_COEFF_A; // B coefficient of MNT4-298 G2 = // ``` // mnt4298_twist_coeff_b = mnt4298_Fq2(mnt4298_Fq::zero(),
@@ -1,4 +1,4 @@
-use ark_ec::models::mnt4::{MNT4Parameters, MNT4}; +use ark_ec::models::mnt4::{MNT4Config, MNT4}; use ark_ff::{biginteger::BigInteger320, BigInt, Field, MontFp}; use crate::{Fq, Fq2, Fq2Config, Fq4Config, Fr};@@ -14,11 +14,11 @@ g1::{G1Affine, G1Prepared, G1Projective},
g2::{G2Affine, G2Prepared, G2Projective}, }; -pub type MNT4_298 = MNT4<Parameters>; +pub type MNT4_298 = MNT4<Config>; -pub struct Parameters; +pub struct Config; -impl MNT4Parameters for Parameters { +impl MNT4Config for Config { const TWIST: Fq2 = Fq2::new(Fq::ZERO, Fq::ONE); // A coefficient of MNT4-298 G2 = // ```@@ -46,8 +46,8 @@ type Fp = Fq;
type Fr = Fr; type Fp2Config = Fq2Config; type Fp4Config = Fq4Config; - type G1Parameters = self::g1::Parameters; - type G2Parameters = self::g2::Parameters; + type G1Config = self::g1::Config; + type G2Config = self::g2::Config; } // 34
@@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt4; -use crate::Parameters; +use crate::Config; /// An element of G1 in the MNT4-753 bilinear group. -pub type G1Var = mnt4::G1Var<Parameters>; +pub type G1Var = mnt4::G1Var<Config>; /// An element of G2 in the MNT4-753 bilinear group. -pub type G2Var = mnt4::G2Var<Parameters>; +pub type G2Var = mnt4::G2Var<Config>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. -pub type G1PreparedVar = mnt4::G1PreparedVar<Parameters>; +pub type G1PreparedVar = mnt4::G1PreparedVar<Config>; /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. -pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>; +pub type G2PreparedVar = mnt4::G2PreparedVar<Config>; #[test] fn test() { - use ark_ec::models::mnt4::MNT4Parameters; - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT4Parameters>::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT4Parameters>::G2Parameters, - G2Var, - >() - .unwrap(); + use ark_ec::models::mnt4::MNT4Config; + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G1Config, G1Var>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G2Config, G2Var>() + .unwrap(); }
@@ -1,8 +1,8 @@
-use crate::Parameters; +use crate::Config; /// Specifies the constraints for computing a pairing in the MNT4-753 bilinear /// group. -pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>; +pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>; #[test] fn test() {
@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; -pub type G1Affine = mnt4::G1Affine<crate::Parameters>; -pub type G1Projective = mnt4::G1Projective<crate::Parameters>; -pub type G1Prepared = mnt4::G1Prepared<crate::Parameters>; +pub type G1Affine = mnt4::G1Affine<crate::Config>; +pub type G1Projective = mnt4::G1Projective<crate::Config>; +pub type G1Prepared = mnt4::G1Prepared<crate::Config>; #[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 @@ /// COFACTOR^(-1) mod r = 1
const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 2 const COEFF_A: Fq = MontFp!("2");
@@ -1,20 +1,20 @@
use ark_ec::{ mnt4, - mnt4::MNT4Parameters, + mnt4::MNT4Config, models::{short_weierstrass::SWCurveConfig, CurveConfig}, }; use ark_ff::{Field, MontFp}; use crate::{Fq, Fq2, Fr, G1_COEFF_A_NON_RESIDUE}; -pub type G2Affine = mnt4::G2Affine<crate::Parameters>; -pub type G2Projective = mnt4::G2Projective<crate::Parameters>; -pub type G2Prepared = mnt4::G2Prepared<crate::Parameters>; +pub type G2Affine = mnt4::G2Affine<crate::Config>; +pub type G2Projective = mnt4::G2Projective<crate::Config>; +pub type G2Prepared = mnt4::G2Prepared<crate::Config>; #[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;@@ -47,8 +47,8 @@
/// MUL_BY_A_C1 = NONRESIDUE * COEFF_A pub const MUL_BY_A_C1: Fq = G1_COEFF_A_NON_RESIDUE; -impl SWCurveConfig for Parameters { - const COEFF_A: Fq2 = crate::Parameters::TWIST_COEFF_A; +impl SWCurveConfig for Config { + const COEFF_A: Fq2 = crate::Config::TWIST_COEFF_A; // B coefficient of MNT4-753 G2 = // ``` // mnt4753_twist_coeff_b = mnt4753_Fq2(mnt4753_Fq::zero(),
@@ -1,4 +1,4 @@
-use ark_ec::models::mnt4::{MNT4Parameters, MNT4}; +use ark_ec::models::mnt4::{MNT4Config, MNT4}; use ark_ff::{ biginteger::{BigInt, BigInteger768}, Field, Fp2, MontFp,@@ -17,11 +17,11 @@ g1::{G1Affine, G1Prepared, G1Projective},
g2::{G2Affine, G2Prepared, G2Projective}, }; -pub type MNT4_753 = MNT4<Parameters>; +pub type MNT4_753 = MNT4<Config>; -pub struct Parameters; +pub struct Config; -impl MNT4Parameters for Parameters { +impl MNT4Config for Config { const TWIST: Fp2<Self::Fp2Config> = Fp2::new(Fq::ZERO, Fq::ONE); // A coefficient of MNT4-753 G2 = // ```@@ -69,8 +69,8 @@ type Fp = Fq;
type Fr = Fr; type Fp2Config = Fq2Config; type Fp4Config = Fq4Config; - type G1Parameters = self::g1::Parameters; - type G2Parameters = self::g2::Parameters; + type G1Config = self::g1::Config; + type G2Config = self::g2::Config; } // 26
@@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt6; -use crate::Parameters; +use crate::Config; /// An element of G1 in the MNT6-298 bilinear group. -pub type G1Var = mnt6::G1Var<Parameters>; +pub type G1Var = mnt6::G1Var<Config>; /// An element of G2 in the MNT6-298 bilinear group. -pub type G2Var = mnt6::G2Var<Parameters>; +pub type G2Var = mnt6::G2Var<Config>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. -pub type G1PreparedVar = mnt6::G1PreparedVar<Parameters>; +pub type G1PreparedVar = mnt6::G1PreparedVar<Config>; /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. -pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>; +pub type G2PreparedVar = mnt6::G2PreparedVar<Config>; #[test] fn test() { - use ark_ec::models::mnt6::MNT6Parameters; - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT6Parameters>::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT6Parameters>::G2Parameters, - G2Var, - >() - .unwrap(); + use ark_ec::models::mnt6::MNT6Config; + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G1Config, G1Var>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G2Config, G2Var>() + .unwrap(); }
@@ -1,8 +1,8 @@
-use crate::Parameters; +use crate::Config; /// Specifies the constraints for computing a pairing in the MNT6-298 bilinear /// group. -pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Parameters>; +pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Config>; #[test] fn test() {
@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; -pub type G1Affine = mnt6::G1Affine<crate::Parameters>; -pub type G1Projective = mnt6::G1Projective<crate::Parameters>; -pub type G1Prepared = mnt6::G1Prepared<crate::Parameters>; +pub type G1Affine = mnt6::G1Affine<crate::Config>; +pub type G1Projective = mnt6::G1Projective<crate::Config>; +pub type G1Prepared = mnt6::G1Prepared<crate::Config>; #[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 @@ /// COFACTOR^(-1) mod r = 1
const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 11 const COEFF_A: Fq = MontFp!("11");
@@ -1,20 +1,20 @@
use ark_ec::{ mnt6, - mnt6::MNT6Parameters, + mnt6::MNT6Config, models::{short_weierstrass::SWCurveConfig, CurveConfig}, }; use ark_ff::{Field, MontFp}; use crate::{g1, Fq, Fq3, Fr}; -pub type G2Affine = mnt6::G2Affine<crate::Parameters>; -pub type G2Projective = mnt6::G2Projective<crate::Parameters>; -pub type G2Prepared = mnt6::G2Prepared<crate::Parameters>; +pub type G2Affine = mnt6::G2Affine<crate::Config>; +pub type G2Projective = mnt6::G2Projective<crate::Config>; +pub type G2Prepared = mnt6::G2Prepared<crate::Config>; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq3; type ScalarField = Fr;@@ -48,10 +48,10 @@ /// MUL_BY_A_C1 = NONRESIDUE * COEFF_A
pub const MUL_BY_A_C1: Fq = MontFp!("55"); /// MUL_BY_A_C2 = COEFF_A -pub const MUL_BY_A_C2: Fq = g1::Parameters::COEFF_A; +pub const MUL_BY_A_C2: Fq = g1::Config::COEFF_A; -impl SWCurveConfig for Parameters { - const COEFF_A: Fq3 = crate::Parameters::TWIST_COEFF_A; +impl SWCurveConfig for Config { + const COEFF_A: Fq3 = crate::Config::TWIST_COEFF_A; const COEFF_B: Fq3 = Fq3::new( // 5 * G1::COEFF_B MontFp!("57578116384997352636487348509878309737146377454014423897662211075515354005624851787652233"),
@@ -1,5 +1,5 @@
use ark_ec::{ - models::mnt6::{MNT6Parameters, MNT6}, + models::mnt6::{MNT6Config, MNT6}, short_weierstrass::SWCurveConfig, }; use ark_ff::{biginteger::BigInteger320, BigInt, Field, Fp3};@@ -17,14 +17,14 @@ g1::{G1Affine, G1Prepared, G1Projective},
g2::{G2Affine, G2Prepared, G2Projective}, }; -pub type MNT6_298 = MNT6<Parameters>; +pub type MNT6_298 = MNT6<Config>; -pub struct Parameters; +pub struct Config; -impl MNT6Parameters for Parameters { +impl MNT6Config for Config { const TWIST: Fp3<Self::Fp3Config> = Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ONE, Fq::ZERO); const TWIST_COEFF_A: Fp3<Self::Fp3Config> = - Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ZERO, g1::Parameters::COEFF_A); + Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A); // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4_80.ml#L88 const ATE_LOOP_COUNT: &'static [i8] = &[@@ -44,6 +44,6 @@ type Fp = Fq;
type Fr = Fr; type Fp3Config = Fq3Config; type Fp6Config = Fq6Config; - type G1Parameters = self::g1::Parameters; - type G2Parameters = self::g2::Parameters; + type G1Config = self::g1::Config; + type G2Config = self::g2::Config; }
@@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt6; -use crate::Parameters; +use crate::Config; /// An element of G1 in the MNT6-753 bilinear group. -pub type G1Var = mnt6::G1Var<Parameters>; +pub type G1Var = mnt6::G1Var<Config>; /// An element of G2 in the MNT6-753 bilinear group. -pub type G2Var = mnt6::G2Var<Parameters>; +pub type G2Var = mnt6::G2Var<Config>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. -pub type G1PreparedVar = mnt6::G1PreparedVar<Parameters>; +pub type G1PreparedVar = mnt6::G1PreparedVar<Config>; /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. -pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>; +pub type G2PreparedVar = mnt6::G2PreparedVar<Config>; #[test] fn test() { - use ark_ec::models::mnt6::MNT6Parameters; - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT6Parameters>::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - <Parameters as MNT6Parameters>::G2Parameters, - G2Var, - >() - .unwrap(); + use ark_ec::models::mnt6::MNT6Config; + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G1Config, G1Var>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G2Config, G2Var>() + .unwrap(); }
@@ -1,8 +1,8 @@
-use crate::Parameters; +use crate::Config; /// Specifies the constraints for computing a pairing in the MNT6-753 bilinear /// group. -pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Parameters>; +pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Config>; #[test] fn test() {
@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; -pub type G1Affine = mnt6::G1Affine<crate::Parameters>; -pub type G1Projective = mnt6::G1Projective<crate::Parameters>; -pub type G1Prepared = mnt6::G1Prepared<crate::Parameters>; +pub type G1Affine = mnt6::G1Affine<crate::Config>; +pub type G1Projective = mnt6::G1Projective<crate::Config>; +pub type G1Prepared = mnt6::G1Prepared<crate::Config>; #[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 @@ /// COFACTOR^(-1) mod r = 1
const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 11 const COEFF_A: Fq = MontFp!("11");
@@ -1,20 +1,20 @@
use ark_ec::{ mnt6, - mnt6::MNT6Parameters, + mnt6::MNT6Config, models::{short_weierstrass::SWCurveConfig, CurveConfig}, }; use ark_ff::{Field, MontFp}; use crate::{g1, Fq, Fq3, Fr}; -pub type G2Affine = mnt6::G2Affine<crate::Parameters>; -pub type G2Projective = mnt6::G2Projective<crate::Parameters>; -pub type G2Prepared = mnt6::G2Prepared<crate::Parameters>; +pub type G2Affine = mnt6::G2Affine<crate::Config>; +pub type G2Projective = mnt6::G2Projective<crate::Config>; +pub type G2Prepared = mnt6::G2Prepared<crate::Config>; #[derive(Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq3; type ScalarField = Fr;@@ -64,10 +64,10 @@ /// = 121
pub const MUL_BY_A_C1: Fq = MontFp!("121"); /// MUL_BY_A_C2 = COEFF_A -pub const MUL_BY_A_C2: Fq = g1::Parameters::COEFF_A; +pub const MUL_BY_A_C2: Fq = g1::Config::COEFF_A; -impl SWCurveConfig for Parameters { - const COEFF_A: Fq3 = crate::Parameters::TWIST_COEFF_A; +impl SWCurveConfig for Config { + const COEFF_A: Fq3 = crate::Config::TWIST_COEFF_A; // B coefficient of MNT6-753 G2 = // ``` // mnt6753_twist_coeff_b = mnt6753_Fq3(mnt6753_G1::coeff_b * mnt6753_Fq3::non_residue,
@@ -1,5 +1,5 @@
use ark_ec::models::{ - mnt6::{MNT6Parameters, MNT6}, + mnt6::{MNT6Config, MNT6}, short_weierstrass::SWCurveConfig, }; use ark_ff::{biginteger::BigInteger768, BigInt, Field, Fp3};@@ -17,11 +17,11 @@ g1::{G1Affine, G1Prepared, G1Projective},
g2::{G2Affine, G2Prepared, G2Projective}, }; -pub type MNT6_753 = MNT6<Parameters>; +pub type MNT6_753 = MNT6<Config>; -pub struct Parameters; +pub struct Config; -impl MNT6Parameters for Parameters { +impl MNT6Config for Config { const TWIST: Fp3<Self::Fp3Config> = Fp3::new(Fq::ZERO, Fq::ONE, Fq::ZERO); // A coefficient of MNT6-753 G2 = // ```@@ -29,8 +29,7 @@ // mnt6753_twist_coeff_a = mnt6753_Fq3(mnt6753_Fq::zero(), mnt6753_Fq::zero(),
// mnt6753_G1::coeff_a); // = (ZERO, ZERO, A_COEFF); // ``` - const TWIST_COEFF_A: Fp3<Self::Fp3Config> = - Fp3::new(Fq::ZERO, Fq::ZERO, g1::Parameters::COEFF_A); + const TWIST_COEFF_A: Fp3<Self::Fp3Config> = Fp3::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A); // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6753.ml const ATE_LOOP_COUNT: &'static [i8] = &[@@ -71,6 +70,6 @@ type Fp = Fq;
type Fr = Fr; type Fp3Config = Fq3Config; type Fp6Config = Fq6Config; - type G1Parameters = self::g1::Parameters; - type G2Parameters = self::g2::Parameters; + type G1Config = self::g1::Config; + type G2Config = self::g2::Config; }
@@ -3,9 +3,9 @@
use crate::{constraints::FBaseVar, *}; /// A group element in the Pallas prime-order group. -pub type GVar = ProjectiveVar<PallasParameters, FBaseVar>; +pub type GVar = ProjectiveVar<PallasConfig, FBaseVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::sw_test::<PallasParameters, GVar>().unwrap(); + ark_curve_constraint_tests::curves::sw_test::<PallasConfig, GVar>().unwrap(); }
@@ -10,9 +10,9 @@ #[cfg(test)]
mod tests; #[derive(Copy, Clone, Default, PartialEq, Eq)] -pub struct PallasParameters; +pub struct PallasConfig; -impl CurveConfig for PallasParameters { +impl CurveConfig for PallasConfig { type BaseField = Fq; type ScalarField = Fr;@@ -23,10 +23,10 @@ /// COFACTOR_INV = 1
const COFACTOR_INV: Fr = Fr::ONE; } -pub type Affine = sw::Affine<PallasParameters>; -pub type Projective = sw::Projective<PallasParameters>; +pub type Affine = sw::Affine<PallasConfig>; +pub type Projective = sw::Projective<PallasConfig>; -impl SWCurveConfig for PallasParameters { +impl SWCurveConfig for PallasConfig { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;
@@ -2,9 +2,9 @@ use crate::{constraints::FqVar, *};
use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar; /// A group element in the secp256k1 curve. -pub type GVar = ProjectiveVar<Parameters, FqVar>; +pub type GVar = ProjectiveVar<Config, FqVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::sw_test::<Parameters, GVar>().unwrap(); + ark_curve_constraint_tests::curves::sw_test::<Config, GVar>().unwrap(); }
@@ -9,13 +9,13 @@
#[cfg(test)] mod tests; -pub type Affine = sw::Affine<Parameters>; -pub type Projective = sw::Projective<Parameters>; +pub type Affine = sw::Affine<Config>; +pub type Projective = sw::Projective<Config>; #[derive(Copy, Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq; type ScalarField = Fr;@@ -27,7 +27,7 @@ #[rustfmt::skip]
const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;
@@ -2,9 +2,9 @@ use crate::{constraints::FqVar, *};
use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar; /// A group element in the secq256k1 curve. -pub type GVar = ProjectiveVar<Parameters, FqVar>; +pub type GVar = ProjectiveVar<Config, FqVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::sw_test::<Parameters, GVar>().unwrap(); + ark_curve_constraint_tests::curves::sw_test::<Config, GVar>().unwrap(); }
@@ -9,13 +9,13 @@
#[cfg(test)] mod tests; -pub type Affine = sw::Affine<Parameters>; -pub type Projective = sw::Projective<Parameters>; +pub type Affine = sw::Affine<Config>; +pub type Projective = sw::Projective<Config>; #[derive(Copy, Clone, Default, PartialEq, Eq)] -pub struct Parameters; +pub struct Config; -impl CurveConfig for Parameters { +impl CurveConfig for Config { type BaseField = Fq; type ScalarField = Fr;@@ -27,7 +27,7 @@ #[rustfmt::skip]
const COFACTOR_INV: Fr = Fr::ONE; } -impl SWCurveConfig for Parameters { +impl SWCurveConfig for Config { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;
@@ -3,9 +3,9 @@
use crate::{constraints::FBaseVar, *}; /// A group element in the Vesta prime-order group. -pub type GVar = ProjectiveVar<VestaParameters, FBaseVar>; +pub type GVar = ProjectiveVar<VestaConfig, FBaseVar>; #[test] fn test() { - ark_curve_constraint_tests::curves::sw_test::<VestaParameters, GVar>().unwrap(); + ark_curve_constraint_tests::curves::sw_test::<VestaConfig, GVar>().unwrap(); }
@@ -9,9 +9,9 @@ #[cfg(test)]
mod tests; #[derive(Copy, Clone, Default, PartialEq, Eq)] -pub struct VestaParameters; +pub struct VestaConfig; -impl CurveConfig for VestaParameters { +impl CurveConfig for VestaConfig { type BaseField = Fq; type ScalarField = Fr;@@ -22,10 +22,10 @@ /// COFACTOR_INV = 1
const COFACTOR_INV: Fr = Fr::ONE; } -pub type Affine = sw::Affine<VestaParameters>; -pub type Projective = sw::Projective<VestaParameters>; +pub type Affine = sw::Affine<VestaConfig>; +pub type Projective = sw::Projective<VestaConfig>; -impl SWCurveConfig for VestaParameters { +impl SWCurveConfig for VestaConfig { /// COEFF_A = 0 const COEFF_A: Fq = Fq::ZERO;