Skip to content
Permalink
Browse files

Use operator syntax

eliminate a few redundant references
  • Loading branch information
huitseeker authored and Pratyush committed Dec 2, 2019
1 parent a95bcd0 commit 23ec653b85c1c1177248c826677b5d1f80d99c76
@@ -241,7 +241,7 @@ impl MNT6 {
ac.c_rz * &p.y_twist,
-(q.y_over_twist * &ac.c_rz + &(l1_coeff * &ac.c_l1)),
);
f = f * &g_rq_at_p;
f *= &g_rq_at_p;
}
}

@@ -272,7 +272,7 @@ impl MNT6 {
let mut elt_q3 = elt.clone();
elt_q3.frobenius_map(3);
// elt_q3_over_elt = elt^(q^3-1)
let elt_q3_over_elt = elt_q3 * &elt_inv;
let elt_q3_over_elt = elt_q3 * elt_inv;
// alpha = elt^((q^3-1) * q)
let mut alpha = elt_q3_over_elt.clone();
alpha.frobenius_map(1);
@@ -208,7 +208,7 @@ use rand_xorshift::XorShiftRng;
for _ in 0..1000 {
let mut a = Fq2::rand(&mut rng);
let mut b = a;
a = a * &Fq6Parameters::NONRESIDUE;
a *= &Fq6Parameters::NONRESIDUE;
b *= &nqr;

assert_eq!(a, b);
@@ -85,9 +85,9 @@ impl<P: Fp6Parameters> Fp6<P> {
found_nonzero = true;

if value > 0 {
res = res * self;
res *= self;
} else {
res = res * &self_inverse;
res *= &self_inverse;
}
}
}
@@ -134,10 +134,10 @@ impl<G: Group, W: PedersenWindow> FixedLengthCRH for BoweHopwoodPedersenCRH<G, W
.map(|(chunk_bits, generator)| {
let mut encoded = generator.clone();
if chunk_bits[0] {
encoded = encoded + &generator;
encoded = encoded + generator;
}
if chunk_bits[1] {
encoded = encoded + &generator.double();
encoded += &generator.double();
}
if chunk_bits[2] {
encoded = encoded.neg();
@@ -106,7 +106,7 @@ impl<G: Group, W: PedersenWindow> FixedLengthCRH for PedersenCRH<G, W> {
let mut encoded = G::zero();
for (bit, base) in bits.iter().zip(generator_powers.iter()) {
if *bit {
encoded = encoded + base;
encoded += base;
}
}
encoded
@@ -71,7 +71,7 @@ impl<F: Field> ConstraintSynthesizer<F> for Benchmark<F> {
for (val, var) in assignments {
a_lc = a_lc + var;
b_lc = b_lc + var;
c_val = c_val + &val;
c_val += &val;
}
c_val = c_val.square();

@@ -49,7 +49,7 @@ impl R1CStoSAP {
Index::Aux(i) => assembly.num_inputs + i,
};

a[index] += &(u_add * &coeff);
a[index] += &(u_add * coeff);
}

for &(ref coeff, index) in assembly.bt[i].iter() {
@@ -58,7 +58,7 @@ impl R1CStoSAP {
Index::Aux(i) => assembly.num_inputs + i,
};

a[index] += &(u_sub * &coeff);
a[index] += &(u_sub * coeff);
}

for &(ref coeff, index) in assembly.ct[i].iter() {
@@ -67,7 +67,7 @@ impl R1CStoSAP {
Index::Aux(i) => assembly.num_inputs + i,
};

c[index] += &((u_2i * &coeff).double().double());
c[index] += &((u_2i * coeff).double().double());
}
c[extra_var_offset + i].add_assign(&u_add);
}
@@ -44,23 +44,23 @@ impl R1CStoQAP {
Index::Aux(i) => assembly.num_inputs + i,
};

a[index] += &(u[i] * &coeff);
a[index] += &(u[i] * coeff);
}
for &(ref coeff, index) in assembly.bt[i].iter() {
let index = match index {
Index::Input(i) => i,
Index::Aux(i) => assembly.num_inputs + i,
};

b[index] += &(u[i] * &coeff);
b[index] += &(u[i] * coeff);
}
for &(ref coeff, index) in assembly.ct[i].iter() {
let index = match index {
Index::Input(i) => i,
Index::Aux(i) => assembly.num_inputs + i,
};

c[index] += &(u[i] * &coeff);
c[index] += &(u[i] * coeff);
}
}

@@ -125,7 +125,7 @@ impl R1CStoQAP {
h.par_iter_mut()
.zip(&a)
.zip(&b)
.for_each(|((h_i, a_i), b_i)| *h_i *= &(*d2 * &a_i + &(*d1 * &b_i)));
.for_each(|((h_i, a_i), b_i)| *h_i *= &(*d2 * a_i + &(*d1 * b_i)));
h[0].sub_assign(&d3);
let d1d2 = *d1 * d2;
h[0].sub_assign(&d1d2);
@@ -205,7 +205,7 @@ impl UInt32 {
all_constants = false;

// Add coeff * bit_gadget
lc = lc + (coeff, bit.get_variable());
lc += (coeff, bit.get_variable());
},
Boolean::Not(ref bit) => {
all_constants = false;
@@ -215,7 +215,7 @@ impl UInt32 {
},
Boolean::Constant(bit) => {
if bit {
lc = lc + (coeff, CS::one());
lc += (coeff, CS::one());
}
},
}
@@ -364,7 +364,7 @@ impl<F: PrimeField> ToBitsGadget<F> for FpGadget<F> {
let mut coeff = F::one();

for bit in bits.iter().rev() {
lc = lc + (coeff, bit.get_variable());
lc += (coeff, bit.get_variable());

coeff.double_in_place();
}
@@ -412,7 +412,7 @@ impl<F: PrimeField> ToBytesGadget<F> for FpGadget<F> {
{
match bit {
Boolean::Is(bit) => {
lc = lc + (coeff, bit.get_variable());
lc += (coeff, bit.get_variable());
coeff.double_in_place();
},
Boolean::Constant(_) | Boolean::Not(_) => unreachable!(),
@@ -994,7 +994,7 @@ mod projective_impl {
let mut coords = vec![];
for _ in 0..4 {
coords.push(acc_power);
acc_power = acc_power + base_power;
acc_power += base_power;
}

let bits = bits.borrow().to_bits(

0 comments on commit 23ec653

Please sign in to comment.
You can’t perform that action at this time.