Browse Source

Fix doctests

reduce-generics
Pratyush Mishra 3 years ago
parent
commit
5860e2a968
6 changed files with 36 additions and 36 deletions
  1. +6
    -6
      bls12_377/src/constraints/mod.rs
  2. +6
    -6
      curve-constraint-tests/src/lib.rs
  3. +6
    -6
      mnt4_298/src/constraints/mod.rs
  4. +6
    -6
      mnt4_753/src/constraints/mod.rs
  5. +6
    -6
      mnt6_298/src/constraints/mod.rs
  6. +6
    -6
      mnt6_753/src/constraints/mod.rs

+ 6
- 6
bls12_377/src/constraints/mod.rs

@ -130,17 +130,17 @@
//! let pairing_result_native = Bls12_377::pairing(a_native, b_native); //! let pairing_result_native = Bls12_377::pairing(a_native, b_native);
//! //!
//! // Prepare `a` and `b` for pairing. //! // 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. //! // Check that the value of &a + &b is correct.
//! assert_eq!(pairing_result.value()?, pairing_result_native); //! assert_eq!(pairing_result.value()?, pairing_result_native);
//! //!
//! // Check that operations on variables and constants are equivalent. //! // 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"); //! println!("Done here 3");
//! //!
//! pairing_result.enforce_equal(&pairing_result_const)?; //! pairing_result.enforce_equal(&pairing_result_const)?;

+ 6
- 6
curve-constraint-tests/src/lib.rs

@ -277,14 +277,14 @@ pub mod curves {
assert_eq!((&a + &zero).value()?, a.value()?); assert_eq!((&a + &zero).value()?, a.value()?);
// a - 0 = a // a - 0 = a
assert_eq!((&a - &zero).value()?, a.value()?); assert_eq!((&a - &zero).value()?, a.value()?);
// a - a = 0
assert_eq!((&a - &a).value()?, zero.value()?);
// a + b = b + a // a + b = b + a
let a_b = &a + &b; let a_b = &a + &b;
let b_a = &b + &a; let b_a = &b + &a;
assert_eq!(a_b.value()?, b_a.value()?); assert_eq!(a_b.value()?, b_a.value()?);
a_b.enforce_equal(&b_a)?; a_b.enforce_equal(&b_a)?;
assert!(cs.is_satisfied().unwrap()); assert!(cs.is_satisfied().unwrap());
// a - a = 0
assert_eq!((&a - &a).value()?, zero.value()?);
// (a + b) + a = a + (b + a) // (a + b) + a = a + (b + a)
let ab_a = &a_b + &a; let ab_a = &a_b + &a;
@ -580,15 +580,15 @@ pub mod pairing {
let (ans1_g, ans1_n) = { let (ans1_g, ans1_n) = {
let _ml_constraints = cs.num_constraints(); let _ml_constraints = cs.num_constraints();
let ml_g = <P as PairingGadget>::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 _fe_constraints = cs.num_constraints();
let ans_g = <P as PairingGadget>::final_exponentiation(&ml_g)?;
let ans_g = P::final_exponentiation_gadget(&ml_g)?;
let ans_n = <P as PairingEngine>::pairing(sa, b); let ans_n = <P as PairingEngine>::pairing(sa, b);
(ans_g, ans_n) (ans_g, ans_n)
}; };
let (ans2_g, ans2_n) = { let (ans2_g, ans2_n) = {
let ans_g = <P as PairingGadget>::pairing(a_prep_g.clone(), sb_prep_g)?;
let ans_g = P::pairing_gadget(a_prep_g.clone(), sb_prep_g)?;
let ans_n = <P as PairingEngine>::pairing(a, sb); let ans_n = <P as PairingEngine>::pairing(a, sb);
(ans_g, ans_n) (ans_g, ans_n)
}; };
@ -598,7 +598,7 @@ pub mod pairing {
.map(Boolean::constant) .map(Boolean::constant)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let mut ans_g = <P as PairingGadget>::pairing(a_prep_g, b_prep_g)?;
let mut ans_g = P::pairing_gadget(a_prep_g, b_prep_g)?;
let mut ans_n = <P as PairingEngine>::pairing(a, b); let mut ans_n = <P as PairingEngine>::pairing(a, b);
ans_n = ans_n.pow(s.into_repr()); ans_n = ans_n.pow(s.into_repr());
ans_g = ans_g.pow_le(&s_iter)?; ans_g = ans_g.pow_le(&s_iter)?;

+ 6
- 6
mnt4_298/src/constraints/mod.rs

@ -130,17 +130,17 @@
//! let pairing_result_native = MNT4_298::pairing(a_native, b_native); //! let pairing_result_native = MNT4_298::pairing(a_native, b_native);
//! //!
//! // Prepare `a` and `b` for pairing. //! // 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. //! // Check that the value of &a + &b is correct.
//! assert_eq!(pairing_result.value()?, pairing_result_native); //! assert_eq!(pairing_result.value()?, pairing_result_native);
//! //!
//! // Check that operations on variables and constants are equivalent. //! // 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"); //! println!("Done here 3");
//! //!
//! pairing_result.enforce_equal(&pairing_result_const)?; //! pairing_result.enforce_equal(&pairing_result_const)?;

+ 6
- 6
mnt4_753/src/constraints/mod.rs

@ -130,17 +130,17 @@
//! let pairing_result_native = MNT4_753::pairing(a_native, b_native); //! let pairing_result_native = MNT4_753::pairing(a_native, b_native);
//! //!
//! // Prepare `a` and `b` for pairing. //! // 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. //! // Check that the value of &a + &b is correct.
//! assert_eq!(pairing_result.value()?, pairing_result_native); //! assert_eq!(pairing_result.value()?, pairing_result_native);
//! //!
//! // Check that operations on variables and constants are equivalent. //! // 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"); //! println!("Done here 3");
//! //!
//! pairing_result.enforce_equal(&pairing_result_const)?; //! pairing_result.enforce_equal(&pairing_result_const)?;

+ 6
- 6
mnt6_298/src/constraints/mod.rs

@ -130,17 +130,17 @@
//! let pairing_result_native = MNT6_298::pairing(a_native, b_native); //! let pairing_result_native = MNT6_298::pairing(a_native, b_native);
//! //!
//! // Prepare `a` and `b` for pairing. //! // 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. //! // Check that the value of &a + &b is correct.
//! assert_eq!(pairing_result.value()?, pairing_result_native); //! assert_eq!(pairing_result.value()?, pairing_result_native);
//! //!
//! // Check that operations on variables and constants are equivalent. //! // 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"); //! println!("Done here 3");
//! //!
//! pairing_result.enforce_equal(&pairing_result_const)?; //! pairing_result.enforce_equal(&pairing_result_const)?;

+ 6
- 6
mnt6_753/src/constraints/mod.rs

@ -130,17 +130,17 @@
//! let pairing_result_native = MNT6_753::pairing(a_native, b_native); //! let pairing_result_native = MNT6_753::pairing(a_native, b_native);
//! //!
//! // Prepare `a` and `b` for pairing. //! // 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. //! // Check that the value of &a + &b is correct.
//! assert_eq!(pairing_result.value()?, pairing_result_native); //! assert_eq!(pairing_result.value()?, pairing_result_native);
//! //!
//! // Check that operations on variables and constants are equivalent. //! // 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"); //! println!("Done here 3");
//! //!
//! pairing_result.enforce_equal(&pairing_result_const)?; //! pairing_result.enforce_equal(&pairing_result_const)?;

Loading…
Cancel
Save