0xPARC / zkrepl

An online playground for zero knowledge circuits
https://zkrepl.dev/
GNU General Public License v3.0
143 stars 23 forks source link

unexpected array behavior #21

Closed thegithubboogie closed 5 months ago

thegithubboogie commented 9 months ago

hi

i'm trying to figure out what's going on here:

template Array () {
    signal input in[3];
    signal input index;
    signal output out;

    signal a;
    assert(index==3);
    a <-- in[index];
    out <== a;
}

component main {public [in, index]} = Array();

/* INPUT = {
    "in": ["5", "3", "2"],
    "index": "3"
} */

in zkrepl this compiles and out = 3, even though that index position is out of bounds of the array. when i use a <-- in[3]; instead, the compiler correctly throws an error. assigning index to higher numbers returns various other values.

can someone help me understand if i'm doing something wrong?

thanks