Browse Source

Rename all `*Parameters` to `*Config` (#136)

* Rename all `*Parameters` to `*Config`

* Tweak
cherry-pick
Pratyush Mishra 2 years ago
committed by GitHub
parent
commit
febd7635fb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 382 additions and 414 deletions
  1. +1
    -0
      Cargo.toml
  2. +14
    -20
      bls12_377/src/constraints/curves.rs
  3. +2
    -2
      bls12_377/src/constraints/pairing.rs
  4. +10
    -10
      bls12_377/src/curves/g1.rs
  5. +5
    -5
      bls12_377/src/curves/g2.rs
  6. +10
    -10
      bls12_377/src/curves/mod.rs
  7. +13
    -13
      bls12_381/src/curves/g1.rs
  8. +17
    -17
      bls12_381/src/curves/g2.rs
  9. +6
    -6
      bls12_381/src/curves/mod.rs
  10. +5
    -7
      bls12_381/src/curves/util.rs
  11. +4
    -4
      bn254/src/curves/g1.rs
  12. +4
    -4
      bn254/src/curves/g2.rs
  13. +10
    -10
      bn254/src/curves/mod.rs
  14. +5
    -5
      bw6_761/src/curves/g1.rs
  15. +5
    -5
      bw6_761/src/curves/g2.rs
  16. +10
    -10
      bw6_761/src/curves/mod.rs
  17. +5
    -5
      cp6_782/src/curves/g1.rs
  18. +5
    -5
      cp6_782/src/curves/g2.rs
  19. +1
    -1
      cp6_782/src/curves/mod.rs
  20. +2
    -2
      ed25519/src/constraints/curves.rs
  21. +8
    -8
      ed25519/src/curves/mod.rs
  22. +2
    -2
      ed_on_bls12_377/src/constraints/curves.rs
  23. +8
    -8
      ed_on_bls12_377/src/curves/mod.rs
  24. +2
    -2
      ed_on_bls12_381/src/constraints/curves.rs
  25. +13
    -13
      ed_on_bls12_381/src/curves/mod.rs
  26. +3
    -3
      ed_on_bls12_381_bandersnatch/src/constraints/curves.rs
  27. +13
    -13
      ed_on_bls12_381_bandersnatch/src/curves/mod.rs
  28. +1
    -1
      ed_on_bn254/src/constraints/curves.rs
  29. +8
    -8
      ed_on_bn254/src/curves/mod.rs
  30. +2
    -2
      ed_on_cp6_782/src/constraints/curves.rs
  31. +8
    -8
      ed_on_cp6_782/src/curves/mod.rs
  32. +2
    -2
      ed_on_mnt4_298/src/constraints/curves.rs
  33. +8
    -8
      ed_on_mnt4_298/src/curves/mod.rs
  34. +2
    -2
      ed_on_mnt4_753/src/constraints/curves.rs
  35. +8
    -8
      ed_on_mnt4_753/src/curves/mod.rs
  36. +10
    -16
      mnt4_298/src/constraints/curves.rs
  37. +2
    -2
      mnt4_298/src/constraints/pairing.rs
  38. +6
    -6
      mnt4_298/src/curves/g1.rs
  39. +8
    -8
      mnt4_298/src/curves/g2.rs
  40. +6
    -6
      mnt4_298/src/curves/mod.rs
  41. +10
    -16
      mnt4_753/src/constraints/curves.rs
  42. +2
    -2
      mnt4_753/src/constraints/pairing.rs
  43. +6
    -6
      mnt4_753/src/curves/g1.rs
  44. +8
    -8
      mnt4_753/src/curves/g2.rs
  45. +6
    -6
      mnt4_753/src/curves/mod.rs
  46. +10
    -16
      mnt6_298/src/constraints/curves.rs
  47. +2
    -2
      mnt6_298/src/constraints/pairing.rs
  48. +6
    -6
      mnt6_298/src/curves/g1.rs
  49. +9
    -9
      mnt6_298/src/curves/g2.rs
  50. +7
    -7
      mnt6_298/src/curves/mod.rs
  51. +10
    -16
      mnt6_753/src/constraints/curves.rs
  52. +2
    -2
      mnt6_753/src/constraints/pairing.rs
  53. +6
    -6
      mnt6_753/src/curves/g1.rs
  54. +9
    -9
      mnt6_753/src/curves/g2.rs
  55. +7
    -8
      mnt6_753/src/curves/mod.rs
  56. +2
    -2
      pallas/src/constraints/curves.rs
  57. +5
    -5
      pallas/src/curves/mod.rs
  58. +2
    -2
      secp256k1/src/constraints/curves.rs
  59. +5
    -5
      secp256k1/src/curves/mod.rs
  60. +2
    -2
      secq256k1/src/constraints/curves.rs
  61. +5
    -5
      secq256k1/src/curves/mod.rs
  62. +2
    -2
      vesta/src/constraints/curves.rs
  63. +5
    -5
      vesta/src/curves/mod.rs

+ 1
- 0
Cargo.toml

@ -65,5 +65,6 @@ debug = true
[patch.crates-io] [patch.crates-io]
ark-ff = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } 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-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" } ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" }

+ 14
- 20
bls12_377/src/constraints/curves.rs

@ -1,45 +1,39 @@
use ark_ec::{bls12::Bls12Parameters, CurveConfig};
use ark_ec::{bls12::Bls12Config, CurveConfig};
use ark_r1cs_std::{ use ark_r1cs_std::{
fields::fp::FpVar, fields::fp::FpVar,
groups::{bls12, curves::twisted_edwards::AffineVar as TEAffineVar}, groups::{bls12, curves::twisted_edwards::AffineVar as TEAffineVar},
}; };
use crate::Parameters;
use crate::Config;
/// An element of G1 in the BLS12-377 bilinear group. /// 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. /// 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. /// An element of G1 (in TE Affine form) in the BLS12-377 bilinear group.
pub type G1TEAffineVar = TEAffineVar< 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// 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 /// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
pub type G2PreparedVar = bls12::G2PreparedVar<Parameters>;
pub type G2PreparedVar = bls12::G2PreparedVar<Config>;
#[test] #[test]
fn 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::< ark_curve_constraint_tests::curves::te_test::<
<Parameters as Bls12Parameters>::G1Parameters,
<Config as Bls12Config>::G1Config,
G1TEAffineVar, G1TEAffineVar,
>() >()
.unwrap(); .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();
} }

+ 2
- 2
bls12_377/src/constraints/pairing.rs

@ -1,8 +1,8 @@
use crate::Parameters;
use crate::Config;
/// Specifies the constraints for computing a pairing in the BLS12-377 bilinear /// Specifies the constraints for computing a pairing in the BLS12-377 bilinear
/// group. /// group.
pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Parameters>;
pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Config>;
#[test] #[test]
fn test() { fn test() {

+ 10
- 10
bls12_377/src/curves/g1.rs

@ -11,9 +11,9 @@ use core::ops::Neg;
use crate::{Fq, Fr}; use crate::{Fq, Fr};
#[derive(Clone, Default, PartialEq, Eq)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -25,7 +25,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = MontFp!("5285428838741532253824584287042945485047145357130994810877"); const COFACTOR_INV: Fr = MontFp!("5285428838741532253824584287042945485047145357130994810877");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 0 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;
@ -41,9 +41,9 @@ impl SWCurveConfig for Parameters {
} }
} }
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. /// Bls12_377::G1 also has a twisted Edwards form.
/// It can be obtained via the following script, implementing /// It can be obtained via the following script, implementing
@ -92,7 +92,7 @@ pub type G1TEProjective = TEProjective;
/// # b = -TE1d/TE1a /// # b = -TE1d/TE1a
/// TE2d = Fp(122268283598675559488486339158635529096981886914877139579534153582033676785385790730042363341236035746924960903179) /// TE2d = Fp(122268283598675559488486339158635529096981886914877139579534153582033676785385790730042363341236035746924960903179)
/// ``` /// ```
impl TECurveConfig for Parameters {
impl TECurveConfig for Config {
/// COEFF_A = -1 /// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1"); const COEFF_A: Fq = MontFp!("-1");
@ -102,7 +102,7 @@ impl TECurveConfig for Parameters {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) /// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: G1TEAffine = G1TEAffine::new_unchecked(TE_GENERATOR_X, TE_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`. /// Multiplication by `a` is multiply by `-1`.
#[inline(always)] #[inline(always)]
@ -140,14 +140,14 @@ impl TECurveConfig for Parameters {
// # MB = s // # MB = s
// MB=Fp(10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931) // MB=Fp(10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931)
// ``` // ```
impl MontCurveConfig for Parameters {
impl MontCurveConfig for Config {
/// COEFF_A = 228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384 /// COEFF_A = 228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384
const COEFF_A: Fq = MontFp!("228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384"); const COEFF_A: Fq = MontFp!("228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384");
/// COEFF_B = 10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931 /// COEFF_B = 10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931
const COEFF_B: Fq = MontFp!("10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931"); const COEFF_B: Fq = MontFp!("10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931");
type TECurveConfig = Parameters;
type TECurveConfig = Config;
} }
/// G1_GENERATOR_X = /// G1_GENERATOR_X =

+ 5
- 5
bls12_377/src/curves/g2.rs

@ -6,11 +6,11 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{g1, Fq, Fq2, Fr}; use crate::{g1, Fq, Fq2, Fr};
pub type G2Affine = Affine<Parameters>;
pub type G2Affine = Affine<Config>;
#[derive(Clone, Default, PartialEq, Eq)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq2; type BaseField = Fq2;
type ScalarField = Fr; type ScalarField = Fr;
@ -34,9 +34,9 @@ impl CurveConfig for Parameters {
MontFp!("6764900296503390671038341982857278410319949526107311149686707033187604810669"); MontFp!("6764900296503390671038341982857278410319949526107311149686707033187604810669");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = [0, 0] /// 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, // 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 // this curve has b' = b/i, where b is the COEFF_B of G1, and x^6 -i is

+ 10
- 10
bls12_377/src/curves/mod.rs

@ -1,6 +1,6 @@
use ark_ec::{ use ark_ec::{
bls12, bls12,
bls12::{Bls12, Bls12Parameters, TwistType},
bls12::{Bls12, Bls12Config, TwistType},
}; };
use crate::*; use crate::*;
@ -11,9 +11,9 @@ pub mod g2;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
pub struct Parameters;
pub struct Config;
impl Bls12Parameters for Parameters {
impl Bls12Config for Config {
const X: &'static [u64] = &[0x8508c00000000001]; const X: &'static [u64] = &[0x8508c00000000001];
/// `x` is positive. /// `x` is positive.
const X_IS_NEGATIVE: bool = false; const X_IS_NEGATIVE: bool = false;
@ -22,15 +22,15 @@ impl Bls12Parameters for Parameters {
type Fp2Config = Fq2Config; type Fp2Config = Fq2Config;
type Fp6Config = Fq6Config; type Fp6Config = Fq6Config;
type Fp12Config = Fq12Config; 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}; pub use g1::{G1TEAffine, G1TEProjective};

+ 13
- 13
bls12_381/src/curves/g1.rs

@ -1,7 +1,7 @@
use crate::*; use crate::*;
use ark_ec::{ use ark_ec::{
bls12, bls12,
bls12::Bls12Parameters,
bls12::Bls12Config,
models::CurveConfig, models::CurveConfig,
short_weierstrass::{Affine, SWCurveConfig}, short_weierstrass::{Affine, SWCurveConfig},
AffineRepr, Group, AffineRepr, Group,
@ -14,13 +14,13 @@ use crate::util::{
read_g1_compressed, read_g1_uncompressed, serialize_fq, EncodingFlags, G1_SERIALIZED_SIZE, 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -33,7 +33,7 @@ impl CurveConfig for Parameters {
MontFp!("52435875175126190458656871551744051925719901746859129887267498875565241663483"); MontFp!("52435875175126190458656871551744051925719901746859129887267498875565241663483");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 0 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;
@ -57,12 +57,12 @@ impl SWCurveConfig for Parameters {
// An early-out optimization described in Section 6. // An early-out optimization described in Section 6.
// If uP == P but P != point of infinity, then the point is not in the right // If uP == P but P != point of infinity, then the point is not in the right
// subgroup. // subgroup.
let x_times_p = p.mul_bigint(crate::Parameters::X);
let x_times_p = p.mul_bigint(crate::Config::X);
if x_times_p.eq(p) && !p.infinity { if x_times_p.eq(p) && !p.infinity {
return false; return false;
} }
let minus_x_squared_times_p = x_times_p.mul_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); let endomorphism_p = endomorphism(p);
minus_x_squared_times_p.eq(&endomorphism_p) minus_x_squared_times_p.eq(&endomorphism_p)
} }
@ -74,7 +74,7 @@ impl SWCurveConfig for Parameters {
// //
// It is enough to multiply by (1 - x), instead of (x - 1)^2 / 3 // It is enough to multiply by (1 - x), instead of (x - 1)^2 / 3
let h_eff = one_minus_x().into_bigint(); 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>( fn deserialize_with_mode<R: ark_serialize::Read>(
@ -139,7 +139,7 @@ impl SWCurveConfig for Parameters {
} }
fn one_minus_x() -> Fr { 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 Fr::one() - X
} }
@ -154,7 +154,7 @@ pub const G1_GENERATOR_Y: Fq = MontFp!("1339506544944476473020471379941921221584
/// BETA is a non-trivial cubic root of unity in Fq. /// BETA is a non-trivial cubic root of unity in Fq.
pub const BETA: Fq = MontFp!("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"); 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 of the points on the curve.
// endomorphism_p(x,y) = (BETA * x, y) // endomorphism_p(x,y) = (BETA * x, y)
// where BETA is a non-trivial cubic root of unity in Fq. // where BETA is a non-trivial cubic root of unity in Fq.
@ -169,7 +169,7 @@ mod test {
use super::*; use super::*;
use ark_std::{rand::Rng, UniformRand}; 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(); let mut rng = ark_std::test_rng();
loop { loop {
let x = Fq::rand(&mut rng); let x = Fq::rand(&mut rng);
@ -185,7 +185,7 @@ mod test {
fn test_cofactor_clearing() { fn test_cofactor_clearing() {
const SAMPLES: usize = 100; const SAMPLES: usize = 100;
for _ in 0..SAMPLES { for _ in 0..SAMPLES {
let p: Affine<g1::Parameters> = sample_unchecked();
let p: Affine<g1::Config> = sample_unchecked();
let p = p.clear_cofactor(); let p = p.clear_cofactor();
assert!(p.is_on_curve()); assert!(p.is_on_curve());
assert!(p.is_in_correct_subgroup_assuming_on_curve()); assert!(p.is_in_correct_subgroup_assuming_on_curve());

+ 17
- 17
bls12_381/src/curves/g2.rs

@ -2,7 +2,7 @@ use ark_std::ops::Neg;
use ark_ec::{ use ark_ec::{
bls12, bls12,
bls12::Bls12Parameters,
bls12::Bls12Config,
models::CurveConfig, models::CurveConfig,
short_weierstrass::{Affine, Projective, SWCurveConfig}, short_weierstrass::{Affine, Projective, SWCurveConfig},
AffineRepr, CurveGroup, Group, AffineRepr, CurveGroup, Group,
@ -16,13 +16,13 @@ use crate::{
*, *,
}; };
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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq2; type BaseField = Fq2;
type ScalarField = Fr; type ScalarField = Fr;
@ -47,12 +47,12 @@ impl CurveConfig for Parameters {
MontFp!("26652489039290660355457965112010883481355318854675681319708643586776743290055"); MontFp!("26652489039290660355457965112010883481355318854675681319708643586776743290055");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = [0, 0] /// 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] /// 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) /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y);
@ -67,8 +67,8 @@ impl SWCurveConfig for Parameters {
// //
// Checks that [p]P = [X]P // 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; x_times_point = -x_times_point;
} }
@ -86,11 +86,11 @@ impl SWCurveConfig for Parameters {
// When multiplying, use -c1 instead, and then negate the result. That's much // 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 // more efficient, since the scalar -c1 has less limbs and a much lower Hamming
// weight. // weight.
let x: &'static [u64] = crate::Parameters::X;
let x: &'static [u64] = crate::Config::X;
let p_projective = p.into_group(); let p_projective = p.into_group();
// [x]P // [x]P
let x_p = Parameters::mul_affine(p, &x).neg();
let x_p = Config::mul_affine(p, &x).neg();
// ψ(P) // ψ(P)
let psi_p = p_power_endomorphism(&p); let psi_p = p_power_endomorphism(&p);
// (ψ^2)(2P) // (ψ^2)(2P)
@ -101,7 +101,7 @@ impl SWCurveConfig for Parameters {
tmp += &psi_p; tmp += &psi_p;
// tmp2 = [x^2]P + [x]ψ(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(); tmp2 = tmp2.mul_bigint(x).neg();
// add up all the terms // add up all the terms
@ -224,7 +224,7 @@ pub const DOUBLE_P_POWER_ENDOMORPHISM: Fq2 = Fq2::new(
Fq::ZERO 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: // 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). // 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, // To map a point (x, y) in E' to (s, t) in E,
@ -252,7 +252,7 @@ pub fn p_power_endomorphism(p: &Affine) -> Affine {
} }
/// For a p-power endomorphism psi(P), compute psi(psi(P)) /// 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; let mut res = *p;
res.x *= DOUBLE_P_POWER_ENDOMORPHISM; res.x *= DOUBLE_P_POWER_ENDOMORPHISM;
@ -287,9 +287,9 @@ mod test {
let mut rng = ark_std::test_rng(); let mut rng = ark_std::test_rng();
const SAMPLES: usize = 10; const SAMPLES: usize = 10;
for _ in 0..SAMPLES { 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 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); assert_eq!(optimised, naive);
} }
} }

+ 6
- 6
bls12_381/src/curves/mod.rs

@ -1,4 +1,4 @@
use ark_ec::bls12::{Bls12, Bls12Parameters, TwistType};
use ark_ec::bls12::{Bls12, Bls12Config, TwistType};
use crate::{Fq, Fq12Config, Fq2Config, Fq6Config}; use crate::{Fq, Fq12Config, Fq2Config, Fq6Config};
@ -14,11 +14,11 @@ pub use self::{
g2::{G2Affine, G2Projective}, 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: &'static [u64] = &[0xd201000000010000];
const X_IS_NEGATIVE: bool = true; const X_IS_NEGATIVE: bool = true;
const TWIST_TYPE: TwistType = TwistType::M; const TWIST_TYPE: TwistType = TwistType::M;
@ -26,6 +26,6 @@ impl Bls12Parameters for Parameters {
type Fp2Config = Fq2Config; type Fp2Config = Fq2Config;
type Fp6Config = Fq6Config; type Fp6Config = Fq6Config;
type Fp12Config = Fq12Config; type Fp12Config = Fq12Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
} }

+ 5
- 7
bls12_381/src/curves/util.rs

@ -2,9 +2,7 @@ use ark_ec::{short_weierstrass::Affine, AffineRepr};
use ark_ff::{BigInteger384, PrimeField}; use ark_ff::{BigInteger384, PrimeField};
use ark_serialize::SerializationError; 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 G1_SERIALIZED_SIZE: usize = 48;
pub const G2_SERIALIZED_SIZE: usize = 96; pub const G2_SERIALIZED_SIZE: usize = 96;
@ -91,7 +89,7 @@ pub(crate) fn read_fq_with_offset(
pub(crate) fn read_g1_compressed<R: ark_serialize::Read>( pub(crate) fn read_g1_compressed<R: ark_serialize::Read>(
mut reader: R, mut reader: R,
) -> Result<Affine<G1Parameters>, ark_serialize::SerializationError> {
) -> Result<Affine<G1Config>, ark_serialize::SerializationError> {
let mut bytes = [0u8; G1_SERIALIZED_SIZE]; let mut bytes = [0u8; G1_SERIALIZED_SIZE];
reader reader
.read_exact(&mut bytes) .read_exact(&mut bytes)
@ -121,7 +119,7 @@ pub(crate) fn read_g1_compressed(
pub(crate) fn read_g1_uncompressed<R: ark_serialize::Read>( pub(crate) fn read_g1_uncompressed<R: ark_serialize::Read>(
mut reader: R, mut reader: R,
) -> Result<Affine<G1Parameters>, ark_serialize::SerializationError> {
) -> Result<Affine<G1Config>, ark_serialize::SerializationError> {
let mut bytes = [0u8; 2 * G1_SERIALIZED_SIZE]; let mut bytes = [0u8; 2 * G1_SERIALIZED_SIZE];
reader reader
.read_exact(&mut bytes) .read_exact(&mut bytes)
@ -151,7 +149,7 @@ pub(crate) fn read_g1_uncompressed(
pub(crate) fn read_g2_compressed<R: ark_serialize::Read>( pub(crate) fn read_g2_compressed<R: ark_serialize::Read>(
mut reader: R, mut reader: R,
) -> Result<Affine<G2Parameters>, ark_serialize::SerializationError> {
) -> Result<Affine<G2Config>, ark_serialize::SerializationError> {
let mut bytes = [0u8; G2_SERIALIZED_SIZE]; let mut bytes = [0u8; G2_SERIALIZED_SIZE];
reader reader
.read_exact(&mut bytes) .read_exact(&mut bytes)
@ -183,7 +181,7 @@ pub(crate) fn read_g2_compressed(
pub(crate) fn read_g2_uncompressed<R: ark_serialize::Read>( pub(crate) fn read_g2_uncompressed<R: ark_serialize::Read>(
mut reader: R, mut reader: R,
) -> Result<Affine<G2Parameters>, ark_serialize::SerializationError> {
) -> Result<Affine<G2Config>, ark_serialize::SerializationError> {
let mut bytes = [0u8; 2 * G2_SERIALIZED_SIZE]; let mut bytes = [0u8; 2 * G2_SERIALIZED_SIZE];
reader reader
.read_exact(&mut bytes) .read_exact(&mut bytes)

+ 4
- 4
bn254/src/curves/g1.rs

@ -7,11 +7,11 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{Fq, Fr}; use crate::{Fq, Fr};
#[derive(Clone, Default, PartialEq, Eq)] #[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 BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -22,7 +22,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = Fr::ONE; const COFACTOR_INV: Fr = Fr::ONE;
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 0 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;

+ 4
- 4
bn254/src/curves/g2.rs

@ -6,12 +6,12 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{Fq, Fq2, Fr}; use crate::{Fq, Fq2, Fr};
pub type G2Affine = Affine<Parameters>;
pub type G2Affine = Affine<Config>;
#[derive(Clone, Default, PartialEq, Eq)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq2; type BaseField = Fq2;
type ScalarField = Fr; type ScalarField = Fr;
@ -30,7 +30,7 @@ impl CurveConfig for Parameters {
MontFp!("10944121435919637613327163357776759465618812564592884533313067514031822496649"); MontFp!("10944121435919637613327163357776759465618812564592884533313067514031822496649");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = [0, 0] /// COEFF_A = [0, 0]
const COEFF_A: Fq2 = Fq2::ZERO; const COEFF_A: Fq2 = Fq2::ZERO;

+ 10
- 10
bn254/src/curves/mod.rs

@ -1,6 +1,6 @@
use ark_ec::{ use ark_ec::{
bn, bn,
bn::{Bn, BnParameters, TwistType},
bn::{Bn, BnConfig, TwistType},
}; };
use ark_ff::MontFp; use ark_ff::MontFp;
@ -12,9 +12,9 @@ pub mod g2;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
pub struct Parameters;
pub struct Config;
impl BnParameters for Parameters {
impl BnConfig for Config {
const X: &'static [u64] = &[4965661367192848881]; const X: &'static [u64] = &[4965661367192848881];
/// `x` is positive. /// `x` is positive.
const X_IS_NEGATIVE: bool = false; const X_IS_NEGATIVE: bool = false;
@ -37,13 +37,13 @@ impl BnParameters for Parameters {
type Fp2Config = Fq2Config; type Fp2Config = Fq2Config;
type Fp6Config = Fq6Config; type Fp6Config = Fq6Config;
type Fp12Config = Fq12Config; 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>;

+ 5
- 5
bw6_761/src/curves/g1.rs

@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -33,7 +33,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = MontFp!("91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804"); const COFACTOR_INV: Fr = MontFp!("91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 0 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;

+ 5
- 5
bw6_761/src/curves/g2.rs

@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -33,7 +33,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = MontFp!("214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124"); const COFACTOR_INV: Fr = MontFp!("214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 0 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;

+ 10
- 10
bw6_761/src/curves/mod.rs

@ -1,6 +1,6 @@
use ark_ec::{ use ark_ec::{
bw6, bw6,
bw6::{BW6Parameters, TwistType, BW6},
bw6::{BW6Config, TwistType, BW6},
}; };
use ark_ff::{biginteger::BigInteger768 as BigInteger, BigInt}; use ark_ff::{biginteger::BigInteger768 as BigInteger, BigInt};
@ -13,9 +13,9 @@ pub mod g2;
mod tests; mod tests;
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl BW6Parameters for Parameters {
impl BW6Config for Config {
const X: BigInteger = BigInt::new([ const X: BigInteger = BigInt::new([
0x8508c00000000001, 0x8508c00000000001,
0x0, 0x0,
@ -50,13 +50,13 @@ impl BW6Parameters for Parameters {
type Fp = Fq; type Fp = Fq;
type Fp3Config = Fq3Config; type Fp3Config = Fq3Config;
type Fp6Config = Fq6Config; 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>;

+ 5
- 5
cp6_782/src/curves/g1.rs

@ -9,8 +9,8 @@ use ark_std::vec::Vec;
use crate::{Fq, Fr}; 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)] #[derive(Clone, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct G1Prepared(pub G1Affine); pub struct G1Prepared(pub G1Affine);
@ -52,9 +52,9 @@ impl Default for G1Prepared {
} }
#[derive(Clone, Default, PartialEq, Eq)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -76,7 +76,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = MontFp!("163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788"); const COFACTOR_INV: Fr = MontFp!("163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788");
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 5 /// COEFF_A = 5
const COEFF_A: Fq = MontFp!("5"); const COEFF_A: Fq = MontFp!("5");

+ 5
- 5
cp6_782/src/curves/g2.rs

@ -9,8 +9,8 @@ use ark_std::vec::Vec;
use crate::{Fq, Fq3, Fr}; 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)] #[derive(Clone, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct G2Prepared(pub G2Affine); pub struct G2Prepared(pub G2Affine);
@ -52,9 +52,9 @@ impl Default for G2Prepared {
} }
#[derive(Clone, Default, PartialEq, Eq)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq3; type BaseField = Fq3;
type ScalarField = Fr; type ScalarField = Fr;
@ -100,7 +100,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = MontFp!("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) /// COEFF_A = (0, 0, COEFF_A * TWIST^2) = (0, 0, 5)
const COEFF_A: Fq3 = Fq3::new(Fq::ZERO, Fq::ZERO, MontFp!("5")); const COEFF_A: Fq3 = Fq3::new(Fq::ZERO, Fq::ZERO, MontFp!("5"));

+ 1
- 1
cp6_782/src/curves/mod.rs

@ -78,7 +78,7 @@ impl CP6_782 {
let old_rx_square = old_rx.square(); let old_rx_square = old_rx.square();
let old_rx_square_3 = old_rx_square.double() + &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 old_ry_double_inverse = old_ry.double().inverse().unwrap();
let gamma = old_rx_square_3_a * &old_ry_double_inverse; let gamma = old_rx_square_3_a * &old_ry_double_inverse;

+ 2
- 2
ed25519/src/constraints/curves.rs

@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *}; use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
} }

+ 8
- 8
ed25519/src/curves/mod.rs

@ -8,13 +8,13 @@ use ark_ff::MontFp;
#[cfg(test)] #[cfg(test)]
mod tests; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsParameters;
pub struct EdwardsConfig;
impl CurveConfig for EdwardsParameters {
impl CurveConfig for EdwardsConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -27,7 +27,7 @@ impl CurveConfig for EdwardsParameters {
MontFp!("2713877091499598330239944961141122840321418634767465352250731601857045344121"); MontFp!("2713877091499598330239944961141122840321418634767465352250731601857045344121");
} }
impl TECurveConfig for EdwardsParameters {
impl TECurveConfig for EdwardsConfig {
/// COEFF_A = -1 /// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1"); const COEFF_A: Fq = MontFp!("-1");
@ -38,7 +38,7 @@ impl TECurveConfig for EdwardsParameters {
/// Standard generators from <https://neuromancer.sk/std/other/Ed25519>. /// Standard generators from <https://neuromancer.sk/std/other/Ed25519>.
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(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. /// Multiplication by `a` is just negation.
#[inline(always)] #[inline(always)]
@ -48,7 +48,7 @@ impl TECurveConfig for EdwardsParameters {
} }
// We want to emphasize that this Montgomery curve is not Curve25519. // We want to emphasize that this Montgomery curve is not Curve25519.
impl MontCurveConfig for EdwardsParameters {
impl MontCurveConfig for EdwardsConfig {
/// COEFF_A = 486662 /// COEFF_A = 486662
const COEFF_A: Fq = MontFp!("486662"); const COEFF_A: Fq = MontFp!("486662");
@ -57,7 +57,7 @@ impl MontCurveConfig for EdwardsParameters {
const COEFF_B: Fq = const COEFF_B: Fq =
MontFp!("57896044618658097711785492504343953926634992332820282019728792003956564333285"); MontFp!("57896044618658097711785492504343953926634992332820282019728792003956564333285");
type TECurveConfig = EdwardsParameters;
type TECurveConfig = EdwardsConfig;
} }
/// GENERATOR_X = /// GENERATOR_X =

+ 2
- 2
ed_on_bls12_377/src/constraints/curves.rs

@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *}; use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
} }

+ 8
- 8
ed_on_bls12_377/src/curves/mod.rs

@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsParameters;
pub struct EdwardsConfig;
impl CurveConfig for EdwardsParameters {
impl CurveConfig for EdwardsConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -28,7 +28,7 @@ impl CurveConfig for EdwardsParameters {
MontFp!("527778859339273151515551558673846658209717731602102048798421311598680340096"); MontFp!("527778859339273151515551558673846658209717731602102048798421311598680340096");
} }
impl TECurveConfig for EdwardsParameters {
impl TECurveConfig for EdwardsConfig {
/// COEFF_A = -1 /// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1"); const COEFF_A: Fq = MontFp!("-1");
@ -38,7 +38,7 @@ impl TECurveConfig for EdwardsParameters {
/// Generated randomly /// Generated randomly
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(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. /// Multiplication by `a` is just negation.
/// Is `a` 1 or -1? /// Is `a` 1 or -1?
@ -48,7 +48,7 @@ impl TECurveConfig for EdwardsParameters {
} }
} }
impl MontCurveConfig for EdwardsParameters {
impl MontCurveConfig for EdwardsConfig {
/// COEFF_A = 0x8D26E3FADA9010A26949031ECE3971B93952AD84D4753DDEDB748DA37E8F552 /// COEFF_A = 0x8D26E3FADA9010A26949031ECE3971B93952AD84D4753DDEDB748DA37E8F552
/// = 3990301581132929505568273333084066329187552697088022219156688740916631500114 /// = 3990301581132929505568273333084066329187552697088022219156688740916631500114
const COEFF_A: Fq = const COEFF_A: Fq =
@ -59,7 +59,7 @@ impl MontCurveConfig for EdwardsParameters {
const COEFF_B: Fq = const COEFF_B: Fq =
MontFp!("4454160168295440918680551605697480202188346638066041608778544715000777738925"); MontFp!("4454160168295440918680551605697480202188346638066041608778544715000777738925");
type TECurveConfig = EdwardsParameters;
type TECurveConfig = EdwardsConfig;
} }
/// GENERATOR_X = /// GENERATOR_X =

+ 2
- 2
ed_on_bls12_381/src/constraints/curves.rs

@ -3,10 +3,10 @@ use ark_r1cs_std::groups::curves::{short_weierstrass::ProjectiveVar, twisted_edw
use crate::{constraints::FqVar, *}; use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. /// 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` /// A variable that is the R1CS equivalent of `crate::SWProjective`
pub type SWVar = ProjectiveVar<JubjubParameters, FqVar>;
pub type SWVar = ProjectiveVar<JubjubConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {

+ 13
- 13
ed_on_bls12_381/src/curves/mod.rs

@ -10,10 +10,10 @@ use crate::{Fq, Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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 /// `JubJub` is a twisted Edwards curve. These curves have equations of the
/// form: ax² + y² = 1 - dx²y². /// form: ax² + y² = 1 - dx²y².
@ -49,11 +49,11 @@ pub type SWProjective = short_weierstrass::Projective;
/// [here](https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/jubjub.sage) /// [here](https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/jubjub.sage)
/// to convert between the different representations. /// to convert between the different representations.
#[derive(Clone, Default, PartialEq, Eq)] #[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 BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -66,7 +66,7 @@ impl CurveConfig for JubjubParameters {
MontFp!("819310549611346726241370945440405716213240158234039660170669895299022906775"); MontFp!("819310549611346726241370945440405716213240158234039660170669895299022906775");
} }
impl TECurveConfig for JubjubParameters {
impl TECurveConfig for JubjubConfig {
/// COEFF_A = -1 /// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1"); const COEFF_A: Fq = MontFp!("-1");
@ -77,7 +77,7 @@ impl TECurveConfig for JubjubParameters {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) /// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(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. /// Multiplication by `a` is simply negation here.
#[inline(always)] #[inline(always)]
@ -86,14 +86,14 @@ impl TECurveConfig for JubjubParameters {
} }
} }
impl MontCurveConfig for JubjubParameters {
impl MontCurveConfig for JubjubConfig {
/// COEFF_A = 40962 /// COEFF_A = 40962
const COEFF_A: Fq = MontFp!("40962"); const COEFF_A: Fq = MontFp!("40962");
/// COEFF_B = -40964 /// COEFF_B = -40964
const COEFF_B: Fq = MontFp!("-40964"); const COEFF_B: Fq = MontFp!("-40964");
type TECurveConfig = JubjubParameters;
type TECurveConfig = JubjubConfig;
} }
const GENERATOR_X: Fq = const GENERATOR_X: Fq =
@ -102,7 +102,7 @@ const GENERATOR_X: Fq =
const GENERATOR_Y: Fq = const GENERATOR_Y: Fq =
MontFp!("13262374693698910701929044844600465831413122818447359594527400194675274060458"); MontFp!("13262374693698910701929044844600465831413122818447359594527400194675274060458");
impl SWCurveConfig for JubjubParameters {
impl SWCurveConfig for JubjubConfig {
/// COEFF_A = 52296097456646850916096512823759002727550416093741407922227928430486925478210 /// COEFF_A = 52296097456646850916096512823759002727550416093741407922227928430486925478210
const COEFF_A: Self::BaseField = const COEFF_A: Self::BaseField =
MontFp!("52296097456646850916096512823759002727550416093741407922227928430486925478210"); MontFp!("52296097456646850916096512823759002727550416093741407922227928430486925478210");

+ 3
- 3
ed_on_bls12_381_bandersnatch/src/constraints/curves.rs

@ -2,11 +2,11 @@ use ark_r1cs_std::groups::curves::{short_weierstrass::ProjectiveVar, twisted_edw
use crate::{constraints::FqVar, *}; 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` /// A variable that is the R1CS equivalent of `crate::SWProjective`
pub type SWVar = ProjectiveVar<BandersnatchParameters, FqVar>;
pub type SWVar = ProjectiveVar<BandersnatchConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {

+ 13
- 13
ed_on_bls12_381_bandersnatch/src/curves/mod.rs

@ -10,11 +10,11 @@ use crate::{Fq, Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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 /// `bandersnatch` is an incomplete twisted Edwards curve. These curves have
/// equations of the form: ax² + y² = 1 + dx²y². /// equations of the form: ax² + y² = 1 + dx²y².
@ -49,12 +49,12 @@ pub type SWProjective = short_weierstrass::Projective;
/// Script to transfer between different curves are available /// Script to transfer between different curves are available
/// <https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/bandersnatch.sage> /// <https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/bandersnatch.sage>
#[derive(Clone, Default, PartialEq, Eq)] #[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 BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -67,7 +67,7 @@ impl CurveConfig for BandersnatchParameters {
MontFp!("9831726595336160714896451345284868594481866920080427688839802480047265754601"); MontFp!("9831726595336160714896451345284868594481866920080427688839802480047265754601");
} }
impl TECurveConfig for BandersnatchParameters {
impl TECurveConfig for BandersnatchConfig {
/// COEFF_A = -5 /// COEFF_A = -5
const COEFF_A: Fq = MontFp!("-5"); const COEFF_A: Fq = MontFp!("-5");
@ -79,7 +79,7 @@ impl TECurveConfig for BandersnatchParameters {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) /// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(TE_GENERATOR_X, TE_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`. /// Multiplication by `a` is multiply by `-5`.
#[inline(always)] #[inline(always)]
@ -88,7 +88,7 @@ impl TECurveConfig for BandersnatchParameters {
} }
} }
impl MontCurveConfig for BandersnatchParameters {
impl MontCurveConfig for BandersnatchConfig {
/// COEFF_A = 29978822694968839326280996386011761570173833766074948509196803838190355340952 /// COEFF_A = 29978822694968839326280996386011761570173833766074948509196803838190355340952
const COEFF_A: Fq = const COEFF_A: Fq =
MontFp!("29978822694968839326280996386011761570173833766074948509196803838190355340952"); MontFp!("29978822694968839326280996386011761570173833766074948509196803838190355340952");
@ -97,7 +97,7 @@ impl MontCurveConfig for BandersnatchParameters {
const COEFF_B: Fq = const COEFF_B: Fq =
MontFp!("25465760566081946422412445027709227188579564747101592991722834452325077642517"); MontFp!("25465760566081946422412445027709227188579564747101592991722834452325077642517");
type TECurveConfig = BandersnatchParameters;
type TECurveConfig = BandersnatchConfig;
} }
// The TE form generator is generated following Zcash's fashion: // The TE form generator is generated following Zcash's fashion:
@ -125,7 +125,7 @@ const SW_GENERATOR_X: Fq =
const SW_GENERATOR_Y: Fq = const SW_GENERATOR_Y: Fq =
MontFp!("12663882780877899054958035777720958383845500985908634476792678820121468453298"); MontFp!("12663882780877899054958035777720958383845500985908634476792678820121468453298");
impl SWCurveConfig for BandersnatchParameters {
impl SWCurveConfig for BandersnatchConfig {
/// COEFF_A = 10773120815616481058602537765553212789256758185246796157495669123169359657269 /// COEFF_A = 10773120815616481058602537765553212789256758185246796157495669123169359657269
const COEFF_A: Self::BaseField = const COEFF_A: Self::BaseField =
MontFp!("10773120815616481058602537765553212789256758185246796157495669123169359657269"); MontFp!("10773120815616481058602537765553212789256758185246796157495669123169359657269");

+ 1
- 1
ed_on_bn254/src/constraints/curves.rs

@ -3,7 +3,7 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *}; use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {

+ 8
- 8
ed_on_bn254/src/curves/mod.rs

@ -9,8 +9,8 @@ use crate::{Fq, Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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 /// `Baby-JubJub` is a twisted Edwards curve. These curves have equations of the
/// form: ax² + y² = 1 + dx²y². /// form: ax² + y² = 1 + dx²y².
@ -20,9 +20,9 @@ pub type EdwardsProjective = Projective;
/// ///
/// q = 21888242871839275222246405745257275088548364400416034343698204186575808495617 /// q = 21888242871839275222246405745257275088548364400416034343698204186575808495617
#[derive(Clone, Default, PartialEq, Eq)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsParameters;
pub struct EdwardsConfig;
impl CurveConfig for EdwardsParameters {
impl CurveConfig for EdwardsConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -35,7 +35,7 @@ impl CurveConfig for EdwardsParameters {
MontFp!("2394026564107420727433200628387514462817212225638746351800188703329891451411"); MontFp!("2394026564107420727433200628387514462817212225638746351800188703329891451411");
} }
impl TECurveConfig for EdwardsParameters {
impl TECurveConfig for EdwardsConfig {
/// COEFF_A = 1 /// COEFF_A = 1
const COEFF_A: Fq = Fq::ONE; const COEFF_A: Fq = Fq::ONE;
@ -52,16 +52,16 @@ impl TECurveConfig for EdwardsParameters {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) /// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(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 /// COEFF_A = 168698
const COEFF_A: Fq = MontFp!("168698"); const COEFF_A: Fq = MontFp!("168698");
/// COEFF_B = 168700 /// COEFF_B = 168700
const COEFF_B: Fq = MontFp!("168700"); const COEFF_B: Fq = MontFp!("168700");
type TECurveConfig = EdwardsParameters;
type TECurveConfig = EdwardsConfig;
} }
const GENERATOR_X: Fq = const GENERATOR_X: Fq =

+ 2
- 2
ed_on_cp6_782/src/constraints/curves.rs

@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *}; use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
} }

+ 8
- 8
ed_on_cp6_782/src/curves/mod.rs

@ -9,13 +9,13 @@ use crate::{Fq, Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsParameters;
pub struct EdwardsConfig;
impl CurveConfig for EdwardsParameters {
impl CurveConfig for EdwardsConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -27,7 +27,7 @@ impl CurveConfig for EdwardsParameters {
const COFACTOR_INV: Fr = MontFp!("12124894969357926281749346891948134384518445910386624712788431705725441736421489799867521238554906438478484045560"); const COFACTOR_INV: Fr = MontFp!("12124894969357926281749346891948134384518445910386624712788431705725441736421489799867521238554906438478484045560");
} }
impl TECurveConfig for EdwardsParameters {
impl TECurveConfig for EdwardsConfig {
/// COEFF_A = -1 = /// COEFF_A = -1 =
const COEFF_A: Fq = MontFp!("-1"); const COEFF_A: Fq = MontFp!("-1");
@ -37,7 +37,7 @@ impl TECurveConfig for EdwardsParameters {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y) /// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(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. /// Multiplication by `a` is just negation.
#[inline(always)] #[inline(always)]
@ -46,14 +46,14 @@ impl TECurveConfig for EdwardsParameters {
} }
} }
impl MontCurveConfig for EdwardsParameters {
impl MontCurveConfig for EdwardsConfig {
/// COEFF_A = 0x95D53EB3F6AC3F7A53C26020144439DC6073BCAE513E03FD06B6B3BAA390F25E51534B26719E33F4CD906D4DA9B535 /// COEFF_A = 0x95D53EB3F6AC3F7A53C26020144439DC6073BCAE513E03FD06B6B3BAA390F25E51534B26719E33F4CD906D4DA9B535
const COEFF_A: Fq = MontFp!("90083623084271891037116870487743067984710080209539149685414147055329063590616489392386084989619674926965747987765"); const COEFF_A: Fq = MontFp!("90083623084271891037116870487743067984710080209539149685414147055329063590616489392386084989619674926965747987765");
/// COEFF_B = 0x118650763CE64AB4BE743604C8D05013DC2663652A3D58B21ECAB7BFF65B70DB8BA09F9098E61CC903B2F92B2564ACA /// COEFF_B = 0x118650763CE64AB4BE743604C8D05013DC2663652A3D58B21ECAB7BFF65B70DB8BA09F9098E61CC903B2F92B2564ACA
const COEFF_B: Fq = MontFp!("168580802928697202973535863207150465551683432545375510854470115611391404757724333382582803149953685197474573470410"); const COEFF_B: Fq = MontFp!("168580802928697202973535863207150465551683432545375510854470115611391404757724333382582803149953685197474573470410");
type TECurveConfig = EdwardsParameters;
type TECurveConfig = EdwardsConfig;
} }
/// GENERATOR_X = /// GENERATOR_X =

+ 2
- 2
ed_on_mnt4_298/src/constraints/curves.rs

@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::fields::FqVar, *}; use crate::{constraints::fields::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
} }

+ 8
- 8
ed_on_mnt4_298/src/curves/mod.rs

@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsParameters;
pub struct EdwardsConfig;
impl CurveConfig for EdwardsParameters {
impl CurveConfig for EdwardsConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -34,7 +34,7 @@ impl CurveConfig for EdwardsParameters {
// R for Fq: 223364648326281414938801705359223029554923725549792420683051274872200260503540791531766876 // R for Fq: 223364648326281414938801705359223029554923725549792420683051274872200260503540791531766876
// R for Fr: 104384076783966083500464392945960916666734135485183910065100558776489954102951241798239545 // R for Fr: 104384076783966083500464392945960916666734135485183910065100558776489954102951241798239545
impl TECurveConfig for EdwardsParameters {
impl TECurveConfig for EdwardsConfig {
/// COEFF_A = -1 /// COEFF_A = -1
/// Needs to be in the Montgomery residue form in Fq /// Needs to be in the Montgomery residue form in Fq
/// I.e., -1 * R for Fq /// I.e., -1 * R for Fq
@ -50,7 +50,7 @@ impl TECurveConfig for EdwardsParameters {
/// Generated randomly /// Generated randomly
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(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. /// Multiplication by `a` is just negation.
#[inline(always)] #[inline(always)]
@ -59,14 +59,14 @@ impl TECurveConfig for EdwardsParameters {
} }
} }
impl MontCurveConfig for EdwardsParameters {
impl MontCurveConfig for EdwardsConfig {
/// COEFF_A = 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204 /// COEFF_A = 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204
const COEFF_A: Fq = MontFp!("203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204"); const COEFF_A: Fq = MontFp!("203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204");
/// COEFF_B = 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931 /// COEFF_B = 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931
const COEFF_B: Fq = MontFp!("272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931"); const COEFF_B: Fq = MontFp!("272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931");
type TECurveConfig = EdwardsParameters;
type TECurveConfig = EdwardsConfig;
} }
/// GENERATOR_X = /// GENERATOR_X =

+ 2
- 2
ed_on_mnt4_753/src/constraints/curves.rs

@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::fields::FqVar, *}; use crate::{constraints::fields::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
} }

+ 8
- 8
ed_on_mnt4_753/src/curves/mod.rs

@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsParameters;
pub struct EdwardsConfig;
impl CurveConfig for EdwardsParameters {
impl CurveConfig for EdwardsConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -27,7 +27,7 @@ impl CurveConfig for EdwardsParameters {
const COFACTOR_INV: Fr = MontFp!("4582647449616135528381398492791944685893671397494963179726320631987147963874964803303316505414568319530101512550297775574042810022553679071007001162683923594233560231270043634777390699589793776691858866199511300853468155295505"); const COFACTOR_INV: Fr = MontFp!("4582647449616135528381398492791944685893671397494963179726320631987147963874964803303316505414568319530101512550297775574042810022553679071007001162683923594233560231270043634777390699589793776691858866199511300853468155295505");
} }
impl TECurveConfig for EdwardsParameters {
impl TECurveConfig for EdwardsConfig {
/// COEFF_A = -1 /// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1"); const COEFF_A: Fq = MontFp!("-1");
@ -37,7 +37,7 @@ impl TECurveConfig for EdwardsParameters {
/// Generated randomly /// Generated randomly
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(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. /// Multiplication by `a` is just negation.
#[inline(always)] #[inline(always)]
@ -46,14 +46,14 @@ impl TECurveConfig for EdwardsParameters {
} }
} }
impl MontCurveConfig for EdwardsParameters {
impl MontCurveConfig for EdwardsConfig {
/// COEFF_A = 40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419 /// COEFF_A = 40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419
const COEFF_A: Fq = MontFp!("40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419"); const COEFF_A: Fq = MontFp!("40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419");
/// COEFF_B = 1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580 /// COEFF_B = 1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580
const COEFF_B: Fq = MontFp!("1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580"); const COEFF_B: Fq = MontFp!("1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580");
type TECurveConfig = EdwardsParameters;
type TECurveConfig = EdwardsConfig;
} }
/// GENERATOR_X = /// GENERATOR_X =

+ 10
- 16
mnt4_298/src/constraints/curves.rs

@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt4; use ark_r1cs_std::groups::mnt4;
use crate::Parameters;
use crate::Config;
/// An element of G1 in the MNT4-298 bilinear group. /// 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. /// 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// 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 /// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>;
pub type G2PreparedVar = mnt4::G2PreparedVar<Config>;
#[test] #[test]
fn 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();
} }

+ 2
- 2
mnt4_298/src/constraints/pairing.rs

@ -1,8 +1,8 @@
use crate::Parameters;
use crate::Config;
/// Specifies the constraints for computing a pairing in the MNT4-298 bilinear /// Specifies the constraints for computing a pairing in the MNT4-298 bilinear
/// group. /// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>;
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>;
#[test] #[test]
fn test() { fn test() {

+ 6
- 6
mnt4_298/src/curves/g1.rs

@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -25,7 +25,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = Fr::ONE; const COFACTOR_INV: Fr = Fr::ONE;
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 2 /// COEFF_A = 2
/// Reference: <https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L116> /// Reference: <https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L116>
const COEFF_A: Fq = MontFp!("2"); const COEFF_A: Fq = MontFp!("2");

+ 8
- 8
mnt4_298/src/curves/g2.rs

@ -1,20 +1,20 @@
use ark_ec::{ use ark_ec::{
mnt4, mnt4,
mnt4::MNT4Parameters,
mnt4::MNT4Config,
models::{short_weierstrass::SWCurveConfig, CurveConfig}, models::{short_weierstrass::SWCurveConfig, CurveConfig},
}; };
use ark_ff::{Field, MontFp}; use ark_ff::{Field, MontFp};
use crate::{Fq, Fq2, Fr, G1_COEFF_A_NON_RESIDUE}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq2; type BaseField = Fq2;
type ScalarField = Fr; type ScalarField = Fr;
@ -40,8 +40,8 @@ pub const MUL_BY_A_C0: Fq = G1_COEFF_A_NON_RESIDUE;
/// MUL_BY_A_C1 = NONRESIDUE * COEFF_A /// MUL_BY_A_C1 = NONRESIDUE * COEFF_A
pub const MUL_BY_A_C1: Fq = G1_COEFF_A_NON_RESIDUE; 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 = // B coefficient of MNT4-298 G2 =
// ``` // ```
// mnt4298_twist_coeff_b = mnt4298_Fq2(mnt4298_Fq::zero(), // mnt4298_twist_coeff_b = mnt4298_Fq2(mnt4298_Fq::zero(),

+ 6
- 6
mnt4_298/src/curves/mod.rs

@ -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 ark_ff::{biginteger::BigInteger320, BigInt, Field, MontFp};
use crate::{Fq, Fq2, Fq2Config, Fq4Config, Fr}; use crate::{Fq, Fq2, Fq2Config, Fq4Config, Fr};
@ -14,11 +14,11 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective}, 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); const TWIST: Fq2 = Fq2::new(Fq::ZERO, Fq::ONE);
// A coefficient of MNT4-298 G2 = // A coefficient of MNT4-298 G2 =
// ``` // ```
@ -46,8 +46,8 @@ impl MNT4Parameters for Parameters {
type Fr = Fr; type Fr = Fr;
type Fp2Config = Fq2Config; type Fp2Config = Fq2Config;
type Fp4Config = Fq4Config; type Fp4Config = Fq4Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
} }
// 34 // 34

+ 10
- 16
mnt4_753/src/constraints/curves.rs

@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt4; use ark_r1cs_std::groups::mnt4;
use crate::Parameters;
use crate::Config;
/// An element of G1 in the MNT4-753 bilinear group. /// 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. /// 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// 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 /// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>;
pub type G2PreparedVar = mnt4::G2PreparedVar<Config>;
#[test] #[test]
fn 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();
} }

+ 2
- 2
mnt4_753/src/constraints/pairing.rs

@ -1,8 +1,8 @@
use crate::Parameters;
use crate::Config;
/// Specifies the constraints for computing a pairing in the MNT4-753 bilinear /// Specifies the constraints for computing a pairing in the MNT4-753 bilinear
/// group. /// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>;
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>;
#[test] #[test]
fn test() { fn test() {

+ 6
- 6
mnt4_753/src/curves/g1.rs

@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -24,7 +24,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = Fr::ONE; const COFACTOR_INV: Fr = Fr::ONE;
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 2 /// COEFF_A = 2
const COEFF_A: Fq = MontFp!("2"); const COEFF_A: Fq = MontFp!("2");

+ 8
- 8
mnt4_753/src/curves/g2.rs

@ -1,20 +1,20 @@
use ark_ec::{ use ark_ec::{
mnt4, mnt4,
mnt4::MNT4Parameters,
mnt4::MNT4Config,
models::{short_weierstrass::SWCurveConfig, CurveConfig}, models::{short_weierstrass::SWCurveConfig, CurveConfig},
}; };
use ark_ff::{Field, MontFp}; use ark_ff::{Field, MontFp};
use crate::{Fq, Fq2, Fr, G1_COEFF_A_NON_RESIDUE}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq2; type BaseField = Fq2;
type ScalarField = Fr; type ScalarField = Fr;
@ -47,8 +47,8 @@ pub const MUL_BY_A_C0: Fq = G1_COEFF_A_NON_RESIDUE;
/// MUL_BY_A_C1 = NONRESIDUE * COEFF_A /// MUL_BY_A_C1 = NONRESIDUE * COEFF_A
pub const MUL_BY_A_C1: Fq = G1_COEFF_A_NON_RESIDUE; 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 = // B coefficient of MNT4-753 G2 =
// ``` // ```
// mnt4753_twist_coeff_b = mnt4753_Fq2(mnt4753_Fq::zero(), // mnt4753_twist_coeff_b = mnt4753_Fq2(mnt4753_Fq::zero(),

+ 6
- 6
mnt4_753/src/curves/mod.rs

@ -1,4 +1,4 @@
use ark_ec::models::mnt4::{MNT4Parameters, MNT4};
use ark_ec::models::mnt4::{MNT4Config, MNT4};
use ark_ff::{ use ark_ff::{
biginteger::{BigInt, BigInteger768}, biginteger::{BigInt, BigInteger768},
Field, Fp2, MontFp, Field, Fp2, MontFp,
@ -17,11 +17,11 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective}, 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); const TWIST: Fp2<Self::Fp2Config> = Fp2::new(Fq::ZERO, Fq::ONE);
// A coefficient of MNT4-753 G2 = // A coefficient of MNT4-753 G2 =
// ``` // ```
@ -69,8 +69,8 @@ impl MNT4Parameters for Parameters {
type Fr = Fr; type Fr = Fr;
type Fp2Config = Fq2Config; type Fp2Config = Fq2Config;
type Fp4Config = Fq4Config; type Fp4Config = Fq4Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
} }
// 26 // 26

+ 10
- 16
mnt6_298/src/constraints/curves.rs

@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt6; use ark_r1cs_std::groups::mnt6;
use crate::Parameters;
use crate::Config;
/// An element of G1 in the MNT6-298 bilinear group. /// 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. /// 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// 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 /// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>;
pub type G2PreparedVar = mnt6::G2PreparedVar<Config>;
#[test] #[test]
fn 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();
} }

+ 2
- 2
mnt6_298/src/constraints/pairing.rs

@ -1,8 +1,8 @@
use crate::Parameters;
use crate::Config;
/// Specifies the constraints for computing a pairing in the MNT6-298 bilinear /// Specifies the constraints for computing a pairing in the MNT6-298 bilinear
/// group. /// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Parameters>;
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Config>;
#[test] #[test]
fn test() { fn test() {

+ 6
- 6
mnt6_298/src/curves/g1.rs

@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -24,7 +24,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = Fr::ONE; const COFACTOR_INV: Fr = Fr::ONE;
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 11 /// COEFF_A = 11
const COEFF_A: Fq = MontFp!("11"); const COEFF_A: Fq = MontFp!("11");

+ 9
- 9
mnt6_298/src/curves/g2.rs

@ -1,20 +1,20 @@
use ark_ec::{ use ark_ec::{
mnt6, mnt6,
mnt6::MNT6Parameters,
mnt6::MNT6Config,
models::{short_weierstrass::SWCurveConfig, CurveConfig}, models::{short_weierstrass::SWCurveConfig, CurveConfig},
}; };
use ark_ff::{Field, MontFp}; use ark_ff::{Field, MontFp};
use crate::{g1, Fq, Fq3, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq3; type BaseField = Fq3;
type ScalarField = Fr; type ScalarField = Fr;
@ -48,10 +48,10 @@ pub const MUL_BY_A_C0: Fq = MontFp!("55");
pub const MUL_BY_A_C1: Fq = MontFp!("55"); pub const MUL_BY_A_C1: Fq = MontFp!("55");
/// MUL_BY_A_C2 = COEFF_A /// 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( const COEFF_B: Fq3 = Fq3::new(
// 5 * G1::COEFF_B // 5 * G1::COEFF_B
MontFp!("57578116384997352636487348509878309737146377454014423897662211075515354005624851787652233"), MontFp!("57578116384997352636487348509878309737146377454014423897662211075515354005624851787652233"),

+ 7
- 7
mnt6_298/src/curves/mod.rs

@ -1,5 +1,5 @@
use ark_ec::{ use ark_ec::{
models::mnt6::{MNT6Parameters, MNT6},
models::mnt6::{MNT6Config, MNT6},
short_weierstrass::SWCurveConfig, short_weierstrass::SWCurveConfig,
}; };
use ark_ff::{biginteger::BigInteger320, BigInt, Field, Fp3}; use ark_ff::{biginteger::BigInteger320, BigInt, Field, Fp3};
@ -17,14 +17,14 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective}, 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: Fp3<Self::Fp3Config> = Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ONE, Fq::ZERO);
const TWIST_COEFF_A: Fp3<Self::Fp3Config> = 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 // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4_80.ml#L88
const ATE_LOOP_COUNT: &'static [i8] = &[ const ATE_LOOP_COUNT: &'static [i8] = &[
@ -44,6 +44,6 @@ impl MNT6Parameters for Parameters {
type Fr = Fr; type Fr = Fr;
type Fp3Config = Fq3Config; type Fp3Config = Fq3Config;
type Fp6Config = Fq6Config; type Fp6Config = Fq6Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
} }

+ 10
- 16
mnt6_753/src/constraints/curves.rs

@ -1,30 +1,24 @@
use ark_r1cs_std::groups::mnt6; use ark_r1cs_std::groups::mnt6;
use crate::Parameters;
use crate::Config;
/// An element of G1 in the MNT6-753 bilinear group. /// 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. /// 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// 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 /// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>;
pub type G2PreparedVar = mnt6::G2PreparedVar<Config>;
#[test] #[test]
fn 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();
} }

+ 2
- 2
mnt6_753/src/constraints/pairing.rs

@ -1,8 +1,8 @@
use crate::Parameters;
use crate::Config;
/// Specifies the constraints for computing a pairing in the MNT6-753 bilinear /// Specifies the constraints for computing a pairing in the MNT6-753 bilinear
/// group. /// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Parameters>;
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Config>;
#[test] #[test]
fn test() { fn test() {

+ 6
- 6
mnt6_753/src/curves/g1.rs

@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -24,7 +24,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = Fr::ONE; const COFACTOR_INV: Fr = Fr::ONE;
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 11 /// COEFF_A = 11
const COEFF_A: Fq = MontFp!("11"); const COEFF_A: Fq = MontFp!("11");

+ 9
- 9
mnt6_753/src/curves/g2.rs

@ -1,20 +1,20 @@
use ark_ec::{ use ark_ec::{
mnt6, mnt6,
mnt6::MNT6Parameters,
mnt6::MNT6Config,
models::{short_weierstrass::SWCurveConfig, CurveConfig}, models::{short_weierstrass::SWCurveConfig, CurveConfig},
}; };
use ark_ff::{Field, MontFp}; use ark_ff::{Field, MontFp};
use crate::{g1, Fq, Fq3, Fr}; 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)] #[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq3; type BaseField = Fq3;
type ScalarField = Fr; type ScalarField = Fr;
@ -64,10 +64,10 @@ pub const MUL_BY_A_C0: Fq = MontFp!("121");
pub const MUL_BY_A_C1: Fq = MontFp!("121"); pub const MUL_BY_A_C1: Fq = MontFp!("121");
/// MUL_BY_A_C2 = COEFF_A /// 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 = // B coefficient of MNT6-753 G2 =
// ``` // ```
// mnt6753_twist_coeff_b = mnt6753_Fq3(mnt6753_G1::coeff_b * mnt6753_Fq3::non_residue, // mnt6753_twist_coeff_b = mnt6753_Fq3(mnt6753_G1::coeff_b * mnt6753_Fq3::non_residue,

+ 7
- 8
mnt6_753/src/curves/mod.rs

@ -1,5 +1,5 @@
use ark_ec::models::{ use ark_ec::models::{
mnt6::{MNT6Parameters, MNT6},
mnt6::{MNT6Config, MNT6},
short_weierstrass::SWCurveConfig, short_weierstrass::SWCurveConfig,
}; };
use ark_ff::{biginteger::BigInteger768, BigInt, Field, Fp3}; use ark_ff::{biginteger::BigInteger768, BigInt, Field, Fp3};
@ -17,11 +17,11 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective}, 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); const TWIST: Fp3<Self::Fp3Config> = Fp3::new(Fq::ZERO, Fq::ONE, Fq::ZERO);
// A coefficient of MNT6-753 G2 = // A coefficient of MNT6-753 G2 =
// ``` // ```
@ -29,8 +29,7 @@ impl MNT6Parameters for Parameters {
// mnt6753_G1::coeff_a); // mnt6753_G1::coeff_a);
// = (ZERO, ZERO, A_COEFF); // = (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 // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6753.ml
const ATE_LOOP_COUNT: &'static [i8] = &[ const ATE_LOOP_COUNT: &'static [i8] = &[
@ -71,6 +70,6 @@ impl MNT6Parameters for Parameters {
type Fr = Fr; type Fr = Fr;
type Fp3Config = Fq3Config; type Fp3Config = Fq3Config;
type Fp6Config = Fq6Config; type Fp6Config = Fq6Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
} }

+ 2
- 2
pallas/src/constraints/curves.rs

@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
use crate::{constraints::FBaseVar, *}; use crate::{constraints::FBaseVar, *};
/// A group element in the Pallas prime-order group. /// A group element in the Pallas prime-order group.
pub type GVar = ProjectiveVar<PallasParameters, FBaseVar>;
pub type GVar = ProjectiveVar<PallasConfig, FBaseVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::sw_test::<PallasParameters, GVar>().unwrap();
ark_curve_constraint_tests::curves::sw_test::<PallasConfig, GVar>().unwrap();
} }

+ 5
- 5
pallas/src/curves/mod.rs

@ -10,9 +10,9 @@ use crate::{fq::Fq, fr::Fr};
mod tests; mod tests;
#[derive(Copy, Clone, Default, PartialEq, Eq)] #[derive(Copy, Clone, Default, PartialEq, Eq)]
pub struct PallasParameters;
pub struct PallasConfig;
impl CurveConfig for PallasParameters {
impl CurveConfig for PallasConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -23,10 +23,10 @@ impl CurveConfig for PallasParameters {
const COFACTOR_INV: Fr = Fr::ONE; 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 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;

+ 2
- 2
secp256k1/src/constraints/curves.rs

@ -2,9 +2,9 @@ use crate::{constraints::FqVar, *};
use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar; use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
/// A group element in the secp256k1 curve. /// A group element in the secp256k1 curve.
pub type GVar = ProjectiveVar<Parameters, FqVar>;
pub type GVar = ProjectiveVar<Config, FqVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::sw_test::<Parameters, GVar>().unwrap();
ark_curve_constraint_tests::curves::sw_test::<Config, GVar>().unwrap();
} }

+ 5
- 5
secp256k1/src/curves/mod.rs

@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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)] #[derive(Copy, Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -27,7 +27,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = Fr::ONE; const COFACTOR_INV: Fr = Fr::ONE;
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 0 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;

+ 2
- 2
secq256k1/src/constraints/curves.rs

@ -2,9 +2,9 @@ use crate::{constraints::FqVar, *};
use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar; use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
/// A group element in the secq256k1 curve. /// A group element in the secq256k1 curve.
pub type GVar = ProjectiveVar<Parameters, FqVar>;
pub type GVar = ProjectiveVar<Config, FqVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::sw_test::<Parameters, GVar>().unwrap();
ark_curve_constraint_tests::curves::sw_test::<Config, GVar>().unwrap();
} }

+ 5
- 5
secq256k1/src/curves/mod.rs

@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)] #[cfg(test)]
mod tests; 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)] #[derive(Copy, Clone, Default, PartialEq, Eq)]
pub struct Parameters;
pub struct Config;
impl CurveConfig for Parameters {
impl CurveConfig for Config {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -27,7 +27,7 @@ impl CurveConfig for Parameters {
const COFACTOR_INV: Fr = Fr::ONE; const COFACTOR_INV: Fr = Fr::ONE;
} }
impl SWCurveConfig for Parameters {
impl SWCurveConfig for Config {
/// COEFF_A = 0 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;

+ 2
- 2
vesta/src/constraints/curves.rs

@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
use crate::{constraints::FBaseVar, *}; use crate::{constraints::FBaseVar, *};
/// A group element in the Vesta prime-order group. /// A group element in the Vesta prime-order group.
pub type GVar = ProjectiveVar<VestaParameters, FBaseVar>;
pub type GVar = ProjectiveVar<VestaConfig, FBaseVar>;
#[test] #[test]
fn test() { fn test() {
ark_curve_constraint_tests::curves::sw_test::<VestaParameters, GVar>().unwrap();
ark_curve_constraint_tests::curves::sw_test::<VestaConfig, GVar>().unwrap();
} }

+ 5
- 5
vesta/src/curves/mod.rs

@ -9,9 +9,9 @@ use ark_ff::{Field, MontFp, Zero};
mod tests; mod tests;
#[derive(Copy, Clone, Default, PartialEq, Eq)] #[derive(Copy, Clone, Default, PartialEq, Eq)]
pub struct VestaParameters;
pub struct VestaConfig;
impl CurveConfig for VestaParameters {
impl CurveConfig for VestaConfig {
type BaseField = Fq; type BaseField = Fq;
type ScalarField = Fr; type ScalarField = Fr;
@ -22,10 +22,10 @@ impl CurveConfig for VestaParameters {
const COFACTOR_INV: Fr = Fr::ONE; 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 /// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO; const COEFF_A: Fq = Fq::ZERO;

Loading…
Cancel
Save