Inputs are assigned wrong values when there is a mistake in array-typed input size
Closed this issue · 1 comments
Working with quite a complex circuits I figured out one weird behavior of WitnessCalculator which make my team spend a lot of time trying to figure out the root cause and fix it.
Preconditions:
- Some circuit has an input of array type
- There is at least one more input following the array type input in the circuit source code
- The value which is assigned to array input has (by mistake) more elements than is expected
Expected behaviour by usual development practice:
The test framework should throw some exception that the input has wrong number of elements
Actual behaviour:
Nothing is thrown but the extra values in the array just ASSIGNED TO THE NEXT INPUT(S) !!!
Example:
template Example () {
signal input a[2];
signal input b;
signal output c;
log (a[0]);
log (a[1]);
log (b);
a[1] === 0;
c <== a[0] * b;
c === 10;
}
component main = Example();
These inputs will work:
/* INPUT = {
"a": ["5", "0"],
"b": "2"
} */
These inputs will break c === 10; constraint as "b" will be "overlapped" with the third element of "a", which is 3
/* INPUT = {
"a": ["5", "0", "3"],
"b": "2"
} */
You can easily check the above in https://zkrepl.dev/
The issue is solved in v0.0.11 version.
Now the following error is thrown
Closing the issue