Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: constant to preprocessed trace #83

Merged
merged 2 commits into from
Nov 22, 2024
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
26 changes: 13 additions & 13 deletions crates/brainfuck_prover/src/brainfuck_air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,22 @@ pub fn prove_brainfuck(
let channel = &mut Blake2sChannel::default();
let commitment_scheme =
&mut CommitmentSchemeProver::<_, Blake2sMerkleChannel>::new(config, &twiddles);
let mut tree_builder = commitment_scheme.tree_builder();

// ┌───────────────────────────────────────────────┐
// │ Interaction Phase 0 - Preprocessed Trace │
// └───────────────────────────────────────────────┘

// Generate constant columns (e.g. is_first)
let tree_builder = commitment_scheme.tree_builder();
tree_builder.commit(channel);

// ┌───────────────────────────────────────┐
// │ Interaction Phase 0 - Main Trace │
// │ Interaction Phase 1 - Main Trace │
// └───────────────────────────────────────┘
let vm_trace = inputs.trace();

let mut tree_builder = commitment_scheme.tree_builder();

let vm_trace = inputs.trace();
let (memory_trace, memory_claim) = MemoryTable::from(vm_trace).trace_evaluation().unwrap();

tree_builder.extend_evals(memory_trace);
Expand All @@ -141,7 +150,7 @@ pub fn prove_brainfuck(
tree_builder.commit(channel);

// ┌───────────────────────────────────────────────┐
// │ Interaction Phase 1 - Interaction Trace │
// │ Interaction Phase 2 - Interaction Trace │
// └───────────────────────────────────────────────┘

// Draw interaction elements
Expand All @@ -154,15 +163,6 @@ pub fn prove_brainfuck(
interaction_claim.mix_into(channel);
tree_builder.commit(channel);

// TODO: move the preprocessed trace to Phase 0
// ┌───────────────────────────────────────────────┐
// │ Interaction Phase 2 - Preprocessed Trace │
// └───────────────────────────────────────────────┘

// Generate constant columns (e.g. is_first)
let tree_builder = commitment_scheme.tree_builder();
tree_builder.commit(channel);

// ┌──────────────────────────┐
// │ Proof Generation │
// └──────────────────────────┘
Expand Down
10 changes: 8 additions & 2 deletions crates/brainfuck_prover/src/components/memory/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ impl Claim {
///
/// NOTE: Currently only the main trace is provided.
pub fn log_sizes(&self) -> TreeVec<Vec<u32>> {
// TODO: Add the preprocessed and interaction trace sizes
// TODO: Add the preprocessed and interaction trace correct sizes
let preprocessed_trace_log_sizes: Vec<u32> = vec![];
let trace_log_sizes = vec![self.log_size; MemoryColumn::count()];
TreeVec::new(vec![trace_log_sizes])
let interaction_trace_log_sizes: Vec<u32> = vec![];
TreeVec::new(vec![
preprocessed_trace_log_sizes,
trace_log_sizes,
interaction_trace_log_sizes,
])
}

/// Mix the log size of the Memory table to the Fiat-Shamir [`Channel`],
Expand Down