Skip to content

Commit

Permalink
Add new PolyOps trait for evaluating many polynomials (columns) for t…
Browse files Browse the repository at this point in the history
…he commitment extension
  • Loading branch information
jarnesino committed Sep 25, 2024
1 parent b7544d8 commit a602b7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
12 changes: 1 addition & 11 deletions crates/prover/src/core/pcs/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use super::super::circle::CirclePoint;
use super::super::fields::m31::BaseField;
use super::super::fields::qm31::SecureField;
use super::super::fri::{FriProof, FriProver};
use super::super::poly::circle::CanonicCoset;
use super::super::poly::BitReversedOrder;
use super::super::ColumnVec;
use super::quotients::{compute_fri_quotients, PointSample};
Expand Down Expand Up @@ -214,16 +213,7 @@ impl<B: BackendForChannel<MC>, MC: MerkleChannel> CommitmentTreeProver<B, MC> {
twiddles: &TwiddleTree<B>,
) -> Self {
let span = span!(Level::INFO, "Extension").entered();
let evaluations = polynomials
.iter()
.map(|poly| {
poly.evaluate_with_twiddles(
CanonicCoset::new(poly.log_size() + log_blowup_factor).circle_domain(),
twiddles,
)
})
.collect_vec();

let evaluations = B::evaluate_columns(&polynomials, log_blowup_factor, twiddles);
span.exit();

let _span = span!(Level::INFO, "Merkle").entered();
Expand Down
20 changes: 20 additions & 0 deletions crates/prover/src/core/poly/circle/ops.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use itertools::Itertools;
use super::{CanonicCoset, CircleDomain, CircleEvaluation, CirclePoly};
use crate::core::backend::Col;
use crate::core::circle::{CirclePoint, Coset};
use crate::core::ColumnVec;
use crate::core::fields::m31::BaseField;
use crate::core::fields::qm31::SecureField;
use crate::core::fields::FieldOps;
Expand Down Expand Up @@ -43,6 +45,24 @@ pub trait PolyOps: FieldOps<BaseField> + Sized {
twiddles: &TwiddleTree<Self>,
) -> CircleEvaluation<Self, BaseField, BitReversedOrder>;

/// Evaluates all polynomials at all points in the domain.
/// Used by the [`CommitmentTreeProver::new()`] function.
fn evaluate_columns(
polynomials: &ColumnVec<CirclePoly<Self>>,
log_blowup_factor: u32,
twiddles: &TwiddleTree<Self>,
) -> Vec<CircleEvaluation<Self, BaseField, BitReversedOrder>> {
polynomials
.iter()
.map(|poly| {
poly.evaluate_with_twiddles(
CanonicCoset::new(poly.log_size() + log_blowup_factor).circle_domain(),
twiddles,
)
})
.collect_vec()
}

/// Precomputes twiddles for a given coset.
fn precompute_twiddles(coset: Coset) -> TwiddleTree<Self>;
}

0 comments on commit a602b7d

Please sign in to comment.