Skip to content

Commit

Permalink
Add method to UnivariatePcsWithLde trait to compute LDE's without com…
Browse files Browse the repository at this point in the history
…mitments
  • Loading branch information
tess-eract committed Jun 14, 2024
1 parent e1de762 commit 1e4c51c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
13 changes: 13 additions & 0 deletions commit/src/pcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ where
where
Self: 'a;

type LdeOwned: MatrixRows<Val> + MatrixGet<Val> + Sync;

fn coset_shift(&self) -> Val;

fn log_blowup(&self) -> usize;
Expand All @@ -85,6 +87,17 @@ where
where
'a: 'b;

// Compute the (shifted) low-degree extensions only without computing the commitment.
fn compute_ldes_batches(
&self,
polynomials: Vec<In>,
coset_shifts: &[Val],
) -> Vec<Self::LdeOwned>;

fn compute_lde_batch(&self, polynomials: In, coset_shift: Val) -> Vec<Self::LdeOwned> {
self.compute_ldes_batches(vec![polynomials], &[coset_shift])
}

// Commit to polys that are already defined over a coset.
fn commit_shifted_batches(
&self,
Expand Down
25 changes: 19 additions & 6 deletions fri/src/two_adic_pcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use p3_field::{
};
use p3_interpolation::interpolate_coset;
use p3_matrix::bitrev::{BitReversableMatrix, BitReversedMatrixView};
use p3_matrix::dense::RowMajorMatrixView;
use p3_matrix::dense::{RowMajorMatrix, RowMajorMatrixView};
use p3_matrix::{Dimensions, Matrix, MatrixRows};
use p3_maybe_rayon::prelude::*;
use p3_util::linear_map::LinearMap;
Expand Down Expand Up @@ -141,6 +141,7 @@ where
<C::InputMmcs as Mmcs<C::Val>>::ProverData: Send + Sync + Sized,
{
type Lde<'a> = BitReversedMatrixView<<C::InputMmcs as Mmcs<C::Val>>::Mat<'a>> where Self: 'a;
type LdeOwned = BitReversedMatrixView<RowMajorMatrix<C::Val>>;

fn coset_shift(&self) -> C::Val {
C::Val::generator()
Expand All @@ -162,26 +163,38 @@ where
.collect()
}

fn commit_shifted_batches(
fn compute_ldes_batches(
&self,
polynomials: Vec<In>,
coset_shifts: &[C::Val],
) -> (Self::Commitment, Self::ProverData) {
let ldes = info_span!("compute all coset LDEs").in_scope(|| {
) -> Vec<Self::LdeOwned> {
info_span!("compute all coset LDEs").in_scope(|| {
polynomials
.par_iter()
.zip_eq(coset_shifts)
.map(|(poly, coset_shift)| {
let shift = C::Val::generator() / *coset_shift;
let input = ((*poly).clone()).to_row_major_matrix();
// Commit to the bit-reversed LDE.
self.dft
.coset_lde_batch(input, self.fri.log_blowup, shift)
.bit_reverse_rows()
.to_row_major_matrix()
})
.map(BitReversedMatrixView::new)
.collect()
});
})
}

fn commit_shifted_batches(
&self,
polynomials: Vec<In>,
coset_shifts: &[C::Val],
) -> (Self::Commitment, Self::ProverData) {
let ldes = self
.compute_ldes_batches(polynomials, coset_shifts)
.into_iter()
.map(|x| x.to_row_major_matrix())
.collect();

self.mmcs.commit(ldes)
}
Expand Down

0 comments on commit 1e4c51c

Please sign in to comment.