mirror of
https://github.com/arnaucube/hyperplonk.git
synced 2026-01-10 16:11:29 +01:00
Optimize verifier eq (#102)
* wip we need to be able to do batch opening for different poly sizes or pad poly with zeros * fix small public inputs. Only works for pow2 pubinput Co-authored-by: Charles Chen <chancharles92@gmail.com>
This commit is contained in:
@@ -12,4 +12,6 @@ pub use multilinear_polynomial::{
|
||||
};
|
||||
pub use univariate_polynomial::{build_l, get_uni_domain};
|
||||
pub use util::{bit_decompose, gen_eval_point, get_batched_nv, get_index};
|
||||
pub use virtual_polynomial::{build_eq_x_r, build_eq_x_r_vec, VPAuxInfo, VirtualPolynomial};
|
||||
pub use virtual_polynomial::{
|
||||
build_eq_x_r, build_eq_x_r_vec, eq_eval, VPAuxInfo, VirtualPolynomial,
|
||||
};
|
||||
|
||||
@@ -325,6 +325,23 @@ impl<F: PrimeField> VirtualPolynomial<F> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Evaluate eq polynomial.
|
||||
pub fn eq_eval<F: PrimeField>(x: &[F], y: &[F]) -> Result<F, ArithErrors> {
|
||||
if x.len() != y.len() {
|
||||
return Err(ArithErrors::InvalidParameters(
|
||||
"x and y have different length".to_string(),
|
||||
));
|
||||
}
|
||||
let start = start_timer!(|| "eq_eval");
|
||||
let mut res = F::one();
|
||||
for (&xi, &yi) in x.iter().zip(y.iter()) {
|
||||
let xi_yi = xi * yi;
|
||||
res *= xi_yi + xi_yi - xi - yi + F::one();
|
||||
}
|
||||
end_timer!(start);
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// This function build the eq(x, r) polynomial for any given r.
|
||||
///
|
||||
/// Evaluate
|
||||
|
||||
Reference in New Issue
Block a user