Skip to content

Commit

Permalink
Use built-in sum instead of writing our own ad-hoc version (#738)
Browse files Browse the repository at this point in the history
Extracted from #736 for ease of
review.
  • Loading branch information
matthiasgoergens authored Dec 14, 2024
1 parent cb8543d commit 74bb962
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions ceno_zkvm/src/uint/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,7 @@ impl<const M: usize, const C: usize, E: ExtensionField> UIntLimbs<M, C, E> {
.into_iter()
.unzip();

let sum_expr = is_equal_per_limb
.iter()
.fold(Expression::ZERO, |acc, flag| acc.clone() + flag.expr());
let sum_expr = is_equal_per_limb.iter().map(ToExpr::expr).sum();

let sum_flag = WitIn::from_expr(|| "sum_flag", circuit_builder, sum_expr, false)?;
let (is_equal, diff_inv) =
Expand Down
4 changes: 1 addition & 3 deletions mpcs/src/sum_check/classic/coeff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ impl<E: ExtensionField> ClassicSumCheckRoundMessage<E> for Coefficients<E> {
}

fn sum(&self) -> E {
self[1..]
.iter()
.fold(self[0].double(), |acc, coeff| acc + coeff)
self[0] + self[..].iter().sum::<E>()
}

fn evaluate(&self, _: &Self::Auxiliary, challenge: &E) -> E {
Expand Down

0 comments on commit 74bb962

Please sign in to comment.