Skip to content

Commit

Permalink
o1vm/mips: allocate correctly the inverse column
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Nov 21, 2024
1 parent 092352a commit b45339e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion o1vm/src/interpreters/mips/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl<Fp: Field> InterpreterEnv for Env<Fp> {
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
Expand Down
13 changes: 6 additions & 7 deletions o1vm/src/interpreters/mips/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ impl<Fp: Field, PreImageOracle: PreImageOracleT> InterpreterEnv for Env<Fp, PreI

fn is_zero(&mut self, x: &Self::Variable) -> 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
Expand All @@ -354,11 +354,10 @@ impl<Fp: Field, PreImageOracle: PreImageOracleT> InterpreterEnv for Env<Fp, PreI
self.write_column(pos, is_zero);
is_zero
};
let pos = self.alloc_scratch_inverse();
if to_zero_test == Fp::zero() {
let pos = self.alloc_scratch();
self.write_field_column(pos, Fp::zero());
} else {
let pos = self.alloc_scratch_inverse();
self.write_field_column(pos, to_zero_test);
};
res
Expand Down

0 comments on commit b45339e

Please sign in to comment.