Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.8k stars 360 forks source link

Compiler panic when wraping a divide-by-zero statement inside a function #1325

Closed beriarue closed 1 year ago

beriarue commented 1 year ago

Description

When wrapping a divide-by-zero assertion statement inside a function, the compiler crashes.

Environment

Steps to Reproduce

Save the following file into buggy_inline.zok:

def foo(field a, field b) -> field {
    assert(1 / (a - b) == 0);
    return a;
}

def main() -> field {
    return foo(1, 1);
}

Compile:

zokrates compile -i buggy_inline.zok

and observe the following output:

The compiler unexpectedly panicked
panicked at 'called `Option::unwrap()` on a `None` value', zokrates_field/src/bn128.rs:4:1
This is unexpected, please submit a full bug report at https://github.com/Zokrates/ZoKrates/issues
make: *** [Makefile:8: out] Error 101