Skip to content

Commit

Permalink
feat: add utils mod for constants needed accross brainfuck_prover (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmalatrax authored Nov 12, 2024
1 parent 05b6dfe commit c4c5019
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/brainfuck_prover/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod brainfuck_air;
pub mod components;
pub mod utils;
21 changes: 21 additions & 0 deletions crates/brainfuck_prover/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use stwo_prover::core::fields::m31::BaseField;

pub const SHIFT_RIGHT_INSTRUCTION: u32 = b'>' as u32;
pub const SHIFT_LEFT_INSTRUCTION: u32 = b'<' as u32;
pub const INCREMENT_INSTRUCTION: u32 = b'+' as u32;
pub const DECREMENT_INSTRUCTION: u32 = b'-' as u32;
pub const INPUT_INSTRUCTION: u32 = b',' as u32;
pub const OUTPUT_INSTRUCTION: u32 = b'.' as u32;
pub const JUMP_IF_ZERO_INSTRUCTION: u32 = b'[' as u32;
pub const JUMP_IF_NON_ZERO_INSTRUCTION: u32 = b']' as u32;

pub const VALID_INSTRUCTIONS: [BaseField; 8] = [
BaseField::from_u32_unchecked(SHIFT_RIGHT_INSTRUCTION),
BaseField::from_u32_unchecked(SHIFT_LEFT_INSTRUCTION),
BaseField::from_u32_unchecked(INCREMENT_INSTRUCTION),
BaseField::from_u32_unchecked(DECREMENT_INSTRUCTION),
BaseField::from_u32_unchecked(INPUT_INSTRUCTION),
BaseField::from_u32_unchecked(OUTPUT_INSTRUCTION),
BaseField::from_u32_unchecked(JUMP_IF_ZERO_INSTRUCTION),
BaseField::from_u32_unchecked(JUMP_IF_NON_ZERO_INSTRUCTION),
];

0 comments on commit c4c5019

Please sign in to comment.