Browse Source

Use built-in iteration functions more

master
François Garillot 5 years ago
committed by Pratyush Mishra
parent
commit
53a51eb4dc
5 changed files with 6 additions and 9 deletions
  1. +2
    -2
      crypto-primitives/src/crh/bowe_hopwood/mod.rs
  2. +1
    -1
      crypto-primitives/src/crh/pedersen/mod.rs
  3. +1
    -1
      r1cs-std/src/bits/boolean.rs
  4. +1
    -1
      r1cs-std/src/fields/mod.rs
  5. +1
    -4
      r1cs-std/src/lib.rs

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

@ -144,9 +144,9 @@ impl FixedLengthCRH for BoweHopwoodPedersenCRH
}
encoded
})
.reduce(|| G::zero(), |a, b| a + &b)
.reduce(G::zero, |a, b| a + &b)
})
.reduce(|| G::zero(), |a, b| a + &b);
.reduce(G::zero, |a, b| a + &b);
end_timer!(eval_time);
Ok(result)

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

@ -111,7 +111,7 @@ impl FixedLengthCRH for PedersenCRH {
}
encoded
})
.reduce(|| G::zero(), |a, b| a + &b);
.reduce(G::zero, |a, b| a + &b);
end_timer!(eval_time);
Ok(result)

+ 1
- 1
r1cs-std/src/bits/boolean.rs

@ -586,7 +586,7 @@ impl Boolean {
// This is part of a run of ones.
current_run.push(a.clone());
} else {
if current_run.len() > 0 {
if !current_run.is_empty() {
// This is the start of a run of zeros, but we need
// to k-ary AND against `last_run` first.

+ 1
- 1
r1cs-std/src/fields/mod.rs

@ -405,7 +405,7 @@ mod test {
assert_eq!(a_inv.get_value().unwrap(), a_native.inverse().unwrap());
// a * a * a = a^3
let bits = BitIterator::new([0x3])
.map(|bit| Boolean::constant(bit))
.map(Boolean::constant)
.collect::<Vec<_>>();
assert_eq!(
a_native * &(a_native * &a_native),

+ 1
- 4
r1cs-std/src/lib.rs

@ -71,9 +71,6 @@ pub trait Assignment {
impl<T> Assignment<T> for Option<T> {
fn get(self) -> Result<T, r1cs_core::SynthesisError> {
match self {
Some(v) => Ok(v),
None => Err(r1cs_core::SynthesisError::AssignmentMissing),
}
self.ok_or_else(|| { r1cs_core::SynthesisError::AssignmentMissing })
}
}

Loading…
Cancel
Save