diff --git a/Cargo.toml b/Cargo.toml index ba7ae624..89d112f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,3 +56,6 @@ lto = "thin" incremental = true debug-assertions = true debug = true + +[patch.crates-io] +ark-r1cs-std = { git = "https://github.com/arkworks-rs/r1cs-std", branch = "reduce-generics", optional = true, default-features = false } \ No newline at end of file diff --git a/bls12_377/Cargo.toml b/bls12_377/Cargo.toml index 63ac9fab..19086a47 100644 --- a/bls12_377/Cargo.toml +++ b/bls12_377/Cargo.toml @@ -31,4 +31,4 @@ std = [ "ark-std/std", "ark-ff/std", "ark-ec/std" ] curve = [ "scalar_field", "base_field" ] scalar_field = [] base_field = [] -r1cs = [ "base_field", "ark-r1cs-std" ] \ No newline at end of file +r1cs = [ "base_field", "ark-r1cs-std" ] diff --git a/bls12_377/src/constraints/curves.rs b/bls12_377/src/constraints/curves.rs index 5441eba0..3b4cedb7 100644 --- a/bls12_377/src/constraints/curves.rs +++ b/bls12_377/src/constraints/curves.rs @@ -16,14 +16,8 @@ pub type G2PreparedVar = bls12::G2PreparedVar; #[test] fn test() { use ark_ec::models::bls12::Bls12Parameters; - ark_curve_constraint_tests::curves::sw_test::< - ::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - ::G2Parameters, - G2Var, - >() - .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G1Parameters>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G2Parameters>() + .unwrap(); } diff --git a/bls12_377/src/constraints/mod.rs b/bls12_377/src/constraints/mod.rs index a67838f5..24b9a587 100644 --- a/bls12_377/src/constraints/mod.rs +++ b/bls12_377/src/constraints/mod.rs @@ -130,17 +130,17 @@ //! let pairing_result_native = Bls12_377::pairing(a_native, b_native); //! //! // Prepare `a` and `b` for pairing. -//! let a_prep = constraints::PairingVar::prepare_g1(&a)?; -//! let b_prep = constraints::PairingVar::prepare_g2(&b)?; -//! let pairing_result = constraints::PairingVar::pairing(a_prep, b_prep)?; +//! let a_prep = Bls12_377::prepare_g1(&a)?; +//! let b_prep = Bls12_377::prepare_g2(&b)?; +//! let pairing_result = Bls12_377::pairing_gadget(a_prep, b_prep)?; //! //! // Check that the value of &a + &b is correct. //! assert_eq!(pairing_result.value()?, pairing_result_native); //! //! // Check that operations on variables and constants are equivalent. -//! let a_prep_const = constraints::PairingVar::prepare_g1(&a_const)?; -//! let b_prep_const = constraints::PairingVar::prepare_g2(&b_const)?; -//! let pairing_result_const = constraints::PairingVar::pairing(a_prep_const, b_prep_const)?; +//! let a_prep_const = Bls12_377::prepare_g1(&a_const)?; +//! let b_prep_const = Bls12_377::prepare_g2(&b_const)?; +//! let pairing_result_const = Bls12_377::pairing_gadget(a_prep_const, b_prep_const)?; //! println!("Done here 3"); //! //! pairing_result.enforce_equal(&pairing_result_const)?; diff --git a/bls12_377/src/constraints/pairing.rs b/bls12_377/src/constraints/pairing.rs index f659f294..cd664aae 100644 --- a/bls12_377/src/constraints/pairing.rs +++ b/bls12_377/src/constraints/pairing.rs @@ -1,10 +1,8 @@ -use crate::Parameters; - /// Specifies the constraints for computing a pairing in the BLS12-377 bilinear group. -pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar; +pub use crate::Bls12_377; #[test] fn test() { use crate::Bls12_377; - ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() + ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() } diff --git a/curve-constraint-tests/src/lib.rs b/curve-constraint-tests/src/lib.rs index ed2c59d3..797425ba 100644 --- a/curve-constraint-tests/src/lib.rs +++ b/curve-constraint-tests/src/lib.rs @@ -233,7 +233,8 @@ pub mod fields { pub mod curves { use ark_ec::{ short_weierstrass_jacobian::GroupProjective as SWProjective, - twisted_edwards_extended::GroupProjective as TEProjective, ProjectiveCurve, + twisted_edwards_extended::GroupProjective as TEProjective, ModelParameters, + ProjectiveCurve, }; use ark_ff::{BitIteratorLE, Field, FpParameters, One, PrimeField}; use ark_relations::r1cs::{ConstraintSystem, SynthesisError}; @@ -241,12 +242,13 @@ pub mod curves { use ark_r1cs_std::prelude::*; - pub fn group_test() -> Result<(), SynthesisError> + type ConstraintF

= <

::BaseField as Field>::BasePrimeField; + + pub fn group_test() -> Result<(), SynthesisError> where - C: ProjectiveCurve, + C: CurveWithVar, ConstraintF: Field, - GG: CurveVar, - for<'a> &'a GG: GroupOpsBounds<'a, C, GG>, + for<'a> &'a C::Var: GroupOpsBounds<'a, C, C::Var>, { let modes = [ AllocationMode::Input, @@ -259,12 +261,14 @@ pub mod curves { let mut rng = test_rng(); let a_native = C::rand(&mut rng); let b_native = C::rand(&mut rng); - let a = GG::new_variable(ark_relations::ns!(cs, "generate_a"), || Ok(a_native), mode) - .unwrap(); - let b = GG::new_variable(ark_relations::ns!(cs, "generate_b"), || Ok(b_native), mode) - .unwrap(); - - let zero = GG::zero(); + let a = + C::Var::new_variable(ark_relations::ns!(cs, "generate_a"), || Ok(a_native), mode) + .unwrap(); + let b = + C::Var::new_variable(ark_relations::ns!(cs, "generate_b"), || Ok(b_native), mode) + .unwrap(); + + let zero = C::Var::zero(); assert_eq!(zero.value()?, zero.value()?); // a == a @@ -273,14 +277,14 @@ pub mod curves { assert_eq!((&a + &zero).value()?, a.value()?); // a - 0 = a assert_eq!((&a - &zero).value()?, a.value()?); - // a - a = 0 - assert_eq!((&a - &a).value()?, zero.value()?); // a + b = b + a let a_b = &a + &b; let b_a = &b + &a; assert_eq!(a_b.value()?, b_a.value()?); a_b.enforce_equal(&b_a)?; assert!(cs.is_satisfied().unwrap()); + // a - a = 0 + assert_eq!((&a - &a).value()?, zero.value()?); // (a + b) + a = a + (b + a) let ab_a = &a_b + &a; @@ -380,13 +384,15 @@ pub mod curves { Ok(()) } - pub fn sw_test() -> Result<(), SynthesisError> + type SWVar

= as CurveWithVar>>::Var; + + pub fn sw_test

() -> Result<(), SynthesisError> where P: ark_ec::SWModelParameters, - GG: CurveVar, ::BasePrimeField>, - for<'a> &'a GG: GroupOpsBounds<'a, SWProjective

, GG>, + SWProjective

: CurveWithVar> + ProjectiveCurve, + for<'a> &'a SWVar

: GroupOpsBounds<'a, SWProjective

, SWVar

>, { - group_test::, _, GG>()?; + group_test::, _>()?; let modes = [ AllocationMode::Input, AllocationMode::Witness, @@ -405,14 +411,12 @@ pub mod curves { let b_affine = b.into_affine(); let ns = ark_relations::ns!(cs, "allocating variables"); - let mut gadget_a = GG::new_variable(cs.clone(), || Ok(a), mode)?; - let gadget_b = GG::new_variable(cs.clone(), || Ok(b), mode)?; - let zero = GG::zero(); + let mut gadget_a = SWVar::

::new_variable(cs.clone(), || Ok(a), mode)?; + let gadget_b = SWVar::

::new_variable(cs.clone(), || Ok(b), mode)?; + let zero = SWVar::

::zero(); drop(ns); - assert_eq!(gadget_a.value()?.into_affine().x, a_affine.x); - assert_eq!(gadget_a.value()?.into_affine().y, a_affine.y); - assert_eq!(gadget_b.value()?.into_affine().x, b_affine.x); - assert_eq!(gadget_b.value()?.into_affine().y, b_affine.y); + assert_eq!(gadget_a.value()?.into_affine(), a_affine); + assert_eq!(gadget_b.value()?.into_affine(), b_affine); assert_eq!(cs.which_is_unsatisfied().unwrap(), None); // Check addition @@ -453,13 +457,15 @@ pub mod curves { Ok(()) } - pub fn te_test() -> Result<(), SynthesisError> + type TEVar

= as CurveWithVar>>::Var; + + pub fn te_test

() -> Result<(), SynthesisError> where P: ark_ec::TEModelParameters, - GG: CurveVar, ::BasePrimeField>, - for<'a> &'a GG: GroupOpsBounds<'a, TEProjective

, GG>, + TEProjective

: CurveWithVar> + ProjectiveCurve, + for<'a> &'a TEVar

: GroupOpsBounds<'a, TEProjective

, TEVar

>, { - group_test::, _, GG>()?; + group_test::, _>()?; let modes = [ AllocationMode::Input, AllocationMode::Witness, @@ -478,14 +484,12 @@ pub mod curves { let b_affine = b.into_affine(); let ns = ark_relations::ns!(cs, "allocating variables"); - let mut gadget_a = GG::new_variable(cs.clone(), || Ok(a), mode)?; - let gadget_b = GG::new_variable(cs.clone(), || Ok(b), mode)?; + let mut gadget_a = TEVar::

::new_variable(cs.clone(), || Ok(a), mode)?; + let gadget_b = TEVar::

::new_variable(cs.clone(), || Ok(b), mode)?; drop(ns); - assert_eq!(gadget_a.value()?.into_affine().x, a_affine.x); - assert_eq!(gadget_a.value()?.into_affine().y, a_affine.y); - assert_eq!(gadget_b.value()?.into_affine().x, b_affine.x); - assert_eq!(gadget_b.value()?.into_affine().y, b_affine.y); + assert_eq!(gadget_a.value()?.into_affine(), a_affine); + assert_eq!(gadget_b.value()?.into_affine(), b_affine); assert_eq!(cs.which_is_unsatisfied()?, None); // Check addition @@ -527,16 +531,21 @@ pub mod curves { pub mod pairing { use ark_ec::{PairingEngine, ProjectiveCurve}; use ark_ff::{BitIteratorLE, Field, PrimeField}; - use ark_r1cs_std::prelude::*; + use ark_r1cs_std::{fields::fp::FpVar, prelude::*}; use ark_relations::r1cs::{ConstraintSystem, SynthesisError}; use ark_std::{test_rng, vec::Vec, UniformRand}; #[allow(dead_code)] - pub fn bilinearity_test>() -> Result<(), SynthesisError> + pub fn bilinearity_test() -> Result<(), SynthesisError> where - for<'a> &'a P::G1Var: GroupOpsBounds<'a, E::G1Projective, P::G1Var>, - for<'a> &'a P::G2Var: GroupOpsBounds<'a, E::G2Projective, P::G2Var>, - for<'a> &'a P::GTVar: FieldOpsBounds<'a, E::Fqk, P::GTVar>, + for<'a> &'a P::G1Var: GroupOpsBounds<'a, P::G1Projective, P::G1Var>, + for<'a> &'a P::G2Var: GroupOpsBounds<'a, P::G2Projective, P::G2Var>, + for<'a> &'a P::GTVar: FieldOpsBounds<'a, P::Fqk, P::GTVar>, + P::Fq: FieldWithVar>, + P::Fqe: FieldWithVar, + P::Fqk: FieldWithVar, + P::G1Projective: CurveWithVar, + P::G2Projective: CurveWithVar, { let modes = [ AllocationMode::Input, @@ -544,12 +553,12 @@ pub mod pairing { AllocationMode::Constant, ]; for &mode in &modes { - let cs = ConstraintSystem::::new_ref(); + let cs = ConstraintSystem::::new_ref(); let mut rng = test_rng(); - let a = E::G1Projective::rand(&mut rng); - let b = E::G2Projective::rand(&mut rng); - let s = E::Fr::rand(&mut rng); + let a = P::G1Projective::rand(&mut rng); + let b = P::G2Projective::rand(&mut rng); + let s = P::Fr::rand(&mut rng); let mut sa = a; sa *= s; @@ -571,16 +580,16 @@ pub mod pairing { let (ans1_g, ans1_n) = { let _ml_constraints = cs.num_constraints(); - let ml_g = P::miller_loop(&[sa_prep_g], &[b_prep_g.clone()])?; + let ml_g = P::miller_loop_gadget(&[sa_prep_g], &[b_prep_g.clone()])?; let _fe_constraints = cs.num_constraints(); - let ans_g = P::final_exponentiation(&ml_g)?; - let ans_n = E::pairing(sa, b); + let ans_g = P::final_exponentiation_gadget(&ml_g)?; + let ans_n =

::pairing(sa, b); (ans_g, ans_n) }; let (ans2_g, ans2_n) = { - let ans_g = P::pairing(a_prep_g.clone(), sb_prep_g)?; - let ans_n = E::pairing(a, sb); + let ans_g = P::pairing_gadget(a_prep_g.clone(), sb_prep_g)?; + let ans_n =

::pairing(a, sb); (ans_g, ans_n) }; @@ -589,8 +598,8 @@ pub mod pairing { .map(Boolean::constant) .collect::>(); - let mut ans_g = P::pairing(a_prep_g, b_prep_g)?; - let mut ans_n = E::pairing(a, b); + let mut ans_g = P::pairing_gadget(a_prep_g, b_prep_g)?; + let mut ans_n =

::pairing(a, b); ans_n = ans_n.pow(s.into_repr()); ans_g = ans_g.pow_le(&s_iter)?; diff --git a/ed_on_bls12_377/src/constraints/curves.rs b/ed_on_bls12_377/src/constraints/curves.rs index 4b15106d..a6586102 100644 --- a/ed_on_bls12_377/src/constraints/curves.rs +++ b/ed_on_bls12_377/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar; -use crate::constraints::FqVar; - /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar; +pub type EdwardsVar = AffineVar; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::().unwrap(); + ark_curve_constraint_tests::curves::te_test::().unwrap(); } diff --git a/ed_on_bls12_381/src/constraints/curves.rs b/ed_on_bls12_381/src/constraints/curves.rs index 9c9f7837..a6586102 100644 --- a/ed_on_bls12_381/src/constraints/curves.rs +++ b/ed_on_bls12_381/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar; -use crate::constraints::FqVar; - /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar; +pub type EdwardsVar = AffineVar; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<_, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::().unwrap(); } diff --git a/ed_on_bls12_381_bandersnatch/src/constraints/curves.rs b/ed_on_bls12_381_bandersnatch/src/constraints/curves.rs index 9c9f7837..a6586102 100644 --- a/ed_on_bls12_381_bandersnatch/src/constraints/curves.rs +++ b/ed_on_bls12_381_bandersnatch/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar; -use crate::constraints::FqVar; - /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar; +pub type EdwardsVar = AffineVar; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<_, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::().unwrap(); } diff --git a/ed_on_bn254/src/constraints/curves.rs b/ed_on_bn254/src/constraints/curves.rs index 9c9f7837..a6586102 100644 --- a/ed_on_bn254/src/constraints/curves.rs +++ b/ed_on_bn254/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar; -use crate::constraints::FqVar; - /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar; +pub type EdwardsVar = AffineVar; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::<_, EdwardsVar>().unwrap(); + ark_curve_constraint_tests::curves::te_test::().unwrap(); } diff --git a/ed_on_cp6_782/src/constraints/curves.rs b/ed_on_cp6_782/src/constraints/curves.rs index 4b15106d..a6586102 100644 --- a/ed_on_cp6_782/src/constraints/curves.rs +++ b/ed_on_cp6_782/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar; -use crate::constraints::FqVar; - /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar; +pub type EdwardsVar = AffineVar; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::().unwrap(); + ark_curve_constraint_tests::curves::te_test::().unwrap(); } diff --git a/ed_on_mnt4_298/src/constraints/curves.rs b/ed_on_mnt4_298/src/constraints/curves.rs index 3ceded42..a6586102 100644 --- a/ed_on_mnt4_298/src/constraints/curves.rs +++ b/ed_on_mnt4_298/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar; -use crate::constraints::fields::FqVar; - /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar; +pub type EdwardsVar = AffineVar; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::().unwrap(); + ark_curve_constraint_tests::curves::te_test::().unwrap(); } diff --git a/ed_on_mnt4_753/src/constraints/curves.rs b/ed_on_mnt4_753/src/constraints/curves.rs index 3ceded42..a6586102 100644 --- a/ed_on_mnt4_753/src/constraints/curves.rs +++ b/ed_on_mnt4_753/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar; -use crate::constraints::fields::FqVar; - /// A variable that is the R1CS equivalent of `crate::EdwardsAffine`. -pub type EdwardsVar = AffineVar; +pub type EdwardsVar = AffineVar; #[test] fn test() { - ark_curve_constraint_tests::curves::te_test::().unwrap(); + ark_curve_constraint_tests::curves::te_test::().unwrap(); } diff --git a/mnt4_298/src/constraints/curves.rs b/mnt4_298/src/constraints/curves.rs index 46401164..6a49f0dd 100644 --- a/mnt4_298/src/constraints/curves.rs +++ b/mnt4_298/src/constraints/curves.rs @@ -16,14 +16,8 @@ pub type G2PreparedVar = mnt4::G2PreparedVar; #[test] fn test() { use ark_ec::models::mnt4::MNT4Parameters; - ark_curve_constraint_tests::curves::sw_test::< - ::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - ::G2Parameters, - G2Var, - >() - .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G1Parameters>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G2Parameters>() + .unwrap(); } diff --git a/mnt4_298/src/constraints/mod.rs b/mnt4_298/src/constraints/mod.rs index 48919084..2feb7ac2 100644 --- a/mnt4_298/src/constraints/mod.rs +++ b/mnt4_298/src/constraints/mod.rs @@ -130,17 +130,17 @@ //! let pairing_result_native = MNT4_298::pairing(a_native, b_native); //! //! // Prepare `a` and `b` for pairing. -//! let a_prep = constraints::PairingVar::prepare_g1(&a)?; -//! let b_prep = constraints::PairingVar::prepare_g2(&b)?; -//! let pairing_result = constraints::PairingVar::pairing(a_prep, b_prep)?; +//! let a_prep = MNT4_298::prepare_g1(&a)?; +//! let b_prep = MNT4_298::prepare_g2(&b)?; +//! let pairing_result = MNT4_298::pairing_gadget(a_prep, b_prep)?; //! //! // Check that the value of &a + &b is correct. //! assert_eq!(pairing_result.value()?, pairing_result_native); //! //! // Check that operations on variables and constants are equivalent. -//! let a_prep_const = constraints::PairingVar::prepare_g1(&a_const)?; -//! let b_prep_const = constraints::PairingVar::prepare_g2(&b_const)?; -//! let pairing_result_const = constraints::PairingVar::pairing(a_prep_const, b_prep_const)?; +//! let a_prep_const = MNT4_298::prepare_g1(&a_const)?; +//! let b_prep_const = MNT4_298::prepare_g2(&b_const)?; +//! let pairing_result_const = MNT4_298::pairing_gadget(a_prep_const, b_prep_const)?; //! println!("Done here 3"); //! //! pairing_result.enforce_equal(&pairing_result_const)?; diff --git a/mnt4_298/src/constraints/pairing.rs b/mnt4_298/src/constraints/pairing.rs index 7941ad05..5b5c195a 100644 --- a/mnt4_298/src/constraints/pairing.rs +++ b/mnt4_298/src/constraints/pairing.rs @@ -1,10 +1,8 @@ -use crate::Parameters; - /// Specifies the constraints for computing a pairing in the MNT4-298 bilinear group. -pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar; +pub use crate::MNT4_298; #[test] fn test() { use crate::MNT4_298; - ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() + ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() } diff --git a/mnt4_753/src/constraints/curves.rs b/mnt4_753/src/constraints/curves.rs index febfeeda..1ceba87e 100644 --- a/mnt4_753/src/constraints/curves.rs +++ b/mnt4_753/src/constraints/curves.rs @@ -16,14 +16,8 @@ pub type G2PreparedVar = mnt4::G2PreparedVar; #[test] fn test() { use ark_ec::models::mnt4::MNT4Parameters; - ark_curve_constraint_tests::curves::sw_test::< - ::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - ::G2Parameters, - G2Var, - >() - .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G1Parameters>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G2Parameters>() + .unwrap(); } diff --git a/mnt4_753/src/constraints/mod.rs b/mnt4_753/src/constraints/mod.rs index 4744e4c9..25a83235 100644 --- a/mnt4_753/src/constraints/mod.rs +++ b/mnt4_753/src/constraints/mod.rs @@ -130,17 +130,17 @@ //! let pairing_result_native = MNT4_753::pairing(a_native, b_native); //! //! // Prepare `a` and `b` for pairing. -//! let a_prep = constraints::PairingVar::prepare_g1(&a)?; -//! let b_prep = constraints::PairingVar::prepare_g2(&b)?; -//! let pairing_result = constraints::PairingVar::pairing(a_prep, b_prep)?; +//! let a_prep = MNT4_753::prepare_g1(&a)?; +//! let b_prep = MNT4_753::prepare_g2(&b)?; +//! let pairing_result = MNT4_753::pairing_gadget(a_prep, b_prep)?; //! //! // Check that the value of &a + &b is correct. //! assert_eq!(pairing_result.value()?, pairing_result_native); //! //! // Check that operations on variables and constants are equivalent. -//! let a_prep_const = constraints::PairingVar::prepare_g1(&a_const)?; -//! let b_prep_const = constraints::PairingVar::prepare_g2(&b_const)?; -//! let pairing_result_const = constraints::PairingVar::pairing(a_prep_const, b_prep_const)?; +//! let a_prep_const = MNT4_753::prepare_g1(&a_const)?; +//! let b_prep_const = MNT4_753::prepare_g2(&b_const)?; +//! let pairing_result_const = MNT4_753::pairing_gadget(a_prep_const, b_prep_const)?; //! println!("Done here 3"); //! //! pairing_result.enforce_equal(&pairing_result_const)?; diff --git a/mnt4_753/src/constraints/pairing.rs b/mnt4_753/src/constraints/pairing.rs index 3e00df45..24af61c7 100644 --- a/mnt4_753/src/constraints/pairing.rs +++ b/mnt4_753/src/constraints/pairing.rs @@ -1,10 +1,8 @@ -use crate::Parameters; - /// Specifies the constraints for computing a pairing in the MNT4-753 bilinear group. -pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar; +pub use crate::MNT4_753; #[test] fn test() { use crate::MNT4_753; - ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() + ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() } diff --git a/mnt6_298/src/constraints/curves.rs b/mnt6_298/src/constraints/curves.rs index 069ee9e2..9c35417e 100644 --- a/mnt6_298/src/constraints/curves.rs +++ b/mnt6_298/src/constraints/curves.rs @@ -16,14 +16,8 @@ pub type G2PreparedVar = mnt6::G2PreparedVar; #[test] fn test() { use ark_ec::models::mnt6::MNT6Parameters; - ark_curve_constraint_tests::curves::sw_test::< - ::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - ::G2Parameters, - G2Var, - >() - .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G1Parameters>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G2Parameters>() + .unwrap(); } diff --git a/mnt6_298/src/constraints/mod.rs b/mnt6_298/src/constraints/mod.rs index 00925676..6221424b 100644 --- a/mnt6_298/src/constraints/mod.rs +++ b/mnt6_298/src/constraints/mod.rs @@ -130,17 +130,17 @@ //! let pairing_result_native = MNT6_298::pairing(a_native, b_native); //! //! // Prepare `a` and `b` for pairing. -//! let a_prep = constraints::PairingVar::prepare_g1(&a)?; -//! let b_prep = constraints::PairingVar::prepare_g2(&b)?; -//! let pairing_result = constraints::PairingVar::pairing(a_prep, b_prep)?; +//! let a_prep = MNT6_298::prepare_g1(&a)?; +//! let b_prep = MNT6_298::prepare_g2(&b)?; +//! let pairing_result = MNT6_298::pairing_gadget(a_prep, b_prep)?; //! //! // Check that the value of &a + &b is correct. //! assert_eq!(pairing_result.value()?, pairing_result_native); //! //! // Check that operations on variables and constants are equivalent. -//! let a_prep_const = constraints::PairingVar::prepare_g1(&a_const)?; -//! let b_prep_const = constraints::PairingVar::prepare_g2(&b_const)?; -//! let pairing_result_const = constraints::PairingVar::pairing(a_prep_const, b_prep_const)?; +//! let a_prep_const = MNT6_298::prepare_g1(&a_const)?; +//! let b_prep_const = MNT6_298::prepare_g2(&b_const)?; +//! let pairing_result_const = MNT6_298::pairing_gadget(a_prep_const, b_prep_const)?; //! println!("Done here 3"); //! //! pairing_result.enforce_equal(&pairing_result_const)?; diff --git a/mnt6_298/src/constraints/pairing.rs b/mnt6_298/src/constraints/pairing.rs index 14641bea..1aaa4d3a 100644 --- a/mnt6_298/src/constraints/pairing.rs +++ b/mnt6_298/src/constraints/pairing.rs @@ -1,10 +1,8 @@ -use crate::Parameters; - /// Specifies the constraints for computing a pairing in the MNT6-298 bilinear group. -pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar; +pub use crate::MNT6_298; #[test] fn test() { use crate::MNT6_298; - ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() + ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() } diff --git a/mnt6_753/src/constraints/curves.rs b/mnt6_753/src/constraints/curves.rs index e747fd23..c7126d6e 100644 --- a/mnt6_753/src/constraints/curves.rs +++ b/mnt6_753/src/constraints/curves.rs @@ -16,14 +16,8 @@ pub type G2PreparedVar = mnt6::G2PreparedVar; #[test] fn test() { use ark_ec::models::mnt6::MNT6Parameters; - ark_curve_constraint_tests::curves::sw_test::< - ::G1Parameters, - G1Var, - >() - .unwrap(); - ark_curve_constraint_tests::curves::sw_test::< - ::G2Parameters, - G2Var, - >() - .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G1Parameters>() + .unwrap(); + ark_curve_constraint_tests::curves::sw_test::<::G2Parameters>() + .unwrap(); } diff --git a/mnt6_753/src/constraints/mod.rs b/mnt6_753/src/constraints/mod.rs index c540ac7f..29f025a8 100644 --- a/mnt6_753/src/constraints/mod.rs +++ b/mnt6_753/src/constraints/mod.rs @@ -130,17 +130,17 @@ //! let pairing_result_native = MNT6_753::pairing(a_native, b_native); //! //! // Prepare `a` and `b` for pairing. -//! let a_prep = constraints::PairingVar::prepare_g1(&a)?; -//! let b_prep = constraints::PairingVar::prepare_g2(&b)?; -//! let pairing_result = constraints::PairingVar::pairing(a_prep, b_prep)?; +//! let a_prep = MNT6_753::prepare_g1(&a)?; +//! let b_prep = MNT6_753::prepare_g2(&b)?; +//! let pairing_result = MNT6_753::pairing_gadget(a_prep, b_prep)?; //! //! // Check that the value of &a + &b is correct. //! assert_eq!(pairing_result.value()?, pairing_result_native); //! //! // Check that operations on variables and constants are equivalent. -//! let a_prep_const = constraints::PairingVar::prepare_g1(&a_const)?; -//! let b_prep_const = constraints::PairingVar::prepare_g2(&b_const)?; -//! let pairing_result_const = constraints::PairingVar::pairing(a_prep_const, b_prep_const)?; +//! let a_prep_const = MNT6_753::prepare_g1(&a_const)?; +//! let b_prep_const = MNT6_753::prepare_g2(&b_const)?; +//! let pairing_result_const = MNT6_753::pairing_gadget(a_prep_const, b_prep_const)?; //! println!("Done here 3"); //! //! pairing_result.enforce_equal(&pairing_result_const)?; diff --git a/mnt6_753/src/constraints/pairing.rs b/mnt6_753/src/constraints/pairing.rs index 8979aec8..3ef1b35c 100644 --- a/mnt6_753/src/constraints/pairing.rs +++ b/mnt6_753/src/constraints/pairing.rs @@ -1,10 +1,8 @@ -use crate::Parameters; - /// Specifies the constraints for computing a pairing in the MNT6-753 bilinear group. -pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar; +pub use crate::MNT6_753; #[test] fn test() { use crate::MNT6_753; - ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() + ark_curve_constraint_tests::pairing::bilinearity_test::().unwrap() } diff --git a/pallas/src/constraints/curves.rs b/pallas/src/constraints/curves.rs index 4f839b16..cf7faff9 100644 --- a/pallas/src/constraints/curves.rs +++ b/pallas/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar; -use crate::constraints::FBaseVar; - /// A group element in the Pallas prime-order group. -pub type GVar = ProjectiveVar; +pub type GVar = ProjectiveVar; #[test] fn test() { - ark_curve_constraint_tests::curves::sw_test::().unwrap(); + ark_curve_constraint_tests::curves::sw_test::().unwrap(); } diff --git a/vesta/src/constraints/curves.rs b/vesta/src/constraints/curves.rs index fac522a5..ed432b31 100644 --- a/vesta/src/constraints/curves.rs +++ b/vesta/src/constraints/curves.rs @@ -1,12 +1,10 @@ use crate::*; use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar; -use crate::constraints::FBaseVar; - /// A group element in the Vesta prime-order group. -pub type GVar = ProjectiveVar; +pub type GVar = ProjectiveVar; #[test] fn test() { - ark_curve_constraint_tests::curves::sw_test::().unwrap(); + ark_curve_constraint_tests::curves::sw_test::().unwrap(); }