Rename all *Parameters to *Config (#136)

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

* Tweak
This commit is contained in:
Pratyush Mishra
2022-12-16 22:35:32 -05:00
committed by GitHub
parent f8a6a4050e
commit febd7635fb
63 changed files with 382 additions and 414 deletions

View File

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

View File

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

View File

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

View File

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

View File

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