When the first branch of a function returns a single-element array, later branches will return weird values
anonnice1999 opened this issue · 0 comments
anonnice1999 commented
I have a simple function as following:
pragma circom 2.1.7;
function get_gkr__ext__evaluations(i) {
if (i == 1) {
return [1]; // one-element array
}
if (i == 2) {
return [1, 2, 3, 4];
}
return [0];
}
template X() {
signal input x;
var a[4] = get_gkr__ext__evaluations(2);
for (var i = 0; i < 4; i++) {
log("a[", i, "]", a[i]);
}
}
component main {public [x]} = X();
When I try to get the values in the branch i==2
, it will returns an array with weird values.
a[ 0 ] 1
a[ 1 ] 1701549928
a[ 2 ] 2108807937
a[ 3 ] 0
But when I change the value in the first branch i==1
to a two-element array, the error will not happen anymore.
pragma circom 2.1.7;
function get_gkr__ext__evaluations(i) {
if (i == 1) {
return [1, 1]; // change to two-element array
}
if (i == 2) {
return [1, 2, 3, 4];
}
return [0];
}
template X() {
signal input x;
var a[4] = get_gkr__ext__evaluations(2);
for (var i = 0; i < 4; i++) {
log("a[", i, "]", a[i]);
}
}
component main {public [x]} = X();
a[ 0 ] 1
a[ 1 ] 2
a[ 2 ] 3
a[ 3 ] 4