From 799172e61c0454f33a80115135aacddf167612c1 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 21 Nov 2024 14:52:24 +0100 Subject: [PATCH] o1vm/mips: allocate correctly the inverse column --- o1vm/src/interpreters/mips/constraints.rs | 2 +- o1vm/src/interpreters/mips/witness.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/o1vm/src/interpreters/mips/constraints.rs b/o1vm/src/interpreters/mips/constraints.rs index 7e97317bbd..cb46508b9b 100644 --- a/o1vm/src/interpreters/mips/constraints.rs +++ b/o1vm/src/interpreters/mips/constraints.rs @@ -227,7 +227,7 @@ impl InterpreterEnv for Env { unsafe { self.test_zero(x, pos) } }; let x_inv_or_zero = { - let pos = self.alloc_scratch(); + let pos = self.alloc_scratch_inverse(); self.variable(pos) }; // If x = 0, then res = 1 and x_inv_or_zero = 0 diff --git a/o1vm/src/interpreters/mips/witness.rs b/o1vm/src/interpreters/mips/witness.rs index d5d7451273..7a180fccda 100644 --- a/o1vm/src/interpreters/mips/witness.rs +++ b/o1vm/src/interpreters/mips/witness.rs @@ -327,15 +327,15 @@ impl InterpreterEnv for Env Self::Variable { // write the result - let pos = self.alloc_scratch(); - let res = if *x == 0 { 1 } else { 0 }; - self.write_column(pos, res); + let res = { + let pos = self.alloc_scratch(); + unsafe { self.test_zero(x, pos) } + }; // write the non deterministic advice inv_or_zero + let pos = self.alloc_scratch_inverse(); if *x == 0 { - let pos = self.alloc_scratch(); self.write_field_column(pos, Fp::zero()); } else { - let pos = self.alloc_scratch_inverse(); self.write_field_column(pos, Fp::from(*x)); }; // return the result @@ -352,11 +352,10 @@ impl InterpreterEnv for Env