Skip to content

Commit

Permalink
feat: add interaction trace evaluation to prove_brainfuck
Browse files Browse the repository at this point in the history
  • Loading branch information
zmalatrax committed Nov 27, 2024
1 parent 771938d commit ee45f7c
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions crates/brainfuck_prover/src/brainfuck_air/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::components::{
memory::table::{MemoryElements, MemoryTable},
memory::{
self,
table::{interaction_trace_evaluation, MemoryElements, MemoryTable},
},
MemoryClaim,
};
use brainfuck_vm::machine::Machine;
Expand Down Expand Up @@ -57,14 +60,17 @@ impl BrainfuckInteractionElements {
}
}

/// All the claims from the second phase (interaction phase 1).
/// All the claims from the second phase (interaction phase 2).
///
/// Mainly the claims on global relations (lookup, permutation, evaluation).
pub struct BrainfuckInteractionClaim;
pub struct BrainfuckInteractionClaim {
memory: memory::component::InteractionClaim,
}

impl BrainfuckInteractionClaim {
pub fn mix_into(&self, _channel: &mut impl Channel) {
todo!();
/// Mix the claimed sums of every components in the Fiat-Shamir [`Channel`].
pub fn mix_into(&self, channel: &mut impl Channel) {
self.memory.mix_into(channel);
}
}

Expand Down Expand Up @@ -148,12 +154,13 @@ pub fn prove_brainfuck(
let vm_trace = inputs.trace();
let (memory_trace, memory_claim) = MemoryTable::from(vm_trace).trace_evaluation().unwrap();

tree_builder.extend_evals(memory_trace);
tree_builder.extend_evals(memory_trace.clone());

let claim = BrainfuckClaim { memory: memory_claim };

// Commit to the claim and the trace.
// Mix the claim into the Fiat-Shamir channel.
claim.mix_into(channel);
// Commit the main trace.
tree_builder.commit(channel);

// ┌───────────────────────────────────────────────┐
Expand All @@ -164,10 +171,18 @@ pub fn prove_brainfuck(
let interaction_elements = BrainfuckInteractionElements::draw(channel);

// Generate the interaction trace and the BrainfuckInteractionClaim
let tree_builder = commitment_scheme.tree_builder();
let mut tree_builder = commitment_scheme.tree_builder();

let (memory_interaction_trace_eval, memory_interaction_claim) =
interaction_trace_evaluation(&memory_trace, &interaction_elements.memory_lookup_elements);

tree_builder.extend_evals(memory_interaction_trace_eval);

let interaction_claim = BrainfuckInteractionClaim { memory: memory_interaction_claim };

let interaction_claim = BrainfuckInteractionClaim {};
// Mix the interaction claim into the Fiat-Shamir channel.
interaction_claim.mix_into(channel);
// Commit the interaction trace.
tree_builder.commit(channel);

// ┌──────────────────────────┐
Expand Down

0 comments on commit ee45f7c

Please sign in to comment.