Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions crypto/stark/src/batched/mod.rs

This file was deleted.

374 changes: 0 additions & 374 deletions crypto/stark/src/batched/shape.rs

This file was deleted.

1,826 changes: 0 additions & 1,826 deletions crypto/stark/src/fri/mmcs.rs

This file was deleted.

1 change: 0 additions & 1 deletion crypto/stark/src/fri/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod fri_commitment;
pub mod fri_decommit;
pub(crate) mod fri_functions;
pub mod mmcs;
pub(crate) mod terminal;

use crypto::fiat_shamir::is_transcript::IsStarkTranscript;
Expand Down
1 change: 0 additions & 1 deletion crypto/stark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#[cfg(all(target_arch = "wasm32", feature = "disk-spill"))]
compile_error!("the `disk-spill` feature requires memmap2, which does not compile on wasm32");

pub mod batched;
#[cfg(feature = "debug-checks")]
pub mod bus_debug;
pub mod commitment;
Expand Down
23 changes: 0 additions & 23 deletions crypto/stark/src/par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,3 @@ pub(crate) fn par_try_for_each_mut<T: Send, E: Send>(
slice.iter_mut().try_for_each(f)
}
}

/// Run `f(i, &mut item)` for each element of `slice` with its index. Parallel
/// when `feature = "parallel"`, sequential otherwise.
pub(crate) fn par_for_each_mut_indexed<T: Send>(
slice: &mut [T],
f: impl Fn(usize, &mut T) + Sync + Send,
) {
#[cfg(feature = "parallel")]
{
use rayon::prelude::*;
slice
.par_iter_mut()
.enumerate()
.for_each(|(i, item)| f(i, item));
}
#[cfg(not(feature = "parallel"))]
{
slice
.iter_mut()
.enumerate()
.for_each(|(i, item)| f(i, item));
}
}
8 changes: 0 additions & 8 deletions prover/src/bin/compute_lfm_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ fn main() {
artifacts.chip_set.keccak, artifacts.chip_set.blake3
);
println!(" program_id: {},", fmt_bytes(&artifacts.program_id));
println!(" prep_root: {},", fmt_bytes(&artifacts.prep_root));
let widths = artifacts
.prep_widths
.iter()
.map(u16::to_string)
.collect::<Vec<_>>()
.join(", ");
println!(" prep_widths: [{widths}],");
println!(" }},");
}
}
Expand Down
77 changes: 0 additions & 77 deletions prover/src/lfm/blake3_chip_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1897,83 +1897,6 @@ fn the_census_counts_every_blake3_chunk() {
}
}

/// The batched preprocessed round expands with the chunks: eleven fixed slot
/// matrices, then ONE per `LFM_BLAKE3` chunk at that chunk's own LDE height —
/// and the shape a verifier reads back rebuilds the pinned root.
///
/// The round is absorbed in slot order and this chip is the last slot in it, so
/// the chunks land at the end; getting the count or an individual height wrong
/// is not loud (the tree still builds), which is why the rebuild is the
/// assertion rather than the shape alone.
#[test]
fn the_prep_round_expands_with_the_blake3_chunks() {
use super::commit::{PrepRoundBuilder, group_columns, lde_columns};
use super::registry::PREP_ROUND_SLOTS;

let opts = options();
let program = chunked_chain_program();
let artifacts = build_artifacts(&program, &opts);
let (heights, widths) = artifacts.prep_round_shape(opts.blowup_factor);

assert_eq!(heights.len(), widths.len());
assert_eq!(
heights.len(),
PREP_ROUND_SLOTS.len() - 1 + 3,
"eleven fixed slots plus one matrix per chunk"
);
let blowup_log = (opts.blowup_factor as usize).trailing_zeros() as usize;
for (i, slot) in PREP_ROUND_SLOTS.take(super::airs::BLAKE3_SLOT).enumerate() {
assert_eq!(
heights[i],
artifacts.log_heights[slot] as usize + blowup_log
);
}
for (c, h) in artifacts.blake3_chunk_log_heights.iter().enumerate() {
assert_eq!(
heights[super::airs::BLAKE3_SLOT + c],
*h as usize + blowup_log,
"chunk {c}: the round's height must be the chunk's LDE height"
);
assert_eq!(
widths[super::airs::BLAKE3_SLOT + c],
program.groups.blake3.width
);
}

let range = super::trace::range_group();
let fixed = [
&program.groups.const_,
&program.groups.balu,
&program.groups.xalu,
&program.groups.select,
&program.groups.bitdec,
&program.groups.hash,
&program.groups.keccak,
&program.groups.lanes,
&program.groups.hint,
&program.groups.public,
&range,
];
let dims: Vec<(usize, usize)> = heights
.iter()
.copied()
.zip(widths.iter().copied())
.collect();
let mut round = PrepRoundBuilder::new(&dims);
for g in fixed.iter() {
round.absorb(&lde_columns(&group_columns(g), &opts));
}
for c in 0..artifacts.blake3_chunks() {
let g = program.blake3_chunk_group(c);
round.absorb(&lde_columns(&group_columns(&g), &opts));
}
assert_eq!(
round.finish(),
artifacts.prep_root,
"the shape a verifier reads back must rebuild the pinned root"
);
}

/// The knob's whole path: a variable VALUE becomes a policy, the policy becomes
/// chunks, and the chunked program proves and verifies. The parse itself is
/// tested in [`super::chunking`]; this is what says the value reaches the
Expand Down
86 changes: 3 additions & 83 deletions prover/src/lfm/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use math::polynomial::Polynomial;
use stark::commitment::{ROWS_PER_LEAF, commit_bit_reversed_with};
use stark::config::Commitment;
use stark::fri::mmcs::{BorrowedMatrix, StreamingMmcsBuilder};
use stark::proof::options::ProofOptions;
use stark::prover::evaluate_polynomial_on_lde_domain;

Expand All @@ -20,13 +19,9 @@ use super::compiler::ColumnGroup;

/// The coset LDE of a column matrix, column-major and in NATURAL order.
///
/// Split out of [`commit_columns`] because two things now consume it: the
/// per-slot row-pair commitment below, and the batched preprocessed round
/// ([`prep_round_root`]), which reads exactly this shape through
/// `BorrowedMatrix::ColMajorNatural`. Computing it once and handing it to both
/// is what keeps the batched root a commitment to *the same* evaluations the
/// per-slot root commits to, rather than to a second, independently built copy
/// of them.
/// Split out of [`commit_columns`] so a caller that needs the evaluations for
/// something else can expand once and commit from the same copy, rather than
/// building a second, independently expanded one.
pub fn lde_columns(columns: &[Vec<FE>], options: &ProofOptions) -> Vec<Vec<FE>> {
let num_rows = columns.first().map_or(0, Vec::len);
let polys: Vec<Polynomial<FE>> = columns
Expand Down Expand Up @@ -82,78 +77,3 @@ pub fn group_columns(group: &ColumnGroup) -> Vec<Vec<FE>> {
pub fn commit_group(group: &ColumnGroup, options: &ProofOptions) -> Commitment {
commit_columns(&group_columns(group), options)
}

/// The batched preprocessed round's root: ONE mixed-height MMCS over several
/// slots' LDE matrices, in slot order.
///
/// # What this is for
///
/// Under the batched commitment path a query opens ONE authentication path
/// covering every preprocessed matrix, instead of one path per slot. This is
/// the root such a verifier compares against
/// ([`stark::fri::mmcs::MixedMmcs::verify_batch`]), and the registry pins it
/// alongside the per-slot roots it does not replace.
///
/// # Streaming, deliberately
///
/// Absorbing through [`StreamingMmcsBuilder`] rather than `MixedMmcs::commit`
/// is what lets the caller expand one slot's LDE, commit it, absorb it and drop
/// it. `commit` reads every matrix of a height group at once, which for the
/// registry builder would mean holding all twelve groups' LDEs simultaneously —
/// a memory regression in a function the king gate and a dozen tests call.
///
/// # Determinism
///
/// The tree is a pure function of the matrices AND their order, so the caller
/// must absorb in the same slot order a verifier will present openings in. The
/// heights are LDE heights (`log2(rows * blowup)`), not trace heights — the
/// registry's own `log_heights` are trace heights, and the two differ by
/// `log2(blowup)`.
pub struct PrepRoundBuilder {
builder: StreamingMmcsBuilder<GoldilocksField, crate::hash_pin::BlockStarkHash>,
}

impl PrepRoundBuilder {
/// Declare the round's shape: `(log_height, width)` per participating slot,
/// in absorption order. `log_height` is the LDE height.
pub fn new(dims: &[(usize, usize)]) -> Self {
Self {
builder: StreamingMmcsBuilder::new(dims),
}
}

/// Absorb one slot's LDE matrix. The caller may drop it as soon as this
/// returns.
///
/// # Panics
///
/// On an empty matrix, or a column length that is not a power of two.
/// Deriving the height as `len.trailing_zeros()` is only the height when the
/// length is a power of two — for anything else it silently reports a
/// SMALLER height (a length of 12 reads as 4), and the round would then
/// commit a tree over a shape nobody declared. This runs at program-build
/// and registry-regeneration time, never on a verify path, so an unusable
/// input is a caller bug and asserting is correct here (unlike on the
/// verifier, where the house rule is to reject rather than panic).
pub fn absorb(&mut self, lde_columns: &[Vec<FE>]) {
let len = lde_columns
.first()
.map(Vec::len)
.expect("a participating slot has at least one column");
assert!(
len.is_power_of_two(),
"an LDE column length must be a power of two, got {len}"
);
let log_height = len.trailing_zeros() as usize;
let source = vec![BorrowedMatrix::ColMajorNatural {
cols: lde_columns,
log_height,
}];
self.builder.absorb(&source, 0);
}

/// The round's root.
pub fn finish(self) -> Commitment {
self.builder.finish().root()
}
}
Loading
Loading