NilFoundation / zkLLVM

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

[Feature request]: Dynamic loops processing #490

Closed ETatuzova closed 6 months ago

ETatuzova commented 8 months ago

What the problem is?

Now constraint system depends on public input. One cause of it is that for loops with different number of iterations produce different constraints and different fixed columns.

akokoshn commented 7 months ago

This feature should be enabled in scope of https://github.com/NilFoundation/zkLLVM/issues/433

akokoshn commented 6 months ago

After merge https://github.com/NilFoundation/zkLLVM/pull/514, for the different inputs generates same circuit. But current implementation doesn't support dynamic size loops

akokoshn commented 6 months ago

Will not be done We can't support dynamic loops because number of copy constraints depend on input.

int f(int a) {
    int res = 0;
    for (int i = 0; i < a; i++) {
        res++;
    }
    return res;
}

In this example will be generate one gate (component ADD for increase iterator and res) indepent on input (a), on each loop iteration added selector rows. But copy_constraints generated on the each call of component.