Skip to content

Commit

Permalink
Support empty commit. (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyalesokhin-starkware authored Nov 7, 2024
1 parent 8c8b744 commit 4aa5a22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion crates/prover/src/core/vcs/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ impl<B: MerkleOps<H>, H: MerkleHasher> MerkleProver<B, H> {
///
/// A new instance of `MerkleProver` with the committed layers.
pub fn commit(columns: Vec<&Col<B, BaseField>>) -> Self {
assert!(!columns.is_empty());
if columns.is_empty() {
return Self {
layers: vec![B::commit_on_layer(0, None, &[])],
};
}

let columns = &mut columns
.into_iter()
Expand Down
6 changes: 4 additions & 2 deletions crates/prover/src/core/vcs/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ impl<H: MerkleHasher> MerkleVerifier<H> {
queried_values: ColumnVec<Vec<BaseField>>,
decommitment: MerkleDecommitment<H>,
) -> Result<(), MerkleVerificationError> {
let max_log_size = self.column_log_sizes.iter().max().copied().unwrap_or(0);
let Some(max_log_size) = self.column_log_sizes.iter().max() else {
return Ok(());
};

// Prepare read buffers.
let mut queried_values_by_layer = self
Expand All @@ -74,7 +76,7 @@ impl<H: MerkleHasher> MerkleVerifier<H> {
let mut column_witness = decommitment.column_witness.into_iter();

let mut last_layer_hashes: Option<Vec<(usize, H::Hash)>> = None;
for layer_log_size in (0..=max_log_size).rev() {
for layer_log_size in (0..=*max_log_size).rev() {
// Prepare read buffer for queried values to the current layer.
let mut layer_queried_values = queried_values_by_layer
.peek_take_while(|(log_size, _)| *log_size == layer_log_size)
Expand Down

0 comments on commit 4aa5a22

Please sign in to comment.