Skip to content

Commit

Permalink
prover: add Claim pub types (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Nov 26, 2024
1 parent 4efae86 commit 8d26c0d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
7 changes: 2 additions & 5 deletions crates/brainfuck_prover/src/brainfuck_air/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::components::{
memory::table::{MemoryColumn, MemoryTable},
Claim,
};
use crate::components::{memory::table::MemoryTable, MemoryClaim};
use brainfuck_vm::machine::Machine;
use stwo_prover::core::{
air::{Component, ComponentProver},
Expand Down Expand Up @@ -30,7 +27,7 @@ pub struct BrainfuckProof<H: MerkleHasher> {
/// It includes the common claim values such as the initial and final states
/// and the claim of each component.
pub struct BrainfuckClaim {
pub memory: Claim<MemoryColumn>,
pub memory: MemoryClaim,
}

impl BrainfuckClaim {
Expand Down
4 changes: 2 additions & 2 deletions crates/brainfuck_prover/src/components/instruction/table.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::components::{Claim, TraceColumn, TraceError, TraceEval};
use crate::components::{Claim, InstructionClaim, TraceColumn, TraceError, TraceEval};
use brainfuck_vm::{
instruction::VALID_INSTRUCTIONS_BF, machine::ProgramMemory, registers::Registers,
};
Expand Down Expand Up @@ -128,7 +128,7 @@ impl InstructionTable {
///
/// # Errors
/// Returns [`TraceError::EmptyTrace`] if the table is empty.
pub fn trace_evaluation(&self) -> Result<(TraceEval, Claim<InstructionColumn>), TraceError> {
pub fn trace_evaluation(&self) -> Result<(TraceEval, InstructionClaim), TraceError> {
let n_rows = self.table.len() as u32;
// If the table is empty, there is no data to evaluate, so return an error.
if n_rows == 0 {
Expand Down
4 changes: 2 additions & 2 deletions crates/brainfuck_prover/src/components/io/table.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::components::{Claim, TraceColumn, TraceEval};
use crate::components::{Claim, IoClaim, TraceColumn, TraceEval};
use brainfuck_vm::{instruction::InstructionType, registers::Registers};
use stwo_prover::core::{
backend::{
Expand Down Expand Up @@ -96,7 +96,7 @@ impl<const N: u32> IOTable<N> {
/// # Returns
/// A tuple containing the evaluated trace and claim for STARK proof.
/// If the table is empty, returns an empty trace and a claim with a log size of 0.
pub fn trace_evaluation(&self) -> (TraceEval, Claim<IoColumn>) {
pub fn trace_evaluation(&self) -> (TraceEval, IoClaim) {
let n_rows = self.table.len() as u32;

// It is possible that the table is empty because the program has no input or output.
Expand Down
4 changes: 2 additions & 2 deletions crates/brainfuck_prover/src/components/memory/table.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::component::InteractionClaim;
use crate::components::{Claim, TraceColumn, TraceError, TraceEval};
use crate::components::{Claim, MemoryClaim, TraceColumn, TraceError, TraceEval};
use brainfuck_vm::registers::Registers;
use num_traits::One;
use stwo_prover::{
Expand Down Expand Up @@ -203,7 +203,7 @@ impl MemoryTable {
///
/// # Errors
/// Returns [`TraceError::EmptyTrace`] if the table is empty.
pub fn trace_evaluation(&self) -> Result<(TraceEval, Claim<MemoryColumn>), TraceError> {
pub fn trace_evaluation(&self) -> Result<(TraceEval, MemoryClaim), TraceError> {
let n_rows = self.table.len() as u32;
if n_rows == 0 {
return Err(TraceError::EmptyTrace);
Expand Down
12 changes: 12 additions & 0 deletions crates/brainfuck_prover/src/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use instruction::table::InstructionColumn;
use io::table::IoColumn;
use memory::table::MemoryColumn;
use stwo_prover::core::{
backend::simd::SimdBackend,
channel::Channel,
Expand All @@ -16,6 +19,15 @@ pub mod processor;
/// Type for trace evaluation to be used in Stwo.
pub type TraceEval = ColumnVec<CircleEvaluation<SimdBackend, BaseField, BitReversedOrder>>;

/// Memory claim for the Trace.
pub type MemoryClaim = Claim<MemoryColumn>;

/// Instruction claim for the Trace.
pub type InstructionClaim = Claim<InstructionColumn>;

/// IO claim for the Trace.
pub type IoClaim = Claim<IoColumn>;

/// Custom error type for the Trace.
#[derive(Debug, Error, Eq, PartialEq)]
pub enum TraceError {
Expand Down

0 comments on commit 8d26c0d

Please sign in to comment.