Skip to content

Commit ca70537

Browse files
authored
bugfix: opt::mem::obliv (#194)
recognize scalar variables as tuple-free
1 parent 9ac4c26 commit ca70537

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
struct BigNat_init_quotient<Qm1, Lp1> {
2+
field[Qm1][Lp1] limbs
3+
field last_limb
4+
}
5+
6+
struct BigNat_init<N, Lp1> {
7+
field[N][Lp1] limbs
8+
}
9+
struct BigNatModMult_init<Qm1, Lp1, ZG, CL> {
10+
BigNat_init_quotient<Qm1, Lp1> quotient_init
11+
BigNat_init<ZG, CL> carry_init
12+
}
13+
14+
const u32 Qm1 = 7
15+
const u32 Lp1 = 4
16+
const u32 ZG = 2
17+
const u32 CL = 5
18+
19+
def main(private BigNatModMult_init<Qm1,Lp1,ZG,CL>[1] intermediate_mod) -> bool:
20+
BigNat_init<ZG, CL> carry = intermediate_mod[0].carry_init
21+
assert(carry.limbs[0][0] == 1)
22+
return true

scripts/zokrates_test.zsh

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ r1cs_test ./third_party/ZoKrates/zokrates_stdlib/stdlib/utils/casts/bool_128_to_
8888
r1cs_test ./third_party/ZoKrates/zokrates_stdlib/stdlib/ecc/edwardsScalarMult.zok
8989
r1cs_test ./third_party/ZoKrates/zokrates_stdlib/stdlib/hashes/mimc7/mimc7R20.zok
9090
r1cs_test ./third_party/ZoKrates/zokrates_stdlib/stdlib/hashes/pedersen/512bit.zok
91+
r1cs_test ./examples/ZoKrates/pf/2024_06_02_chad_bug.zok
9192

9293
pf_test_only_pf sha_temp1
9394
pf_test_only_pf sha_rot

src/ir/opt/mem/obliv.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ impl OblivRewriter {
4242
}
4343
fn visit(&mut self, t: &Term) {
4444
let (tup_opt, term_opt) = match t.op() {
45+
Op::Var(_, sort) if sort.is_scalar() => (Some(t.clone()), None),
4546
Op::Const(v @ Value::Array(_)) => (Some(leaf_term(Op::Const(arr_val_to_tup(v)))), None),
4647
Op::Array(_k, _v) => (
4748
Some(term(

0 commit comments

Comments
 (0)