Prepare release 0.4 (#109) * Bump the dependencies and remove patch * temp remove dev-dependencies (until curves are published) due to circular dev-dependencies * bring back dev-dependencies to be merged only after curves crates are released * bump patch version * fix * use frobenius_map_in_place instead of frobenious_map * temp remove dev dependencies * chore: Release ark-r1cs-std version 0.4.0-alpha.2 * Revert "temp remove dev dependencies" This reverts commit 6b3ba6a5e98ea2055222d459d84d49eab7a98d47. * fix test import after curves have a new version * chore: Release ark-r1cs-std version 0.4.0-alpha.3 Co-authored-by: onewayfunc <onewayfunc@gmail.com>
jump to
@@ -1,6 +1,6 @@
[package] name = "ark-r1cs-std" -version = "0.3.1" +version = "0.4.0-alpha.3" authors = [ "arkworks contributors" ] description = "A standard library for constraint system gadgets" homepage = "https://arkworks.rs"@@ -13,10 +13,10 @@ license = "MIT/Apache-2.0"
edition = "2018" [dependencies] -ark-ff = { version = "^0.3.0", default-features = false } -ark-ec = { version = "^0.3.0", default-features = false } -ark-std = { version = "^0.3.0", default-features = false } -ark-relations = { version = "^0.3.0", default-features = false } +ark-ff = { version = "0.4.0-alpha", default-features = false } +ark-ec = { version = "0.4.0-alpha", default-features = false } +ark-std = { version = "0.4.0-alpha", default-features = false } +ark-relations = { version = "0.4.0-alpha", default-features = false } derivative = { version = "2", features = ["use_core"] } tracing = { version = "0.1", default-features = false, features = [ "attributes" ] }@@ -25,16 +25,16 @@ num-traits = {version = "0.2", default-features = false }
num-integer = { version = "0.1.44", default-features = false } [dev-dependencies] -ark-test-curves = { version = "^0.3.0", default-features = false, features = ["bls12_381_scalar_field", "bls12_381_curve", "mnt4_753_scalar_field"] } -ark-poly = { version = "^0.3.0", default-features = false } +ark-test-curves = { version = "0.4.0-alpha", default-features = false, features = ["bls12_381_scalar_field", "bls12_381_curve", "mnt4_753_scalar_field"] } +ark-poly = { version = "0.4.0-alpha", default-features = false } paste = "1.0" -ark-bls12-377 = { version = "^0.3.0", features = ["curve"], default-features = false } -ark-bls12-381 = { version = "^0.3.0", features = ["curve"], default-features = false } -ark-mnt4-298 = { version = "^0.3.0", features = ["curve"], default-features = false } -ark-mnt4-753 = { version = "^0.3.0", features = ["curve"], default-features = false } -ark-mnt6-298 = { version = "^0.3.0", default-features = false } -ark-mnt6-753 = { version = "^0.3.0", default-features = false } -ark-pallas = { version = "^0.3.0", features = ["curve"], default-features = false } +ark-bls12-377 = { version = "0.4.0-alpha", features = ["curve"], default-features = false } +ark-bls12-381 = { version = "0.4.0-alpha", features = ["curve"], default-features = false } +ark-mnt4-298 = { version = "0.4.0-alpha", features = ["curve"], default-features = false } +ark-mnt4-753 = { version = "0.4.0-alpha", features = ["curve"], default-features = false } +ark-mnt6-298 = { version = "0.4.0-alpha", default-features = false } +ark-mnt6-753 = { version = "0.4.0-alpha", default-features = false } +ark-pallas = { version = "0.4.0-alpha", features = ["curve"], default-features = false } [features] default = ["std"]@@ -70,19 +70,3 @@ lto = "thin"
incremental = true debug-assertions = true debug = true - -# To be removed in the new release. -[patch.crates-io] -ark-std = { git = "https://github.com/arkworks-rs/std" } -ark-ec = { git = "https://github.com/arkworks-rs/algebra" } -ark-ff = { git = "https://github.com/arkworks-rs/algebra" } -ark-poly = { git = "https://github.com/arkworks-rs/algebra" } -ark-serialize = { git = "https://github.com/arkworks-rs/algebra" } -ark-test-curves = { git = "https://github.com/arkworks-rs/algebra" } -ark-bls12-381 = { git = "https://github.com/arkworks-rs/curves" } -ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves" } -ark-mnt4-298 = { git = "https://github.com/arkworks-rs/curves" } -ark-mnt4-753 = { git = "https://github.com/arkworks-rs/curves" } -ark-mnt6-298 = { git = "https://github.com/arkworks-rs/curves" } -ark-mnt6-753 = { git = "https://github.com/arkworks-rs/curves" } -ark-pallas = { git = "https://github.com/arkworks-rs/curves" }
@@ -762,7 +762,7 @@ match self {
FpVar::Var(v) => v.frobenius_map(power).map(FpVar::Var), FpVar::Constant(f) => { let mut f = *f; - f.frobenius_map(power); + f.frobenius_map_in_place(power); Ok(FpVar::Constant(f)) }, }
@@ -138,7 +138,7 @@ fn frobenius_map(&self, power: usize) -> R1CSResult<Self> {
match self { Self::Constant(c) => Ok(Self::Constant({ let mut tmp = *c; - tmp.frobenius_map(power); + tmp.frobenius_map_in_place(power); tmp })), Self::Var(v) => Ok(Self::Var(v.frobenius_map(power)?)),
@@ -1,5 +1,5 @@
use ark_ec::{ - bls12::{Bls12Parameters, G1Prepared, G2Prepared, TwistType}, + bls12::{Bls12Config, G1Prepared, G2Prepared, TwistType}, short_weierstrass::Affine as GroupAffine, }; use ark_ff::{BitIteratorBE, Field, One};@@ -13,29 +13,27 @@ };
use core::fmt::Debug; /// Represents a projective point in G1. -pub type G1Var<P> = - ProjectiveVar<<P as Bls12Parameters>::G1Parameters, FpVar<<P as Bls12Parameters>::Fp>>; +pub type G1Var<P> = ProjectiveVar<<P as Bls12Config>::G1Config, FpVar<<P as Bls12Config>::Fp>>; /// Represents an affine point on G1. Should be used only for comparison and /// when a canonical representation of a point is required, and not for /// arithmetic. -pub type G1AffineVar<P> = - AffineVar<<P as Bls12Parameters>::G1Parameters, FpVar<<P as Bls12Parameters>::Fp>>; +pub type G1AffineVar<P> = AffineVar<<P as Bls12Config>::G1Config, FpVar<<P as Bls12Config>::Fp>>; /// Represents a projective point in G2. -pub type G2Var<P> = ProjectiveVar<<P as Bls12Parameters>::G2Parameters, Fp2G<P>>; +pub type G2Var<P> = ProjectiveVar<<P as Bls12Config>::G2Config, Fp2G<P>>; /// Represents an affine point on G2. Should be used only for comparison and /// when a canonical representation of a point is required, and not for /// arithmetic. -pub type G2AffineVar<P> = AffineVar<<P as Bls12Parameters>::G2Parameters, Fp2G<P>>; +pub type G2AffineVar<P> = AffineVar<<P as Bls12Config>::G2Config, Fp2G<P>>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. #[derive(Derivative)] #[derivative(Clone(bound = "G1Var<P>: Clone"), Debug(bound = "G1Var<P>: Debug"))] -pub struct G1PreparedVar<P: Bls12Parameters>(pub AffineVar<P::G1Parameters, FpVar<P::Fp>>); +pub struct G1PreparedVar<P: Bls12Config>(pub AffineVar<P::G1Config, FpVar<P::Fp>>); -impl<P: Bls12Parameters> G1PreparedVar<P> { +impl<P: Bls12Config> G1PreparedVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> {@@ -56,7 +54,7 @@ Ok(Self(g))
} } -impl<P: Bls12Parameters> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> { +impl<P: Bls12Config> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> { fn new_variable<T: Borrow<G1Prepared<P>>>( cs: impl Into<Namespace<P::Fp>>, f: impl FnOnce() -> Result<T, SynthesisError>,@@ -78,7 +76,7 @@ Ok(Self(g))
} } -impl<P: Bls12Parameters> ToBytesGadget<P::Fp> for G1PreparedVar<P> { +impl<P: Bls12Config> ToBytesGadget<P::Fp> for G1PreparedVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -101,7 +99,7 @@ Ok(bytes)
} } -type Fp2G<P> = Fp2Var<<P as Bls12Parameters>::Fp2Config>; +type Fp2G<P> = Fp2Var<<P as Bls12Config>::Fp2Config>; type LCoeff<P> = (Fp2G<P>, Fp2G<P>); /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation.@@ -110,12 +108,12 @@ #[derivative(
Clone(bound = "Fp2Var<P::Fp2Config>: Clone"), Debug(bound = "Fp2Var<P::Fp2Config>: Debug") )] -pub struct G2PreparedVar<P: Bls12Parameters> { +pub struct G2PreparedVar<P: Bls12Config> { #[doc(hidden)] pub ell_coeffs: Vec<LCoeff<P>>, } -impl<P: Bls12Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> { +impl<P: Bls12Config> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f, mode))] fn new_variable<T: Borrow<G2Prepared<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -173,7 +171,7 @@ Ok(Self { ell_coeffs })
} } -impl<P: Bls12Parameters> ToBytesGadget<P::Fp> for G2PreparedVar<P> { +impl<P: Bls12Config> ToBytesGadget<P::Fp> for G2PreparedVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -196,7 +194,7 @@ Ok(bytes)
} } -impl<P: Bls12Parameters> G2PreparedVar<P> { +impl<P: Bls12Config> G2PreparedVar<P> { /// Constructs `Self` from a `G2Var`. #[tracing::instrument(target = "r1cs")] pub fn from_group_var(q: &G2Var<P>) -> Result<Self, SynthesisError> {
@@ -1,6 +1,6 @@
use ark_ec::mnt4::{ g2::{AteAdditionCoefficients, AteDoubleCoefficients}, - G1Prepared, G2Prepared, MNT4Parameters, + G1Prepared, G2Prepared, MNT4Config, }; use ark_ff::Field; use ark_relations::r1cs::{Namespace, SynthesisError};@@ -15,17 +15,16 @@ };
use core::borrow::Borrow; /// Represents a projective point in G1. -pub type G1Var<P> = - ProjectiveVar<<P as MNT4Parameters>::G1Parameters, FpVar<<P as MNT4Parameters>::Fp>>; +pub type G1Var<P> = ProjectiveVar<<P as MNT4Config>::G1Config, FpVar<<P as MNT4Config>::Fp>>; /// Represents a projective point in G2. -pub type G2Var<P> = ProjectiveVar<<P as MNT4Parameters>::G2Parameters, Fp2G<P>>; +pub type G2Var<P> = ProjectiveVar<<P as MNT4Config>::G2Config, Fp2G<P>>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))] -pub struct G1PreparedVar<P: MNT4Parameters> { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct G1PreparedVar<P: MNT4Config> { #[doc(hidden)] pub x: FpVar<P::Fp>, #[doc(hidden)]@@ -36,7 +35,7 @@ #[doc(hidden)]
pub y_twist: Fp2Var<P::Fp2Config>, } -impl<P: MNT4Parameters> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> { +impl<P: MNT4Config> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<G1Prepared<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -69,7 +68,7 @@ })
} } -impl<P: MNT4Parameters> G1PreparedVar<P> { +impl<P: MNT4Config> G1PreparedVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> {@@ -102,7 +101,7 @@ })
} } -impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for G1PreparedVar<P> { +impl<P: MNT4Config> ToBytesGadget<P::Fp> for G1PreparedVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -131,13 +130,13 @@ Ok(x)
} } -type Fp2G<P> = Fp2Var<<P as MNT4Parameters>::Fp2Config>; +type Fp2G<P> = Fp2Var<<P as MNT4Config>::Fp2Config>; /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))] -pub struct G2PreparedVar<P: MNT4Parameters> { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct G2PreparedVar<P: MNT4Config> { #[doc(hidden)] pub x: Fp2Var<P::Fp2Config>, #[doc(hidden)]@@ -152,7 +151,7 @@ #[doc(hidden)]
pub addition_coefficients: Vec<AteAdditionCoefficientsVar<P>>, } -impl<P: MNT4Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> { +impl<P: MNT4Config> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<G2Prepared<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -198,7 +197,7 @@ })
} } -impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for G2PreparedVar<P> { +impl<P: MNT4Config> ToBytesGadget<P::Fp> for G2PreparedVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -241,7 +240,7 @@ Ok(x)
} } -impl<P: MNT4Parameters> G2PreparedVar<P> { +impl<P: MNT4Config> G2PreparedVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<G2Prepared<P>, SynthesisError> {@@ -341,15 +340,15 @@ }
#[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))] -pub struct AteDoubleCoefficientsVar<P: MNT4Parameters> { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct AteDoubleCoefficientsVar<P: MNT4Config> { pub c_h: Fp2Var<P::Fp2Config>, pub c_4c: Fp2Var<P::Fp2Config>, pub c_j: Fp2Var<P::Fp2Config>, pub c_l: Fp2Var<P::Fp2Config>, } -impl<P: MNT4Parameters> AllocVar<AteDoubleCoefficients<P>, P::Fp> for AteDoubleCoefficientsVar<P> { +impl<P: MNT4Config> AllocVar<AteDoubleCoefficients<P>, P::Fp> for AteDoubleCoefficientsVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<AteDoubleCoefficients<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -376,7 +375,7 @@ })
} } -impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> { +impl<P: MNT4Config> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -405,7 +404,7 @@ Ok(c_h)
} } -impl<P: MNT4Parameters> AteDoubleCoefficientsVar<P> { +impl<P: MNT4Config> AteDoubleCoefficientsVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<AteDoubleCoefficients<P>, SynthesisError> {@@ -426,15 +425,13 @@ }
#[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))] -pub struct AteAdditionCoefficientsVar<P: MNT4Parameters> { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct AteAdditionCoefficientsVar<P: MNT4Config> { pub c_l1: Fp2Var<P::Fp2Config>, pub c_rz: Fp2Var<P::Fp2Config>, } -impl<P: MNT4Parameters> AllocVar<AteAdditionCoefficients<P>, P::Fp> - for AteAdditionCoefficientsVar<P> -{ +impl<P: MNT4Config> AllocVar<AteAdditionCoefficients<P>, P::Fp> for AteAdditionCoefficientsVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<AteAdditionCoefficients<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -455,7 +452,7 @@ Ok(Self { c_l1, c_rz })
} } -impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> { +impl<P: MNT4Config> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -476,7 +473,7 @@ Ok(c_l1)
} } -impl<P: MNT4Parameters> AteAdditionCoefficientsVar<P> { +impl<P: MNT4Config> AteAdditionCoefficientsVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<AteAdditionCoefficients<P>, SynthesisError> {@@ -486,7 +483,7 @@ }
} #[doc(hidden)] -pub struct G2ProjectiveExtendedVar<P: MNT4Parameters> { +pub struct G2ProjectiveExtendedVar<P: MNT4Config> { pub x: Fp2Var<P::Fp2Config>, pub y: Fp2Var<P::Fp2Config>, pub z: Fp2Var<P::Fp2Config>,
@@ -1,6 +1,6 @@
use ark_ec::mnt6::{ g2::{AteAdditionCoefficients, AteDoubleCoefficients}, - G1Prepared, G2Prepared, MNT6Parameters, + G1Prepared, G2Prepared, MNT6Config, }; use ark_ff::Field; use ark_relations::r1cs::{Namespace, SynthesisError};@@ -15,17 +15,16 @@ };
use core::borrow::Borrow; /// Represents a projective point in G1. -pub type G1Var<P> = - ProjectiveVar<<P as MNT6Parameters>::G1Parameters, FpVar<<P as MNT6Parameters>::Fp>>; +pub type G1Var<P> = ProjectiveVar<<P as MNT6Config>::G1Config, FpVar<<P as MNT6Config>::Fp>>; /// Represents a projective point in G2. -pub type G2Var<P> = ProjectiveVar<<P as MNT6Parameters>::G2Parameters, Fp3G<P>>; +pub type G2Var<P> = ProjectiveVar<<P as MNT6Config>::G2Config, Fp3G<P>>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT6Parameters"), Debug(bound = "P: MNT6Parameters"))] -pub struct G1PreparedVar<P: MNT6Parameters> { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct G1PreparedVar<P: MNT6Config> { #[doc(hidden)] pub x: FpVar<P::Fp>, #[doc(hidden)]@@ -36,7 +35,7 @@ #[doc(hidden)]
pub y_twist: Fp3Var<P::Fp3Config>, } -impl<P: MNT6Parameters> G1PreparedVar<P> { +impl<P: MNT6Config> G1PreparedVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> {@@ -69,7 +68,7 @@ Ok(result)
} } -impl<P: MNT6Parameters> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> { +impl<P: MNT6Config> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<G1Prepared<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -102,7 +101,7 @@ })
} } -impl<P: MNT6Parameters> ToBytesGadget<P::Fp> for G1PreparedVar<P> { +impl<P: MNT6Config> ToBytesGadget<P::Fp> for G1PreparedVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -131,13 +130,13 @@ Ok(x)
} } -type Fp3G<P> = Fp3Var<<P as MNT6Parameters>::Fp3Config>; +type Fp3G<P> = Fp3Var<<P as MNT6Config>::Fp3Config>; /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT6Parameters"), Debug(bound = "P: MNT6Parameters"))] -pub struct G2PreparedVar<P: MNT6Parameters> { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct G2PreparedVar<P: MNT6Config> { #[doc(hidden)] pub x: Fp3Var<P::Fp3Config>, #[doc(hidden)]@@ -152,7 +151,7 @@ #[doc(hidden)]
pub addition_coefficients: Vec<AteAdditionCoefficientsVar<P>>, } -impl<P: MNT6Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> { +impl<P: MNT6Config> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<G2Prepared<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -198,7 +197,7 @@ })
} } -impl<P: MNT6Parameters> ToBytesGadget<P::Fp> for G2PreparedVar<P> { +impl<P: MNT6Config> ToBytesGadget<P::Fp> for G2PreparedVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -241,7 +240,7 @@ Ok(x)
} } -impl<P: MNT6Parameters> G2PreparedVar<P> { +impl<P: MNT6Config> G2PreparedVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<G2Prepared<P>, SynthesisError> {@@ -341,15 +340,15 @@ }
#[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT6Parameters"), Debug(bound = "P: MNT6Parameters"))] -pub struct AteDoubleCoefficientsVar<P: MNT6Parameters> { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct AteDoubleCoefficientsVar<P: MNT6Config> { pub c_h: Fp3Var<P::Fp3Config>, pub c_4c: Fp3Var<P::Fp3Config>, pub c_j: Fp3Var<P::Fp3Config>, pub c_l: Fp3Var<P::Fp3Config>, } -impl<P: MNT6Parameters> AllocVar<AteDoubleCoefficients<P>, P::Fp> for AteDoubleCoefficientsVar<P> { +impl<P: MNT6Config> AllocVar<AteDoubleCoefficients<P>, P::Fp> for AteDoubleCoefficientsVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<AteDoubleCoefficients<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -376,7 +375,7 @@ })
} } -impl<P: MNT6Parameters> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> { +impl<P: MNT6Config> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -405,7 +404,7 @@ Ok(c_h)
} } -impl<P: MNT6Parameters> AteDoubleCoefficientsVar<P> { +impl<P: MNT6Config> AteDoubleCoefficientsVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<AteDoubleCoefficients<P>, SynthesisError> {@@ -424,15 +423,13 @@ }
#[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT6Parameters"), Debug(bound = "P: MNT6Parameters"))] -pub struct AteAdditionCoefficientsVar<P: MNT6Parameters> { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct AteAdditionCoefficientsVar<P: MNT6Config> { pub c_l1: Fp3Var<P::Fp3Config>, pub c_rz: Fp3Var<P::Fp3Config>, } -impl<P: MNT6Parameters> AllocVar<AteAdditionCoefficients<P>, P::Fp> - for AteAdditionCoefficientsVar<P> -{ +impl<P: MNT6Config> AllocVar<AteAdditionCoefficients<P>, P::Fp> for AteAdditionCoefficientsVar<P> { #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable<T: Borrow<AteAdditionCoefficients<P>>>( cs: impl Into<Namespace<P::Fp>>,@@ -453,7 +450,7 @@ Ok(Self { c_l1, c_rz })
} } -impl<P: MNT6Parameters> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> { +impl<P: MNT6Config> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> { #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {@@ -474,7 +471,7 @@ Ok(c_l1)
} } -impl<P: MNT6Parameters> AteAdditionCoefficientsVar<P> { +impl<P: MNT6Config> AteAdditionCoefficientsVar<P> { /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result<AteAdditionCoefficients<P>, SynthesisError> {@@ -485,7 +482,7 @@ }
} #[doc(hidden)] -pub struct G2ProjectiveExtendedVar<P: MNT6Parameters> { +pub struct G2ProjectiveExtendedVar<P: MNT6Config> { pub x: Fp3Var<P::Fp3Config>, pub y: Fp3Var<P::Fp3Config>, pub z: Fp3Var<P::Fp3Config>,
@@ -242,24 +242,24 @@ };
use ark_ec::{models::short_weierstrass::SWCurveConfig, CurveGroup}; use ark_relations::r1cs::ConstraintSystem; use ark_std::{vec::Vec, One}; - use ark_test_curves::bls12_381::{g1::Parameters as G1Parameters, Fq}; + use ark_test_curves::bls12_381::{g1::Config as G1Config, Fq}; #[test] fn correctness_test_1() { let cs = ConstraintSystem::<Fq>::new_ref(); let x = FpVar::Var( - AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.x)).unwrap(), + AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.x)).unwrap(), ); let y = FpVar::Var( - AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.y)).unwrap(), + AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.y)).unwrap(), ); // The following code uses `double` and `add` (`add_unchecked`) to compute // (1 + 2 + ... + 2^9) G let sum_a = { - let mut a = ProjectiveVar::<G1Parameters, FpVar<Fq>>::new( + let mut a = ProjectiveVar::<G1Config, FpVar<Fq>>::new( x.clone(), y.clone(), FpVar::Constant(Fq::one()),@@ -283,7 +283,7 @@ (sum.x, sum.y)
}; let sum_b = { - let mut a = NonZeroAffineVar::<G1Parameters, FpVar<Fq>>::new(x, y); + let mut a = NonZeroAffineVar::<G1Config, FpVar<Fq>>::new(x, y); let mut double_sequence = Vec::new(); double_sequence.push(a.clone());@@ -310,15 +310,15 @@ fn correctness_test_2() {
let cs = ConstraintSystem::<Fq>::new_ref(); let x = FpVar::Var( - AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.x)).unwrap(), + AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.x)).unwrap(), ); let y = FpVar::Var( - AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.y)).unwrap(), + AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.y)).unwrap(), ); // The following code tests `double_and_add`. let sum_a = { - let a = ProjectiveVar::<G1Parameters, FpVar<Fq>>::new( + let a = ProjectiveVar::<G1Config, FpVar<Fq>>::new( x.clone(), y.clone(), FpVar::Constant(Fq::one()),@@ -336,7 +336,7 @@ (sum.x, sum.y)
}; let sum_b = { - let a = NonZeroAffineVar::<G1Parameters, FpVar<Fq>>::new(x, y); + let a = NonZeroAffineVar::<G1Config, FpVar<Fq>>::new(x, y); let mut cur = a.double().unwrap(); for _ in 1..10 {@@ -356,22 +356,22 @@ fn correctness_test_eq() {
let cs = ConstraintSystem::<Fq>::new_ref(); let x = FpVar::Var( - AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.x)).unwrap(), + AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.x)).unwrap(), ); let y = FpVar::Var( - AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.y)).unwrap(), + AllocatedFp::<Fq>::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.y)).unwrap(), ); - let a = NonZeroAffineVar::<G1Parameters, FpVar<Fq>>::new(x, y); + let a = NonZeroAffineVar::<G1Config, FpVar<Fq>>::new(x, y); let n = 10; - let a_multiples: Vec<NonZeroAffineVar<G1Parameters, FpVar<Fq>>> = + let a_multiples: Vec<NonZeroAffineVar<G1Config, FpVar<Fq>>> = std::iter::successors(Some(a.clone()), |acc| Some(acc.add_unchecked(&a).unwrap())) .take(n) .collect(); - let all_equal: Vec<NonZeroAffineVar<G1Parameters, FpVar<Fq>>> = (0..n / 2) + let all_equal: Vec<NonZeroAffineVar<G1Config, FpVar<Fq>>> = (0..n / 2) .map(|i| { a_multiples[i] .add_unchecked(&a_multiples[n - i - 1])
@@ -6,16 +6,16 @@ use crate::{
fields::{fp::FpVar, fp12::Fp12Var, fp2::Fp2Var, FieldVar}, groups::bls12::{G1AffineVar, G1PreparedVar, G1Var, G2PreparedVar, G2Var}, }; -use ark_ec::bls12::{Bls12, Bls12Parameters, TwistType}; +use ark_ec::bls12::{Bls12, Bls12Config, TwistType}; use ark_ff::BitIteratorBE; use ark_std::marker::PhantomData; /// Specifies the constraints for computing a pairing in a BLS12 bilinear group. -pub struct PairingVar<P: Bls12Parameters>(PhantomData<P>); +pub struct PairingVar<P: Bls12Config>(PhantomData<P>); -type Fp2V<P> = Fp2Var<<P as Bls12Parameters>::Fp2Config>; +type Fp2V<P> = Fp2Var<<P as Bls12Config>::Fp2Config>; -impl<P: Bls12Parameters> PairingVar<P> { +impl<P: Bls12Config> PairingVar<P> { // Evaluate the line function at point p. #[tracing::instrument(target = "r1cs")] fn ell(@@ -59,7 +59,7 @@ Ok(result)
} } -impl<P: Bls12Parameters> PG<Bls12<P>, P::Fp> for PairingVar<P> { +impl<P: Bls12Config> PG<Bls12<P>, P::Fp> for PairingVar<P> { type G1Var = G1Var<P>; type G2Var = G2Var<P>; type G1PreparedVar = G1PreparedVar<P>;
@@ -9,19 +9,19 @@ AteAdditionCoefficientsVar, AteDoubleCoefficientsVar, G1PreparedVar, G1Var, G2PreparedVar,
G2ProjectiveExtendedVar, G2Var, }, }; -use ark_ec::mnt4::{MNT4Parameters, MNT4}; +use ark_ec::mnt4::{MNT4Config, MNT4}; use core::marker::PhantomData; /// Specifies the constraints for computing a pairing in a MNT4 bilinear group. -pub struct PairingVar<P: MNT4Parameters>(PhantomData<P>); +pub struct PairingVar<P: MNT4Config>(PhantomData<P>); -type Fp2G<P> = Fp2Var<<P as MNT4Parameters>::Fp2Config>; -type Fp4G<P> = Fp4Var<<P as MNT4Parameters>::Fp4Config>; +type Fp2G<P> = Fp2Var<<P as MNT4Config>::Fp2Config>; +type Fp4G<P> = Fp4Var<<P as MNT4Config>::Fp4Config>; /// A variable corresponding to `ark_ec::mnt4::GT`. pub type GTVar<P> = Fp4G<P>; -impl<P: MNT4Parameters> PairingVar<P> { +impl<P: MNT4Config> PairingVar<P> { #[tracing::instrument(target = "r1cs", skip(r))] pub(crate) fn doubling_step_for_flipped_miller_loop( r: &G2ProjectiveExtendedVar<P>,@@ -196,7 +196,7 @@ Ok(w1_part * &w0_part)
} } -impl<P: MNT4Parameters> PG<MNT4<P>, P::Fp> for PairingVar<P> { +impl<P: MNT4Config> PG<MNT4<P>, P::Fp> for PairingVar<P> { type G1Var = G1Var<P>; type G2Var = G2Var<P>; type G1PreparedVar = G1PreparedVar<P>;
@@ -9,18 +9,18 @@ AteAdditionCoefficientsVar, AteDoubleCoefficientsVar, G1PreparedVar, G1Var, G2PreparedVar,
G2ProjectiveExtendedVar, G2Var, }, }; -use ark_ec::mnt6::{MNT6Parameters, MNT6}; +use ark_ec::mnt6::{MNT6Config, MNT6}; use core::marker::PhantomData; /// Specifies the constraints for computing a pairing in a MNT6 bilinear group. -pub struct PairingVar<P: MNT6Parameters>(PhantomData<P>); +pub struct PairingVar<P: MNT6Config>(PhantomData<P>); -type Fp3G<P> = Fp3Var<<P as MNT6Parameters>::Fp3Config>; -type Fp6G<P> = Fp6Var<<P as MNT6Parameters>::Fp6Config>; +type Fp3G<P> = Fp3Var<<P as MNT6Config>::Fp3Config>; +type Fp6G<P> = Fp6Var<<P as MNT6Config>::Fp6Config>; /// A variable corresponding to `ark_ec::mnt6::GT`. pub type GTVar<P> = Fp6G<P>; -impl<P: MNT6Parameters> PairingVar<P> { +impl<P: MNT6Config> PairingVar<P> { #[tracing::instrument(target = "r1cs", skip(r))] pub(crate) fn doubling_step_for_flipped_miller_loop( r: &G2ProjectiveExtendedVar<P>,@@ -191,7 +191,7 @@ Ok(w1_part * &w0_part)
} } -impl<P: MNT6Parameters> PG<MNT6<P>, P::Fp> for PairingVar<P> { +impl<P: MNT6Config> PG<MNT6<P>, P::Fp> for PairingVar<P> { type G1Var = G1Var<P>; type G2Var = G2Var<P>; type G1PreparedVar = G1PreparedVar<P>;