Zokrates / ZoKrates

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

Cannot use <= on u32 in assert #1295

Closed jswalens closed 10 months ago

jswalens commented 1 year ago

Description

When using <= in assert, I get a compilation error:

The compiler unexpectedly panicked
panicked at 'assertion failed: res.len() <= to', zokrates_codegen/src/lib.rs:2020:21

This does not happen for <, >, or >=.

Environment

Steps to Reproduce

def main(u32 n) {
    assert(n <= 5);
    return;
}

Compiling this code returns the error above. assert(n < 5) does not trigger the same error. Changing the type of n to field also does not trigger the error. assert(n <= 5 ? true : false) works as a workaround.