From d4edfb6e15c89f18708e34d31e131445e3558b54 Mon Sep 17 00:00:00 2001 From: mmagician Date: Wed, 28 Dec 2022 16:04:33 +0100 Subject: [PATCH] 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 --- Cargo.toml | 44 +++++---------- src/fields/fp/mod.rs | 2 +- src/fields/nonnative/field_var.rs | 2 +- .../curves/short_weierstrass/bls12/mod.rs | 30 +++++------ .../curves/short_weierstrass/mnt4/mod.rs | 53 +++++++++---------- .../curves/short_weierstrass/mnt6/mod.rs | 53 +++++++++---------- .../short_weierstrass/non_zero_affine.rs | 28 +++++----- src/pairing/bls12/mod.rs | 10 ++-- src/pairing/mnt4/mod.rs | 12 ++--- src/pairing/mnt6/mod.rs | 12 ++--- 10 files changed, 111 insertions(+), 135 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8f0668a..3b297bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/src/fields/fp/mod.rs b/src/fields/fp/mod.rs index 2486309..8241aa6 100644 --- a/src/fields/fp/mod.rs +++ b/src/fields/fp/mod.rs @@ -762,7 +762,7 @@ impl FieldVar for FpVar { 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)) }, } diff --git a/src/fields/nonnative/field_var.rs b/src/fields/nonnative/field_var.rs index 4a08dd1..fb2e492 100644 --- a/src/fields/nonnative/field_var.rs +++ b/src/fields/nonnative/field_var.rs @@ -138,7 +138,7 @@ impl FieldVar 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)?)), diff --git a/src/groups/curves/short_weierstrass/bls12/mod.rs b/src/groups/curves/short_weierstrass/bls12/mod.rs index 99dcd11..263a1bd 100644 --- a/src/groups/curves/short_weierstrass/bls12/mod.rs +++ b/src/groups/curves/short_weierstrass/bls12/mod.rs @@ -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 crate::{ use core::fmt::Debug; /// Represents a projective point in G1. -pub type G1Var

= - ProjectiveVar<

::G1Parameters, FpVar<

::Fp>>; +pub type G1Var

= ProjectiveVar<

::G1Config, FpVar<

::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

= - AffineVar<

::G1Parameters, FpVar<

::Fp>>; +pub type G1AffineVar

= AffineVar<

::G1Config, FpVar<

::Fp>>; /// Represents a projective point in G2. -pub type G2Var

= ProjectiveVar<

::G2Parameters, Fp2G

>; +pub type G2Var

= ProjectiveVar<

::G2Config, Fp2G

>; /// 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

= AffineVar<

::G2Parameters, Fp2G

>; +pub type G2AffineVar

= AffineVar<

::G2Config, Fp2G

>; /// Represents the cached precomputation that can be performed on a G1 element /// which enables speeding up pairing computation. #[derive(Derivative)] #[derivative(Clone(bound = "G1Var

: Clone"), Debug(bound = "G1Var

: Debug"))] -pub struct G1PreparedVar(pub AffineVar>); +pub struct G1PreparedVar(pub AffineVar>); -impl G1PreparedVar

{ +impl G1PreparedVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -56,7 +54,7 @@ impl G1PreparedVar

{ } } -impl AllocVar, P::Fp> for G1PreparedVar

{ +impl AllocVar, P::Fp> for G1PreparedVar

{ fn new_variable>>( cs: impl Into>, f: impl FnOnce() -> Result, @@ -78,7 +76,7 @@ impl AllocVar, P::Fp> for G1PreparedVar

{ } } -impl ToBytesGadget for G1PreparedVar

{ +impl ToBytesGadget for G1PreparedVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -101,7 +99,7 @@ impl ToBytesGadget for G1PreparedVar

{ } } -type Fp2G

= Fp2Var<

::Fp2Config>; +type Fp2G

= Fp2Var<

::Fp2Config>; type LCoeff

= (Fp2G

, Fp2G

); /// Represents the cached precomputation that can be performed on a G2 element /// which enables speeding up pairing computation. @@ -110,12 +108,12 @@ type LCoeff

= (Fp2G

, Fp2G

); Clone(bound = "Fp2Var: Clone"), Debug(bound = "Fp2Var: Debug") )] -pub struct G2PreparedVar { +pub struct G2PreparedVar { #[doc(hidden)] pub ell_coeffs: Vec>, } -impl AllocVar, P::Fp> for G2PreparedVar

{ +impl AllocVar, P::Fp> for G2PreparedVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f, mode))] fn new_variable>>( cs: impl Into>, @@ -173,7 +171,7 @@ impl AllocVar, P::Fp> for G2PreparedVar

{ } } -impl ToBytesGadget for G2PreparedVar

{ +impl ToBytesGadget for G2PreparedVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -196,7 +194,7 @@ impl ToBytesGadget for G2PreparedVar

{ } } -impl G2PreparedVar

{ +impl G2PreparedVar

{ /// Constructs `Self` from a `G2Var`. #[tracing::instrument(target = "r1cs")] pub fn from_group_var(q: &G2Var

) -> Result { diff --git a/src/groups/curves/short_weierstrass/mnt4/mod.rs b/src/groups/curves/short_weierstrass/mnt4/mod.rs index 51e98c5..1bd768e 100644 --- a/src/groups/curves/short_weierstrass/mnt4/mod.rs +++ b/src/groups/curves/short_weierstrass/mnt4/mod.rs @@ -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 crate::{ use core::borrow::Borrow; /// Represents a projective point in G1. -pub type G1Var

= - ProjectiveVar<

::G1Parameters, FpVar<

::Fp>>; +pub type G1Var

= ProjectiveVar<

::G1Config, FpVar<

::Fp>>; /// Represents a projective point in G2. -pub type G2Var

= ProjectiveVar<

::G2Parameters, Fp2G

>; +pub type G2Var

= ProjectiveVar<

::G2Config, Fp2G

>; /// 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 { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct G1PreparedVar { #[doc(hidden)] pub x: FpVar, #[doc(hidden)] @@ -36,7 +35,7 @@ pub struct G1PreparedVar { pub y_twist: Fp2Var, } -impl AllocVar, P::Fp> for G1PreparedVar

{ +impl AllocVar, P::Fp> for G1PreparedVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -69,7 +68,7 @@ impl AllocVar, P::Fp> for G1PreparedVar

{ } } -impl G1PreparedVar

{ +impl G1PreparedVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -102,7 +101,7 @@ impl G1PreparedVar

{ } } -impl ToBytesGadget for G1PreparedVar

{ +impl ToBytesGadget for G1PreparedVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -131,13 +130,13 @@ impl ToBytesGadget for G1PreparedVar

{ } } -type Fp2G

= Fp2Var<

::Fp2Config>; +type Fp2G

= Fp2Var<

::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 { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct G2PreparedVar { #[doc(hidden)] pub x: Fp2Var, #[doc(hidden)] @@ -152,7 +151,7 @@ pub struct G2PreparedVar { pub addition_coefficients: Vec>, } -impl AllocVar, P::Fp> for G2PreparedVar

{ +impl AllocVar, P::Fp> for G2PreparedVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -198,7 +197,7 @@ impl AllocVar, P::Fp> for G2PreparedVar

{ } } -impl ToBytesGadget for G2PreparedVar

{ +impl ToBytesGadget for G2PreparedVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -241,7 +240,7 @@ impl ToBytesGadget for G2PreparedVar

{ } } -impl G2PreparedVar

{ +impl G2PreparedVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -341,15 +340,15 @@ impl G2PreparedVar

{ #[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))] -pub struct AteDoubleCoefficientsVar { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct AteDoubleCoefficientsVar { pub c_h: Fp2Var, pub c_4c: Fp2Var, pub c_j: Fp2Var, pub c_l: Fp2Var, } -impl AllocVar, P::Fp> for AteDoubleCoefficientsVar

{ +impl AllocVar, P::Fp> for AteDoubleCoefficientsVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -376,7 +375,7 @@ impl AllocVar, P::Fp> for AteDoubleC } } -impl ToBytesGadget for AteDoubleCoefficientsVar

{ +impl ToBytesGadget for AteDoubleCoefficientsVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -405,7 +404,7 @@ impl ToBytesGadget for AteDoubleCoefficientsVar

{ } } -impl AteDoubleCoefficientsVar

{ +impl AteDoubleCoefficientsVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -426,15 +425,13 @@ impl AteDoubleCoefficientsVar

{ #[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))] -pub struct AteAdditionCoefficientsVar { +#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))] +pub struct AteAdditionCoefficientsVar { pub c_l1: Fp2Var, pub c_rz: Fp2Var, } -impl AllocVar, P::Fp> - for AteAdditionCoefficientsVar

-{ +impl AllocVar, P::Fp> for AteAdditionCoefficientsVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -455,7 +452,7 @@ impl AllocVar, P::Fp> } } -impl ToBytesGadget for AteAdditionCoefficientsVar

{ +impl ToBytesGadget for AteAdditionCoefficientsVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -476,7 +473,7 @@ impl ToBytesGadget for AteAdditionCoefficientsVar

{ } } -impl AteAdditionCoefficientsVar

{ +impl AteAdditionCoefficientsVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -486,7 +483,7 @@ impl AteAdditionCoefficientsVar

{ } #[doc(hidden)] -pub struct G2ProjectiveExtendedVar { +pub struct G2ProjectiveExtendedVar { pub x: Fp2Var, pub y: Fp2Var, pub z: Fp2Var, diff --git a/src/groups/curves/short_weierstrass/mnt6/mod.rs b/src/groups/curves/short_weierstrass/mnt6/mod.rs index b3ab838..6d216e1 100644 --- a/src/groups/curves/short_weierstrass/mnt6/mod.rs +++ b/src/groups/curves/short_weierstrass/mnt6/mod.rs @@ -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 crate::{ use core::borrow::Borrow; /// Represents a projective point in G1. -pub type G1Var

= - ProjectiveVar<

::G1Parameters, FpVar<

::Fp>>; +pub type G1Var

= ProjectiveVar<

::G1Config, FpVar<

::Fp>>; /// Represents a projective point in G2. -pub type G2Var

= ProjectiveVar<

::G2Parameters, Fp3G

>; +pub type G2Var

= ProjectiveVar<

::G2Config, Fp3G

>; /// 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 { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct G1PreparedVar { #[doc(hidden)] pub x: FpVar, #[doc(hidden)] @@ -36,7 +35,7 @@ pub struct G1PreparedVar { pub y_twist: Fp3Var, } -impl G1PreparedVar

{ +impl G1PreparedVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -69,7 +68,7 @@ impl G1PreparedVar

{ } } -impl AllocVar, P::Fp> for G1PreparedVar

{ +impl AllocVar, P::Fp> for G1PreparedVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -102,7 +101,7 @@ impl AllocVar, P::Fp> for G1PreparedVar

{ } } -impl ToBytesGadget for G1PreparedVar

{ +impl ToBytesGadget for G1PreparedVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -131,13 +130,13 @@ impl ToBytesGadget for G1PreparedVar

{ } } -type Fp3G

= Fp3Var<

::Fp3Config>; +type Fp3G

= Fp3Var<

::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 { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct G2PreparedVar { #[doc(hidden)] pub x: Fp3Var, #[doc(hidden)] @@ -152,7 +151,7 @@ pub struct G2PreparedVar { pub addition_coefficients: Vec>, } -impl AllocVar, P::Fp> for G2PreparedVar

{ +impl AllocVar, P::Fp> for G2PreparedVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -198,7 +197,7 @@ impl AllocVar, P::Fp> for G2PreparedVar

{ } } -impl ToBytesGadget for G2PreparedVar

{ +impl ToBytesGadget for G2PreparedVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -241,7 +240,7 @@ impl ToBytesGadget for G2PreparedVar

{ } } -impl G2PreparedVar

{ +impl G2PreparedVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -341,15 +340,15 @@ impl G2PreparedVar

{ #[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT6Parameters"), Debug(bound = "P: MNT6Parameters"))] -pub struct AteDoubleCoefficientsVar { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct AteDoubleCoefficientsVar { pub c_h: Fp3Var, pub c_4c: Fp3Var, pub c_j: Fp3Var, pub c_l: Fp3Var, } -impl AllocVar, P::Fp> for AteDoubleCoefficientsVar

{ +impl AllocVar, P::Fp> for AteDoubleCoefficientsVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -376,7 +375,7 @@ impl AllocVar, P::Fp> for AteDoubleC } } -impl ToBytesGadget for AteDoubleCoefficientsVar

{ +impl ToBytesGadget for AteDoubleCoefficientsVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -405,7 +404,7 @@ impl ToBytesGadget for AteDoubleCoefficientsVar

{ } } -impl AteDoubleCoefficientsVar

{ +impl AteDoubleCoefficientsVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -424,15 +423,13 @@ impl AteDoubleCoefficientsVar

{ #[doc(hidden)] #[derive(Derivative)] -#[derivative(Clone(bound = "P: MNT6Parameters"), Debug(bound = "P: MNT6Parameters"))] -pub struct AteAdditionCoefficientsVar { +#[derivative(Clone(bound = "P: MNT6Config"), Debug(bound = "P: MNT6Config"))] +pub struct AteAdditionCoefficientsVar { pub c_l1: Fp3Var, pub c_rz: Fp3Var, } -impl AllocVar, P::Fp> - for AteAdditionCoefficientsVar

-{ +impl AllocVar, P::Fp> for AteAdditionCoefficientsVar

{ #[tracing::instrument(target = "r1cs", skip(cs, f))] fn new_variable>>( cs: impl Into>, @@ -453,7 +450,7 @@ impl AllocVar, P::Fp> } } -impl ToBytesGadget for AteAdditionCoefficientsVar

{ +impl ToBytesGadget for AteAdditionCoefficientsVar

{ #[inline] #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { @@ -474,7 +471,7 @@ impl ToBytesGadget for AteAdditionCoefficientsVar

{ } } -impl AteAdditionCoefficientsVar

{ +impl AteAdditionCoefficientsVar

{ /// Returns the value assigned to `self` in the underlying constraint /// system. pub fn value(&self) -> Result, SynthesisError> { @@ -485,7 +482,7 @@ impl AteAdditionCoefficientsVar

{ } #[doc(hidden)] -pub struct G2ProjectiveExtendedVar { +pub struct G2ProjectiveExtendedVar { pub x: Fp3Var, pub y: Fp3Var, pub z: Fp3Var, diff --git a/src/groups/curves/short_weierstrass/non_zero_affine.rs b/src/groups/curves/short_weierstrass/non_zero_affine.rs index 8578702..281b562 100644 --- a/src/groups/curves/short_weierstrass/non_zero_affine.rs +++ b/src/groups/curves/short_weierstrass/non_zero_affine.rs @@ -242,24 +242,24 @@ mod test_non_zero_affine { 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::::new_ref(); let x = FpVar::Var( - AllocatedFp::::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.x)).unwrap(), + AllocatedFp::::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.x)).unwrap(), ); let y = FpVar::Var( - AllocatedFp::::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.y)).unwrap(), + AllocatedFp::::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::>::new( + let mut a = ProjectiveVar::>::new( x.clone(), y.clone(), FpVar::Constant(Fq::one()), @@ -283,7 +283,7 @@ mod test_non_zero_affine { }; let sum_b = { - let mut a = NonZeroAffineVar::>::new(x, y); + let mut a = NonZeroAffineVar::>::new(x, y); let mut double_sequence = Vec::new(); double_sequence.push(a.clone()); @@ -310,15 +310,15 @@ mod test_non_zero_affine { let cs = ConstraintSystem::::new_ref(); let x = FpVar::Var( - AllocatedFp::::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.x)).unwrap(), + AllocatedFp::::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.x)).unwrap(), ); let y = FpVar::Var( - AllocatedFp::::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.y)).unwrap(), + AllocatedFp::::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.y)).unwrap(), ); // The following code tests `double_and_add`. let sum_a = { - let a = ProjectiveVar::>::new( + let a = ProjectiveVar::>::new( x.clone(), y.clone(), FpVar::Constant(Fq::one()), @@ -336,7 +336,7 @@ mod test_non_zero_affine { }; let sum_b = { - let a = NonZeroAffineVar::>::new(x, y); + let a = NonZeroAffineVar::>::new(x, y); let mut cur = a.double().unwrap(); for _ in 1..10 { @@ -356,22 +356,22 @@ mod test_non_zero_affine { let cs = ConstraintSystem::::new_ref(); let x = FpVar::Var( - AllocatedFp::::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.x)).unwrap(), + AllocatedFp::::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.x)).unwrap(), ); let y = FpVar::Var( - AllocatedFp::::new_witness(cs.clone(), || Ok(G1Parameters::GENERATOR.y)).unwrap(), + AllocatedFp::::new_witness(cs.clone(), || Ok(G1Config::GENERATOR.y)).unwrap(), ); - let a = NonZeroAffineVar::>::new(x, y); + let a = NonZeroAffineVar::>::new(x, y); let n = 10; - let a_multiples: Vec>> = + let a_multiples: Vec>> = std::iter::successors(Some(a.clone()), |acc| Some(acc.add_unchecked(&a).unwrap())) .take(n) .collect(); - let all_equal: Vec>> = (0..n / 2) + let all_equal: Vec>> = (0..n / 2) .map(|i| { a_multiples[i] .add_unchecked(&a_multiples[n - i - 1]) diff --git a/src/pairing/bls12/mod.rs b/src/pairing/bls12/mod.rs index 91adbb7..727f1e9 100644 --- a/src/pairing/bls12/mod.rs +++ b/src/pairing/bls12/mod.rs @@ -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(PhantomData

); +pub struct PairingVar(PhantomData

); -type Fp2V

= Fp2Var<

::Fp2Config>; +type Fp2V

= Fp2Var<

::Fp2Config>; -impl PairingVar

{ +impl PairingVar

{ // Evaluate the line function at point p. #[tracing::instrument(target = "r1cs")] fn ell( @@ -59,7 +59,7 @@ impl PairingVar

{ } } -impl PG, P::Fp> for PairingVar

{ +impl PG, P::Fp> for PairingVar

{ type G1Var = G1Var

; type G2Var = G2Var

; type G1PreparedVar = G1PreparedVar

; diff --git a/src/pairing/mnt4/mod.rs b/src/pairing/mnt4/mod.rs index b7ce0b3..73e43dd 100644 --- a/src/pairing/mnt4/mod.rs +++ b/src/pairing/mnt4/mod.rs @@ -9,19 +9,19 @@ use crate::{ 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(PhantomData

); +pub struct PairingVar(PhantomData

); -type Fp2G

= Fp2Var<

::Fp2Config>; -type Fp4G

= Fp4Var<

::Fp4Config>; +type Fp2G

= Fp2Var<

::Fp2Config>; +type Fp4G

= Fp4Var<

::Fp4Config>; /// A variable corresponding to `ark_ec::mnt4::GT`. pub type GTVar

= Fp4G

; -impl PairingVar

{ +impl PairingVar

{ #[tracing::instrument(target = "r1cs", skip(r))] pub(crate) fn doubling_step_for_flipped_miller_loop( r: &G2ProjectiveExtendedVar

, @@ -196,7 +196,7 @@ impl PairingVar

{ } } -impl PG, P::Fp> for PairingVar

{ +impl PG, P::Fp> for PairingVar

{ type G1Var = G1Var

; type G2Var = G2Var

; type G1PreparedVar = G1PreparedVar

; diff --git a/src/pairing/mnt6/mod.rs b/src/pairing/mnt6/mod.rs index 350eb62..b469549 100644 --- a/src/pairing/mnt6/mod.rs +++ b/src/pairing/mnt6/mod.rs @@ -9,18 +9,18 @@ use crate::{ 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(PhantomData

); +pub struct PairingVar(PhantomData

); -type Fp3G

= Fp3Var<

::Fp3Config>; -type Fp6G

= Fp6Var<

::Fp6Config>; +type Fp3G

= Fp3Var<

::Fp3Config>; +type Fp6G

= Fp6Var<

::Fp6Config>; /// A variable corresponding to `ark_ec::mnt6::GT`. pub type GTVar

= Fp6G

; -impl PairingVar

{ +impl PairingVar

{ #[tracing::instrument(target = "r1cs", skip(r))] pub(crate) fn doubling_step_for_flipped_miller_loop( r: &G2ProjectiveExtendedVar

, @@ -191,7 +191,7 @@ impl PairingVar

{ } } -impl PG, P::Fp> for PairingVar

{ +impl PG, P::Fp> for PairingVar

{ type G1Var = G1Var

; type G2Var = G2Var

; type G1PreparedVar = G1PreparedVar

;