Browse Source

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 6b3ba6a5e9.

* 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>
master
mmagician 1 year ago
committed by GitHub
parent
commit
d4edfb6e15
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 111 additions and 135 deletions
  1. +14
    -30
      Cargo.toml
  2. +1
    -1
      src/fields/fp/mod.rs
  3. +1
    -1
      src/fields/nonnative/field_var.rs
  4. +14
    -16
      src/groups/curves/short_weierstrass/bls12/mod.rs
  5. +25
    -28
      src/groups/curves/short_weierstrass/mnt4/mod.rs
  6. +25
    -28
      src/groups/curves/short_weierstrass/mnt6/mod.rs
  7. +14
    -14
      src/groups/curves/short_weierstrass/non_zero_affine.rs
  8. +5
    -5
      src/pairing/bls12/mod.rs
  9. +6
    -6
      src/pairing/mnt4/mod.rs
  10. +6
    -6
      src/pairing/mnt6/mod.rs

+ 14
- 30
Cargo.toml

@ -1,6 +1,6 @@
[package] [package]
name = "ark-r1cs-std" name = "ark-r1cs-std"
version = "0.3.1"
version = "0.4.0-alpha.3"
authors = [ "arkworks contributors" ] authors = [ "arkworks contributors" ]
description = "A standard library for constraint system gadgets" description = "A standard library for constraint system gadgets"
homepage = "https://arkworks.rs" homepage = "https://arkworks.rs"
@ -13,10 +13,10 @@ license = "MIT/Apache-2.0"
edition = "2018" edition = "2018"
[dependencies] [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"] } derivative = { version = "2", features = ["use_core"] }
tracing = { version = "0.1", default-features = false, features = [ "attributes" ] } 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 } num-integer = { version = "0.1.44", default-features = false }
[dev-dependencies] [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" 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] [features]
default = ["std"] default = ["std"]
@ -70,19 +70,3 @@ lto = "thin"
incremental = true incremental = true
debug-assertions = true debug-assertions = true
debug = 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" }

+ 1
- 1
src/fields/fp/mod.rs

@ -762,7 +762,7 @@ impl FieldVar for FpVar {
FpVar::Var(v) => v.frobenius_map(power).map(FpVar::Var), FpVar::Var(v) => v.frobenius_map(power).map(FpVar::Var),
FpVar::Constant(f) => { FpVar::Constant(f) => {
let mut f = *f; let mut f = *f;
f.frobenius_map(power);
f.frobenius_map_in_place(power);
Ok(FpVar::Constant(f)) Ok(FpVar::Constant(f))
}, },
} }

+ 1
- 1
src/fields/nonnative/field_var.rs

@ -138,7 +138,7 @@ impl FieldVar
match self { match self {
Self::Constant(c) => Ok(Self::Constant({ Self::Constant(c) => Ok(Self::Constant({
let mut tmp = *c; let mut tmp = *c;
tmp.frobenius_map(power);
tmp.frobenius_map_in_place(power);
tmp tmp
})), })),
Self::Var(v) => Ok(Self::Var(v.frobenius_map(power)?)), Self::Var(v) => Ok(Self::Var(v.frobenius_map(power)?)),

+ 14
- 16
src/groups/curves/short_weierstrass/bls12/mod.rs

@ -1,5 +1,5 @@
use ark_ec::{ use ark_ec::{
bls12::{Bls12Parameters, G1Prepared, G2Prepared, TwistType},
bls12::{Bls12Config, G1Prepared, G2Prepared, TwistType},
short_weierstrass::Affine as GroupAffine, short_weierstrass::Affine as GroupAffine,
}; };
use ark_ff::{BitIteratorBE, Field, One}; use ark_ff::{BitIteratorBE, Field, One};
@ -13,29 +13,27 @@ use crate::{
use core::fmt::Debug; use core::fmt::Debug;
/// Represents a projective point in G1. /// 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 /// 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 /// when a canonical representation of a point is required, and not for
/// arithmetic. /// 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. /// 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 /// 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 /// when a canonical representation of a point is required, and not for
/// arithmetic. /// 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
#[derive(Derivative)] #[derive(Derivative)]
#[derivative(Clone(bound = "G1Var<P>: Clone"), Debug(bound = "G1Var<P>: Debug"))] #[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 /// Returns the value assigned to `self` in the underlying constraint
/// system. /// system.
pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> { pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> {
@ -56,7 +54,7 @@ impl G1PreparedVar

{

} }
} }
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>>>( fn new_variable<T: Borrow<G1Prepared<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
f: impl FnOnce() -> Result<T, SynthesisError>, f: impl FnOnce() -> Result<T, SynthesisError>,
@ -78,7 +76,7 @@ impl AllocVar, P::Fp> for G1PreparedVar

{

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

{

} }
} }
type Fp2G<P> = Fp2Var<<P as Bls12Parameters>::Fp2Config>;
type Fp2G<P> = Fp2Var<<P as Bls12Config>::Fp2Config>;
type LCoeff<P> = (Fp2G<P>, Fp2G<P>); type LCoeff<P> = (Fp2G<P>, Fp2G<P>);
/// 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.
@ -110,12 +108,12 @@ type LCoeff

= (Fp2G

, Fp2G

);

Clone(bound = "Fp2Var<P::Fp2Config>: Clone"), Clone(bound = "Fp2Var<P::Fp2Config>: Clone"),
Debug(bound = "Fp2Var<P::Fp2Config>: Debug") Debug(bound = "Fp2Var<P::Fp2Config>: Debug")
)] )]
pub struct G2PreparedVar<P: Bls12Parameters> {
pub struct G2PreparedVar<P: Bls12Config> {
#[doc(hidden)] #[doc(hidden)]
pub ell_coeffs: Vec<LCoeff<P>>, 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))] #[tracing::instrument(target = "r1cs", skip(cs, f, mode))]
fn new_variable<T: Borrow<G2Prepared<P>>>( fn new_variable<T: Borrow<G2Prepared<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -173,7 +171,7 @@ impl AllocVar, P::Fp> for G2PreparedVar

{

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

{

} }
} }
impl<P: Bls12Parameters> G2PreparedVar<P> {
impl<P: Bls12Config> G2PreparedVar<P> {
/// Constructs `Self` from a `G2Var`. /// Constructs `Self` from a `G2Var`.
#[tracing::instrument(target = "r1cs")] #[tracing::instrument(target = "r1cs")]
pub fn from_group_var(q: &G2Var<P>) -> Result<Self, SynthesisError> { pub fn from_group_var(q: &G2Var<P>) -> Result<Self, SynthesisError> {

+ 25
- 28
src/groups/curves/short_weierstrass/mnt4/mod.rs

@ -1,6 +1,6 @@
use ark_ec::mnt4::{ use ark_ec::mnt4::{
g2::{AteAdditionCoefficients, AteDoubleCoefficients}, g2::{AteAdditionCoefficients, AteDoubleCoefficients},
G1Prepared, G2Prepared, MNT4Parameters,
G1Prepared, G2Prepared, MNT4Config,
}; };
use ark_ff::Field; use ark_ff::Field;
use ark_relations::r1cs::{Namespace, SynthesisError}; use ark_relations::r1cs::{Namespace, SynthesisError};
@ -15,17 +15,16 @@ use crate::{
use core::borrow::Borrow; use core::borrow::Borrow;
/// Represents a projective point in G1. /// 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. /// 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
#[derive(Derivative)] #[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)] #[doc(hidden)]
pub x: FpVar<P::Fp>, pub x: FpVar<P::Fp>,
#[doc(hidden)] #[doc(hidden)]
@ -36,7 +35,7 @@ pub struct G1PreparedVar {
pub y_twist: Fp2Var<P::Fp2Config>, 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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<G1Prepared<P>>>( fn new_variable<T: Borrow<G1Prepared<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -69,7 +68,7 @@ impl AllocVar, P::Fp> for G1PreparedVar

{

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

{

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

{

} }
} }
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 /// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
#[derive(Derivative)] #[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)] #[doc(hidden)]
pub x: Fp2Var<P::Fp2Config>, pub x: Fp2Var<P::Fp2Config>,
#[doc(hidden)] #[doc(hidden)]
@ -152,7 +151,7 @@ pub struct G2PreparedVar {
pub addition_coefficients: Vec<AteAdditionCoefficientsVar<P>>, 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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<G2Prepared<P>>>( fn new_variable<T: Borrow<G2Prepared<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -198,7 +197,7 @@ impl AllocVar, P::Fp> for G2PreparedVar

{

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

{

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

{

#[doc(hidden)] #[doc(hidden)]
#[derive(Derivative)] #[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_h: Fp2Var<P::Fp2Config>,
pub c_4c: Fp2Var<P::Fp2Config>, pub c_4c: Fp2Var<P::Fp2Config>,
pub c_j: Fp2Var<P::Fp2Config>, pub c_j: Fp2Var<P::Fp2Config>,
pub c_l: 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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<AteDoubleCoefficients<P>>>( fn new_variable<T: Borrow<AteDoubleCoefficients<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -376,7 +375,7 @@ impl AllocVar, P::Fp> for AteDoubleC
} }
} }
impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> {
impl<P: MNT4Config> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> {
#[inline] #[inline]
#[tracing::instrument(target = "r1cs")] #[tracing::instrument(target = "r1cs")]
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> { fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@ -405,7 +404,7 @@ impl ToBytesGadget for AteDoubleCoefficientsVar

{

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

{

#[doc(hidden)] #[doc(hidden)]
#[derive(Derivative)] #[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_l1: Fp2Var<P::Fp2Config>,
pub c_rz: 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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<AteAdditionCoefficients<P>>>( fn new_variable<T: Borrow<AteAdditionCoefficients<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -455,7 +452,7 @@ impl AllocVar, P::Fp>
} }
} }
impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> {
impl<P: MNT4Config> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> {
#[inline] #[inline]
#[tracing::instrument(target = "r1cs")] #[tracing::instrument(target = "r1cs")]
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> { fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@ -476,7 +473,7 @@ impl ToBytesGadget for AteAdditionCoefficientsVar

{

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

{

} }
#[doc(hidden)] #[doc(hidden)]
pub struct G2ProjectiveExtendedVar<P: MNT4Parameters> {
pub struct G2ProjectiveExtendedVar<P: MNT4Config> {
pub x: Fp2Var<P::Fp2Config>, pub x: Fp2Var<P::Fp2Config>,
pub y: Fp2Var<P::Fp2Config>, pub y: Fp2Var<P::Fp2Config>,
pub z: Fp2Var<P::Fp2Config>, pub z: Fp2Var<P::Fp2Config>,

+ 25
- 28
src/groups/curves/short_weierstrass/mnt6/mod.rs

@ -1,6 +1,6 @@
use ark_ec::mnt6::{ use ark_ec::mnt6::{
g2::{AteAdditionCoefficients, AteDoubleCoefficients}, g2::{AteAdditionCoefficients, AteDoubleCoefficients},
G1Prepared, G2Prepared, MNT6Parameters,
G1Prepared, G2Prepared, MNT6Config,
}; };
use ark_ff::Field; use ark_ff::Field;
use ark_relations::r1cs::{Namespace, SynthesisError}; use ark_relations::r1cs::{Namespace, SynthesisError};
@ -15,17 +15,16 @@ use crate::{
use core::borrow::Borrow; use core::borrow::Borrow;
/// Represents a projective point in G1. /// 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. /// 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 /// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
#[derive(Derivative)] #[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)] #[doc(hidden)]
pub x: FpVar<P::Fp>, pub x: FpVar<P::Fp>,
#[doc(hidden)] #[doc(hidden)]
@ -36,7 +35,7 @@ pub struct G1PreparedVar {
pub y_twist: Fp3Var<P::Fp3Config>, 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 /// Returns the value assigned to `self` in the underlying constraint
/// system. /// system.
pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> { pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> {
@ -69,7 +68,7 @@ impl G1PreparedVar

{

} }
} }
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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<G1Prepared<P>>>( fn new_variable<T: Borrow<G1Prepared<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -102,7 +101,7 @@ impl AllocVar, P::Fp> for G1PreparedVar

{

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

{

} }
} }
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 /// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation. /// which enables speeding up pairing computation.
#[derive(Derivative)] #[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)] #[doc(hidden)]
pub x: Fp3Var<P::Fp3Config>, pub x: Fp3Var<P::Fp3Config>,
#[doc(hidden)] #[doc(hidden)]
@ -152,7 +151,7 @@ pub struct G2PreparedVar {
pub addition_coefficients: Vec<AteAdditionCoefficientsVar<P>>, 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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<G2Prepared<P>>>( fn new_variable<T: Borrow<G2Prepared<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -198,7 +197,7 @@ impl AllocVar, P::Fp> for G2PreparedVar

{

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

{

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

{

#[doc(hidden)] #[doc(hidden)]
#[derive(Derivative)] #[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_h: Fp3Var<P::Fp3Config>,
pub c_4c: Fp3Var<P::Fp3Config>, pub c_4c: Fp3Var<P::Fp3Config>,
pub c_j: Fp3Var<P::Fp3Config>, pub c_j: Fp3Var<P::Fp3Config>,
pub c_l: 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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<AteDoubleCoefficients<P>>>( fn new_variable<T: Borrow<AteDoubleCoefficients<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -376,7 +375,7 @@ impl AllocVar, P::Fp> for AteDoubleC
} }
} }
impl<P: MNT6Parameters> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> {
impl<P: MNT6Config> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> {
#[inline] #[inline]
#[tracing::instrument(target = "r1cs")] #[tracing::instrument(target = "r1cs")]
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> { fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@ -405,7 +404,7 @@ impl ToBytesGadget for AteDoubleCoefficientsVar

{

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

{

#[doc(hidden)] #[doc(hidden)]
#[derive(Derivative)] #[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_l1: Fp3Var<P::Fp3Config>,
pub c_rz: 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))] #[tracing::instrument(target = "r1cs", skip(cs, f))]
fn new_variable<T: Borrow<AteAdditionCoefficients<P>>>( fn new_variable<T: Borrow<AteAdditionCoefficients<P>>>(
cs: impl Into<Namespace<P::Fp>>, cs: impl Into<Namespace<P::Fp>>,
@ -453,7 +450,7 @@ impl AllocVar, P::Fp>
} }
} }
impl<P: MNT6Parameters> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> {
impl<P: MNT6Config> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> {
#[inline] #[inline]
#[tracing::instrument(target = "r1cs")] #[tracing::instrument(target = "r1cs")]
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> { fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@ -474,7 +471,7 @@ impl ToBytesGadget for AteAdditionCoefficientsVar

{

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

{

} }
#[doc(hidden)] #[doc(hidden)]
pub struct G2ProjectiveExtendedVar<P: MNT6Parameters> {
pub struct G2ProjectiveExtendedVar<P: MNT6Config> {
pub x: Fp3Var<P::Fp3Config>, pub x: Fp3Var<P::Fp3Config>,
pub y: Fp3Var<P::Fp3Config>, pub y: Fp3Var<P::Fp3Config>,
pub z: Fp3Var<P::Fp3Config>, pub z: Fp3Var<P::Fp3Config>,

+ 14
- 14
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_ec::{models::short_weierstrass::SWCurveConfig, CurveGroup};
use ark_relations::r1cs::ConstraintSystem; use ark_relations::r1cs::ConstraintSystem;
use ark_std::{vec::Vec, One}; 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] #[test]
fn correctness_test_1() { fn correctness_test_1() {
let cs = ConstraintSystem::<Fq>::new_ref(); let cs = ConstraintSystem::<Fq>::new_ref();
let x = FpVar::Var( 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( 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 // The following code uses `double` and `add` (`add_unchecked`) to compute
// (1 + 2 + ... + 2^9) G // (1 + 2 + ... + 2^9) G
let sum_a = { let sum_a = {
let mut a = ProjectiveVar::<G1Parameters, FpVar<Fq>>::new(
let mut a = ProjectiveVar::<G1Config, FpVar<Fq>>::new(
x.clone(), x.clone(),
y.clone(), y.clone(),
FpVar::Constant(Fq::one()), FpVar::Constant(Fq::one()),
@ -283,7 +283,7 @@ mod test_non_zero_affine {
}; };
let sum_b = { 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(); let mut double_sequence = Vec::new();
double_sequence.push(a.clone()); double_sequence.push(a.clone());
@ -310,15 +310,15 @@ mod test_non_zero_affine {
let cs = ConstraintSystem::<Fq>::new_ref(); let cs = ConstraintSystem::<Fq>::new_ref();
let x = FpVar::Var( 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( 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`. // The following code tests `double_and_add`.
let sum_a = { let sum_a = {
let a = ProjectiveVar::<G1Parameters, FpVar<Fq>>::new(
let a = ProjectiveVar::<G1Config, FpVar<Fq>>::new(
x.clone(), x.clone(),
y.clone(), y.clone(),
FpVar::Constant(Fq::one()), FpVar::Constant(Fq::one()),
@ -336,7 +336,7 @@ mod test_non_zero_affine {
}; };
let sum_b = { 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(); let mut cur = a.double().unwrap();
for _ in 1..10 { for _ in 1..10 {
@ -356,22 +356,22 @@ mod test_non_zero_affine {
let cs = ConstraintSystem::<Fq>::new_ref(); let cs = ConstraintSystem::<Fq>::new_ref();
let x = FpVar::Var( 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( 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 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())) std::iter::successors(Some(a.clone()), |acc| Some(acc.add_unchecked(&a).unwrap()))
.take(n) .take(n)
.collect(); .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| { .map(|i| {
a_multiples[i] a_multiples[i]
.add_unchecked(&a_multiples[n - i - 1]) .add_unchecked(&a_multiples[n - i - 1])

+ 5
- 5
src/pairing/bls12/mod.rs

@ -6,16 +6,16 @@ use crate::{
fields::{fp::FpVar, fp12::Fp12Var, fp2::Fp2Var, FieldVar}, fields::{fp::FpVar, fp12::Fp12Var, fp2::Fp2Var, FieldVar},
groups::bls12::{G1AffineVar, G1PreparedVar, G1Var, G2PreparedVar, G2Var}, 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_ff::BitIteratorBE;
use ark_std::marker::PhantomData; use ark_std::marker::PhantomData;
/// Specifies the constraints for computing a pairing in a BLS12 bilinear group. /// 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. // Evaluate the line function at point p.
#[tracing::instrument(target = "r1cs")] #[tracing::instrument(target = "r1cs")]
fn ell( fn ell(
@ -59,7 +59,7 @@ impl PairingVar

{

} }
} }
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 G1Var = G1Var<P>;
type G2Var = G2Var<P>; type G2Var = G2Var<P>;
type G1PreparedVar = G1PreparedVar<P>; type G1PreparedVar = G1PreparedVar<P>;

+ 6
- 6
src/pairing/mnt4/mod.rs

@ -9,19 +9,19 @@ use crate::{
G2ProjectiveExtendedVar, G2Var, G2ProjectiveExtendedVar, G2Var,
}, },
}; };
use ark_ec::mnt4::{MNT4Parameters, MNT4};
use ark_ec::mnt4::{MNT4Config, MNT4};
use core::marker::PhantomData; use core::marker::PhantomData;
/// Specifies the constraints for computing a pairing in a MNT4 bilinear group. /// 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`. /// A variable corresponding to `ark_ec::mnt4::GT`.
pub type GTVar<P> = Fp4G<P>; pub type GTVar<P> = Fp4G<P>;
impl<P: MNT4Parameters> PairingVar<P> {
impl<P: MNT4Config> PairingVar<P> {
#[tracing::instrument(target = "r1cs", skip(r))] #[tracing::instrument(target = "r1cs", skip(r))]
pub(crate) fn doubling_step_for_flipped_miller_loop( pub(crate) fn doubling_step_for_flipped_miller_loop(
r: &G2ProjectiveExtendedVar<P>, r: &G2ProjectiveExtendedVar<P>,
@ -196,7 +196,7 @@ impl PairingVar

{

} }
} }
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 G1Var = G1Var<P>;
type G2Var = G2Var<P>; type G2Var = G2Var<P>;
type G1PreparedVar = G1PreparedVar<P>; type G1PreparedVar = G1PreparedVar<P>;

+ 6
- 6
src/pairing/mnt6/mod.rs

@ -9,18 +9,18 @@ use crate::{
G2ProjectiveExtendedVar, G2Var, G2ProjectiveExtendedVar, G2Var,
}, },
}; };
use ark_ec::mnt6::{MNT6Parameters, MNT6};
use ark_ec::mnt6::{MNT6Config, MNT6};
use core::marker::PhantomData; use core::marker::PhantomData;
/// Specifies the constraints for computing a pairing in a MNT6 bilinear group. /// 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`. /// A variable corresponding to `ark_ec::mnt6::GT`.
pub type GTVar<P> = Fp6G<P>; pub type GTVar<P> = Fp6G<P>;
impl<P: MNT6Parameters> PairingVar<P> {
impl<P: MNT6Config> PairingVar<P> {
#[tracing::instrument(target = "r1cs", skip(r))] #[tracing::instrument(target = "r1cs", skip(r))]
pub(crate) fn doubling_step_for_flipped_miller_loop( pub(crate) fn doubling_step_for_flipped_miller_loop(
r: &G2ProjectiveExtendedVar<P>, r: &G2ProjectiveExtendedVar<P>,
@ -191,7 +191,7 @@ impl PairingVar

{

} }
} }
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 G1Var = G1Var<P>;
type G2Var = G2Var<P>; type G2Var = G2Var<P>;
type G1PreparedVar = G1PreparedVar<P>; type G1PreparedVar = G1PreparedVar<P>;

Loading…
Cancel
Save