diff --git a/o1vm/src/interpreters/riscv32im/constraints.rs b/o1vm/src/interpreters/riscv32im/constraints.rs index ba1633e1a7..e45099490e 100644 --- a/o1vm/src/interpreters/riscv32im/constraints.rs +++ b/o1vm/src/interpreters/riscv32im/constraints.rs @@ -77,8 +77,8 @@ impl InterpreterEnv for Env { // No-op, witness only } - fn check_boolean(_x: &Self::Variable) { - // No-op, witness only + fn assert_boolean(&mut self, x: &Self::Variable) { + self.add_constraint(x.clone() * x.clone() - x.clone()); } fn add_lookup(&mut self, lookup: Lookup) { diff --git a/o1vm/src/interpreters/riscv32im/interpreter.rs b/o1vm/src/interpreters/riscv32im/interpreter.rs index 8a3e02d022..0b0adab521 100644 --- a/o1vm/src/interpreters/riscv32im/interpreter.rs +++ b/o1vm/src/interpreters/riscv32im/interpreter.rs @@ -598,14 +598,8 @@ pub trait InterpreterEnv { self.add_constraint(x - y); } - /// Check that the witness value `x` is a boolean (`0` or `1`); otherwise abort. - fn check_boolean(x: &Self::Variable); - /// Assert that the value `x` is boolean, and add a constraint in the proof system. - fn assert_boolean(&mut self, x: &Self::Variable) { - Self::check_boolean(x); - self.add_constraint(x.clone() * x.clone() - x.clone()); - } + fn assert_boolean(&mut self, x: &Self::Variable); fn add_lookup(&mut self, lookup: Lookup); diff --git a/o1vm/src/interpreters/riscv32im/witness.rs b/o1vm/src/interpreters/riscv32im/witness.rs index 011185339b..256de81687 100644 --- a/o1vm/src/interpreters/riscv32im/witness.rs +++ b/o1vm/src/interpreters/riscv32im/witness.rs @@ -88,8 +88,8 @@ impl InterpreterEnv for Env { assert_eq!(*x, *y); } - fn check_boolean(x: &Self::Variable) { - if !(*x == 0 || *x == 1) { + fn assert_boolean(&mut self, x: &Self::Variable) { + if *x != 0 && *x != 1 { panic!("The value {} is not a boolean", *x); } }