NilFoundation / zkLLVM

Zero-Knowledge Proof Systems Circuit Compiler
https://docs.nil.foundation/zkllvm
284 stars 48 forks source link

[Possible bug]: opcode freeze handling #457

Closed CblPOK-git closed 8 months ago

CblPOK-git commented 9 months ago

Here are 2 examples that don't work https://github.com/manylov/zkllvm-issues

vo-nil commented 8 months ago

Here is simplified example that causes problems with freeze opcode:

int pow(int a, int n) {
    int cur_index = n;
    int r = 1;
    for(int i = 0; i<16;++i) {
        if (cur_index % 2 == 0) {
            r = r * a;
        } else {
            r = r * n;
        }
        cur_index = cur_index / 2;
    }
    return r;
}

[[circuit]] int for_even_odd(int a, int b) {
    int c = pow(a,b);
    return c;
}
nil-foundation-cicd-bot[bot] commented 8 months ago

PRs, synced with the current issue:

Note: Please do not edit this comment; it's generated automatically.

makxenov commented 8 months ago

Fixed in https://github.com/NilFoundation/zkllvm-assigner/pull/169