diff --git a/driver.py b/driver.py index 0c374942..3140de45 100755 --- a/driver.py +++ b/driver.py @@ -125,7 +125,7 @@ def doc(features): set of features required """ - cmd = ["cargo", "doc", "--document-private-items"] + cmd = ["cargo", "doc", "--document-private-items", "--no-deps"] if features: cmd = cmd + ["--features"] + [",".join(features)] log_run_check(cmd) diff --git a/examples/ZoKrates/pf/2024_07_01_chad_bug_wit.zok b/examples/ZoKrates/pf/2024_07_01_chad_bug_wit.zok new file mode 100644 index 00000000..b20c7328 --- /dev/null +++ b/examples/ZoKrates/pf/2024_07_01_chad_bug_wit.zok @@ -0,0 +1,19 @@ +// TEST_FILE +// FEATURES: r1cs poly +// CMD: $circ $file r1cs --proof-impl mirage --action count +def unsafe_baz(field input) -> field[M]: + return [input; M] + +def foo(field input) -> field[M]: + unsafe witness field[M] inputs = unsafe_baz::(input) + assert(inputs[0] == input) + return inputs + +def bar(field[N][M] input) -> field[M]: + return foo::(input[0][0]) + +def main(field[8] a) -> bool: + field[8] x = bar::<2,8>([a, a]) + field[8] y = bar::<2,8>([x, a]) + //field[8] y = foo::<8>(x[0]) + return true diff --git a/src/ir/opt/mem/obliv.rs b/src/ir/opt/mem/obliv.rs index 649f27ba..324d0554 100644 --- a/src/ir/opt/mem/obliv.rs +++ b/src/ir/opt/mem/obliv.rs @@ -83,8 +83,14 @@ impl OblivRewriter { ( if let Some(aa) = self.tups.get(a) { if suitable_const(i) { - trace!("simplify store at {}", i); - Some(term![Op::Update(get_const(i)); aa.clone(), self.get_t(v).clone()]) + if matches!(check(aa), Sort::Tuple(..)) { + trace!("simplify store at {}", i); + Some( + term![Op::Update(get_const(i)); aa.clone(), self.get_t(v).clone()], + ) + } else { + None + } } else { None } @@ -99,16 +105,20 @@ impl OblivRewriter { let i = &t.cs()[1]; if let Some(aa) = self.tups.get(a) { if suitable_const(i) { - trace!("simplify select at {}", i); - let tt = term![Op::Field(get_const(i)); aa.clone()]; - ( - Some(tt.clone()), - if check(&tt).is_scalar() { - Some(tt) - } else { - None - }, - ) + if matches!(check(aa), Sort::Tuple(..)) { + trace!("simplify select at {}", i); + let tt = term![Op::Field(get_const(i)); aa.clone()]; + ( + Some(tt.clone()), + if check(&tt).is_scalar() { + Some(tt) + } else { + None + }, + ) + } else { + (None, None) + } } else { (None, None) }