Browse Source

Remove a few unnecessary clones

master
François Garillot 5 years ago
committed by Pratyush Mishra
parent
commit
c42c7dd98a
5 changed files with 10 additions and 10 deletions
  1. +1
    -1
      crypto-primitives/src/nizk/gm17/constraints.rs
  2. +2
    -2
      r1cs-std/src/fields/fp2.rs
  3. +2
    -2
      r1cs-std/src/pairing/bls12/mod.rs
  4. +4
    -4
      r1cs-std/src/pairing/mod.rs
  5. +1
    -1
      r1cs-std/src/test_constraint_system.rs

+ 1
- 1
crypto-primitives/src/nizk/gm17/constraints.rs

@ -180,7 +180,7 @@ where
P::miller_loop( P::miller_loop(
cs.ns(|| "Miller loop 4"), cs.ns(|| "Miller loop 4"),
&[a_prep, pvk.g_gamma_pc.clone()], &[a_prep, pvk.g_gamma_pc.clone()],
&[pvk.h_gamma_pc.clone(), b_prep],
&[pvk.h_gamma_pc, b_prep],
)? )?
}; };
let test2 = P::final_exponentiation(cs.ns(|| "Final Exp 2"), &test2_exp)?; let test2 = P::final_exponentiation(cs.ns(|| "Final Exp 2"), &test2_exp)?;

+ 2
- 2
r1cs-std/src/fields/fp2.rs

@ -76,8 +76,8 @@ impl, ConstraintF: PrimeField> FieldGadget
#[inline] #[inline]
fn get_variable(&self) -> Self::Variable { fn get_variable(&self) -> Self::Variable {
( (
self.c0.get_variable().clone(),
self.c1.get_variable().clone(),
self.c0.get_variable(),
self.c1.get_variable(),
) )
} }

+ 2
- 2
r1cs-std/src/pairing/bls12/mod.rs

@ -39,7 +39,7 @@ impl PairingGadget

{

TwistType::M => { TwistType::M => {
let c0 = coeffs.0.clone(); let c0 = coeffs.0.clone();
let mut c1 = coeffs.1.clone(); let mut c1 = coeffs.1.clone();
let c2 = Fp2G::<P>::new(p.y.clone(), zero.clone());
let c2 = Fp2G::<P>::new(p.y.clone(), zero);
c1.c0 = c1.c0.mul(cs.ns(|| "mul c1.c0"), &p.x)?; c1.c0 = c1.c0.mul(cs.ns(|| "mul c1.c0"), &p.x)?;
c1.c1 = c1.c1.mul(cs.ns(|| "mul c1.c1"), &p.x)?; c1.c1 = c1.c1.mul(cs.ns(|| "mul c1.c1"), &p.x)?;
@ -47,7 +47,7 @@ impl PairingGadget

{

Ok(()) Ok(())
}, },
TwistType::D => { TwistType::D => {
let c0 = Fp2G::<P>::new(p.y.clone(), zero.clone());
let c0 = Fp2G::<P>::new(p.y.clone(), zero);
let mut c1 = coeffs.0.clone(); let mut c1 = coeffs.0.clone();
let c2 = coeffs.1.clone(); let c2 = coeffs.1.clone();

+ 4
- 4
r1cs-std/src/pairing/mod.rs

@ -108,7 +108,7 @@ mod test {
let (ans1_g, ans1_n) = { let (ans1_g, ans1_n) = {
let ans_g = PairingGadget::pairing( let ans_g = PairingGadget::pairing(
cs.ns(|| "pair(sa, b)"), cs.ns(|| "pair(sa, b)"),
sa_prep_g.clone(),
sa_prep_g,
b_prep_g.clone(), b_prep_g.clone(),
) )
.unwrap(); .unwrap();
@ -120,7 +120,7 @@ mod test {
let ans_g = PairingGadget::pairing( let ans_g = PairingGadget::pairing(
cs.ns(|| "pair(a, sb)"), cs.ns(|| "pair(a, sb)"),
a_prep_g.clone(), a_prep_g.clone(),
sb_prep_g.clone(),
sb_prep_g,
) )
.unwrap(); .unwrap();
let ans_n = Bls12_377::pairing(a, sb); let ans_n = Bls12_377::pairing(a, sb);
@ -129,11 +129,11 @@ mod test {
let (ans3_g, ans3_n) = { let (ans3_g, ans3_n) = {
let s_iter = BitIterator::new(s.into_repr()) let s_iter = BitIterator::new(s.into_repr())
.map(|bit| Boolean::constant(bit))
.map(Boolean::constant)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let mut ans_g = let mut ans_g =
PairingGadget::pairing(cs.ns(|| "pair(a, b)"), a_prep_g.clone(), b_prep_g.clone())
PairingGadget::pairing(cs.ns(|| "pair(a, b)"), a_prep_g, b_prep_g)
.unwrap(); .unwrap();
let mut ans_n = Bls12_377::pairing(a, b); let mut ans_n = Bls12_377::pairing(a, b);
ans_n = ans_n.pow(s.into_repr()); ans_n = ans_n.pow(s.into_repr());

+ 1
- 1
r1cs-std/src/test_constraint_system.rs

@ -212,7 +212,7 @@ impl ConstraintSystem for TestConstraintSystem<
{ {
let name = name_fn().into(); let name = name_fn().into();
let path = compute_path(&self.current_namespace, name.clone()); let path = compute_path(&self.current_namespace, name.clone());
self.set_named_obj(path.clone(), NamedObject::Namespace);
self.set_named_obj(path, NamedObject::Namespace);
self.current_namespace.push(name); self.current_namespace.push(name);
} }

Loading…
Cancel
Save