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 (#854)
  • Loading branch information
jarnesino authored Oct 10, 2024
1 parent bb0cce2 commit f5bf841
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
14 changes: 2 additions & 12 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 @@ -206,22 +205,13 @@ pub struct CommitmentTreeProver<B: BackendForChannel<MC>, MC: MerkleChannel> {

impl<B: BackendForChannel<MC>, MC: MerkleChannel> CommitmentTreeProver<B, MC> {
pub fn new(
polynomials: ColumnVec<CirclePoly<B>>,
mut polynomials: ColumnVec<CirclePoly<B>>,
log_blowup_factor: u32,
channel: &mut MC::C,
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_polynomials(&mut polynomials, log_blowup_factor, twiddles);
span.exit();

let _span = span!(Level::INFO, "Merkle").entered();
Expand Down
19 changes: 19 additions & 0 deletions crates/prover/src/core/poly/circle/ops.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use itertools::Itertools;

use super::{CanonicCoset, CircleDomain, CircleEvaluation, CirclePoly};
use crate::core::backend::Col;
use crate::core::circle::{CirclePoint, Coset};
Expand All @@ -6,6 +8,7 @@ use crate::core::fields::qm31::SecureField;
use crate::core::fields::FieldOps;
use crate::core::poly::twiddles::TwiddleTree;
use crate::core::poly::BitReversedOrder;
use crate::core::ColumnVec;

/// Operations on BaseField polynomials.
pub trait PolyOps: FieldOps<BaseField> + Sized {
Expand Down Expand Up @@ -53,6 +56,22 @@ pub trait PolyOps: FieldOps<BaseField> + Sized {
twiddles: &TwiddleTree<Self>,
) -> CircleEvaluation<Self, BaseField, BitReversedOrder>;

fn evaluate_polynomials(
polynomials: &mut 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 f5bf841

Please sign in to comment.