Browse Source

Use operator syntax

eliminate a few redundant references
master
François Garillot 5 years ago
committed by Pratyush Mishra
parent
commit
f1d8b122fc
5 changed files with 8 additions and 8 deletions
  1. +2
    -2
      crypto-primitives/src/crh/bowe_hopwood/mod.rs
  2. +1
    -1
      crypto-primitives/src/crh/pedersen/mod.rs
  3. +2
    -2
      r1cs-std/src/bits/uint32.rs
  4. +2
    -2
      r1cs-std/src/fields/fp.rs
  5. +1
    -1
      r1cs-std/src/groups/curves/twisted_edwards/mod.rs

+ 2
- 2
crypto-primitives/src/crh/bowe_hopwood/mod.rs

@ -134,10 +134,10 @@ impl FixedLengthCRH for BoweHopwoodPedersenCRH
.map(|(chunk_bits, generator)| { .map(|(chunk_bits, generator)| {
let mut encoded = generator.clone(); let mut encoded = generator.clone();
if chunk_bits[0] { if chunk_bits[0] {
encoded = encoded + &generator;
encoded = encoded + generator;
} }
if chunk_bits[1] { if chunk_bits[1] {
encoded = encoded + &generator.double();
encoded += &generator.double();
} }
if chunk_bits[2] { if chunk_bits[2] {
encoded = encoded.neg(); encoded = encoded.neg();

+ 1
- 1
crypto-primitives/src/crh/pedersen/mod.rs

@ -106,7 +106,7 @@ impl FixedLengthCRH for PedersenCRH {
let mut encoded = G::zero(); let mut encoded = G::zero();
for (bit, base) in bits.iter().zip(generator_powers.iter()) { for (bit, base) in bits.iter().zip(generator_powers.iter()) {
if *bit { if *bit {
encoded = encoded + base;
encoded += base;
} }
} }
encoded encoded

+ 2
- 2
r1cs-std/src/bits/uint32.rs

@ -205,7 +205,7 @@ impl UInt32 {
all_constants = false; all_constants = false;
// Add coeff * bit_gadget // Add coeff * bit_gadget
lc = lc + (coeff, bit.get_variable());
lc += (coeff, bit.get_variable());
}, },
Boolean::Not(ref bit) => { Boolean::Not(ref bit) => {
all_constants = false; all_constants = false;
@ -215,7 +215,7 @@ impl UInt32 {
}, },
Boolean::Constant(bit) => { Boolean::Constant(bit) => {
if bit { if bit {
lc = lc + (coeff, CS::one());
lc += (coeff, CS::one());
} }
}, },
} }

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

@ -364,7 +364,7 @@ impl ToBitsGadget for FpGadget {
let mut coeff = F::one(); let mut coeff = F::one();
for bit in bits.iter().rev() { for bit in bits.iter().rev() {
lc = lc + (coeff, bit.get_variable());
lc += (coeff, bit.get_variable());
coeff.double_in_place(); coeff.double_in_place();
} }
@ -412,7 +412,7 @@ impl ToBytesGadget for FpGadget {
{ {
match bit { match bit {
Boolean::Is(bit) => { Boolean::Is(bit) => {
lc = lc + (coeff, bit.get_variable());
lc += (coeff, bit.get_variable());
coeff.double_in_place(); coeff.double_in_place();
}, },
Boolean::Constant(_) | Boolean::Not(_) => unreachable!(), Boolean::Constant(_) | Boolean::Not(_) => unreachable!(),

+ 1
- 1
r1cs-std/src/groups/curves/twisted_edwards/mod.rs

@ -994,7 +994,7 @@ mod projective_impl {
let mut coords = vec![]; let mut coords = vec![];
for _ in 0..4 { for _ in 0..4 {
coords.push(acc_power); coords.push(acc_power);
acc_power = acc_power + base_power;
acc_power += base_power;
} }
let bits = bits.borrow().to_bits( let bits = bits.borrow().to_bits(

Loading…
Cancel
Save