Simplify h(x_3) computation in verifier using Horner's rule

Closes zcash/halo2#45
This commit is contained in:
Jack Grigg 2020-10-21 16:03:42 +01:00
parent feba8e2fdf
commit 7f29ab913d
1 changed files with 3 additions and 4 deletions

View File

@ -315,12 +315,11 @@ impl<'a, C: CurveAffine> Proof<C> {
.fold(C::Scalar::zero(), |h_eval, v| h_eval * &x_2 + &v);
// Compute h(x_3) from the prover
let (_, h_eval) = self
let h_eval = self
.h_evals
.iter()
.fold((C::Scalar::one(), C::Scalar::zero()), |(cur, acc), eval| {
(cur * &x_3n, acc + &(cur * eval))
});
.rev()
.fold(C::Scalar::zero(), |acc, eval| acc * &x_3n + eval);
// Did the prover commit to the correct polynomial?
if expected_h_eval != (h_eval * &(x_3n - &C::Scalar::one())) {