Skip to content

Commit

Permalink
chore: update bit_and to avoid all bitwise ANDs being optimised away
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Jan 18, 2024
1 parent a789fae commit a2f58f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions test_programs/execution_success/bit_and/Prover.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
x = "0x00"
y = "0x10"
a = "0x00"
b = "0x10"
8 changes: 4 additions & 4 deletions test_programs/execution_success/bit_and/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// You can only do bit operations with integers.
// (Kobi/Daira/Circom/#37) https://github.com/iden3/circom/issues/37
fn main(x: Field, y: Field) {
fn main(x: Field, y: Field, a: Field, b: Field) {
let x_as_u8 = x as u8;
let y_as_u8 = y as u8;

Expand All @@ -9,8 +9,8 @@ fn main(x: Field, y: Field) {
let flag = (x == 0) & (y == 16);
assert(flag);
//bitwise and with odd bits:
let x_as_u11 = x as u11;
let y_as_u11 = y as u11;
assert((x_as_u11 & y_as_u11) == x_as_u11);
let a_as_u8 = a as u8;
let b_as_u8 = b as u8;
assert((a_as_u8 & b_as_u8) == a_as_u8);
}

0 comments on commit a2f58f2

Please sign in to comment.