Skip to content

Commit

Permalink
use lookup method for preimage length checks
Browse files Browse the repository at this point in the history
  • Loading branch information
querolita committed Aug 26, 2024
1 parent 6b03d7d commit e99aac1
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions o1vm/src/mips/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,26 +532,11 @@ impl<Fp: Field> InterpreterEnv for Env<Fp> {

// FIXED LOOKUPS
// Check that 0 <= preimage read <= actual read <= len <= 4
self.add_lookup(Lookup::write_one(
LookupTableIDs::AtMost4Lookup,
vec![len.clone()],
));
self.add_lookup(Lookup::write_one(
LookupTableIDs::AtMost4Lookup,
vec![actual_read_bytes.clone()],
));
self.add_lookup(Lookup::write_one(
LookupTableIDs::AtMost4Lookup,
vec![num_preimage_bytes_read.clone()],
));
self.add_lookup(Lookup::write_one(
LookupTableIDs::AtMost4Lookup,
vec![len.clone() - actual_read_bytes.clone()],
));
self.add_lookup(Lookup::write_one(
LookupTableIDs::AtMost4Lookup,
vec![actual_read_bytes.clone() - num_preimage_bytes_read.clone()],
));
self.lookup_2bits(len);
self.lookup_2bits(&actual_read_bytes);
self.lookup_2bits(&num_preimage_bytes_read);
self.lookup_2bits(&(len.clone() - actual_read_bytes.clone()));
self.lookup_2bits(&(actual_read_bytes.clone() - num_preimage_bytes_read.clone()));

// COMMUNICATION CHANNEL: Write preimage chunk (1, 2, 3, or 4 bytes)
for i in 0..MIPS_CHUNK_BYTES_LEN {
Expand Down

0 comments on commit e99aac1

Please sign in to comment.