mirror of https://github.com/zcash/orchard.git
utilities::range_check: Correct range_check expression
Previously, we were multiplying the expression by 0, which led it to always evaluate to true.
This commit is contained in:
parent
8a9f8218e9
commit
6c41c72e66
|
@ -123,10 +123,9 @@ pub fn bitrange_subset<F: FieldExt + PrimeFieldBits>(field_elem: F, bitrange: Ra
|
|||
/// Check that an expression is in the small range [0..range),
|
||||
/// i.e. 0 ≤ word < range.
|
||||
pub fn range_check<F: FieldExt>(word: Expression<F>, range: usize) -> Expression<F> {
|
||||
(0..range)
|
||||
.map(|i| Expression::Constant(F::from_u64(i as u64)))
|
||||
.reduce(|acc, i| acc * (word.clone() - i))
|
||||
.expect("range > 0")
|
||||
(1..range).fold(word.clone(), |acc, i| {
|
||||
acc * (word.clone() - Expression::Constant(F::from_u64(i as u64)))
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in New Issue