Skip to content

Commit

Permalink
feat: add constraints on next_ci and next_ni
Browse files Browse the repository at this point in the history
  • Loading branch information
zmalatrax committed Dec 20, 2024
1 parent b16c3d5 commit fd241dd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/brainfuck_prover/src/components/instruction/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,27 @@ impl FrameworkEval for InstructionEval {
let next_ip = eval.next_trace_mask();
let next_ci = eval.next_trace_mask();
let next_ni = eval.next_trace_mask();
// TODO: Looks unnecessary here, might as well remove it.
let _next_d = eval.next_trace_mask();
let next_d = eval.next_trace_mask();

// Boundary constraints
eval.add_constraint(is_first * ip.clone());

// Consistency constraints
eval.add_constraint(d.clone() * (d.clone() - BaseField::one().into()));
eval.add_constraint(next_d.clone() * (next_d.clone() - BaseField::one().into()));

// If d is set, then `ci` equals 0
// If `d` is set, then `ci` equals 0
eval.add_constraint(d.clone() * ci.clone());

// If ci is set, then `ni` equals 0
// If `d` is set, then `ni` equals 0
eval.add_constraint(d.clone() * ni.clone());

// If `next_d` is set, then `next_ci` equals 0
eval.add_constraint(next_d.clone() * next_ci.clone());

// If `next_d` is set, then `ni` equals 0
eval.add_constraint(next_d * next_ni.clone());

// Transition constraints

// `ip` increases by 0 or 1
Expand Down

0 comments on commit fd241dd

Please sign in to comment.