From fa161818f928cc9f1d17f249f507a05e5752c83a Mon Sep 17 00:00:00 2001 From: Julian Arnesino Date: Thu, 17 Oct 2024 14:10:06 -0300 Subject: [PATCH] Add new PolyOps trait for evaluating many polynomials at many out-of-domain points --- crates/prover/src/core/pcs/prover.rs | 15 ++------------- crates/prover/src/core/poly/circle/ops.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/crates/prover/src/core/pcs/prover.rs b/crates/prover/src/core/pcs/prover.rs index 58d347ee6..dbedabd5d 100644 --- a/crates/prover/src/core/pcs/prover.rs +++ b/crates/prover/src/core/pcs/prover.rs @@ -10,7 +10,7 @@ use super::super::fields::qm31::SecureField; use super::super::fri::{FriProof, FriProver}; use super::super::poly::BitReversedOrder; use super::super::ColumnVec; -use super::quotients::{compute_fri_quotients, PointSample}; +use super::quotients::compute_fri_quotients; use super::utils::TreeVec; use super::{PcsConfig, TreeSubspan}; use crate::core::air::Trace; @@ -87,18 +87,7 @@ impl<'a, B: BackendForChannel, MC: MerkleChannel> CommitmentSchemeProver<'a, ) -> CommitmentSchemeProof { // Evaluate polynomials on open points. let span = span!(Level::INFO, "Evaluate columns out of domain").entered(); - let samples = self - .polynomials() - .zip_cols(&sampled_points) - .map_cols(|(poly, points)| { - points - .iter() - .map(|&point| PointSample { - point, - value: poly.eval_at_point(point), - }) - .collect_vec() - }); + let samples = B::evaluate_polynomials_out_of_domain(self.polynomials(), sampled_points); span.exit(); let sampled_values = samples .as_cols_ref() diff --git a/crates/prover/src/core/poly/circle/ops.rs b/crates/prover/src/core/poly/circle/ops.rs index a08fa6739..8fa83bf70 100644 --- a/crates/prover/src/core/poly/circle/ops.rs +++ b/crates/prover/src/core/poly/circle/ops.rs @@ -9,6 +9,8 @@ use crate::core::fields::FieldOps; use crate::core::poly::twiddles::TwiddleTree; use crate::core::poly::BitReversedOrder; use crate::core::ColumnVec; +use crate::core::pcs::quotients::PointSample; +use crate::core::pcs::TreeVec; /// Operations on BaseField polynomials. pub trait PolyOps: FieldOps + Sized { @@ -44,6 +46,24 @@ pub trait PolyOps: FieldOps + Sized { /// Used by the [`CirclePoly::eval_at_point()`] function. fn eval_at_point(poly: &CirclePoly, point: CirclePoint) -> SecureField; + fn evaluate_polynomials_out_of_domain( + polynomials: TreeVec>>, + points: TreeVec>>>, + ) -> TreeVec>> { + polynomials + .zip_cols(&points) + .map_cols(|(poly, points)| { + points + .iter() + .map(|&point| PointSample { + point, + value: poly.eval_at_point(point), + }) + .collect_vec() + }) + } + + /// Extends the polynomial to a larger degree bound. /// Used by the [`CirclePoly::extend()`] function. fn extend(poly: &CirclePoly, log_size: u32) -> CirclePoly;