Inconsistent behavior on unused unsigned integer and field inputs
gwdjkspnado opened this issue · comments
Description
Zokrates would throw an error if a field input is not used. However, when an unsigned integer input is not used, no error message would be thrown. This kind of behavior is inconsistent and causes confusion. It would be better if Zokrates can make the behavior consistent.
Environment
- Zokrates Compiler version: 0.8.7
- Operating system: Ubuntu 22.04.2 LTS
Steps to Reproduce
Save the following code as unconstrained.zok
and check that the compiler would complain about the unused field input:
def main(private field a) {
}
Compile with zokrates compile -i unconstrained.zok
, you would get the following error:
Compiling unconstrained.zok
Error: Found 1 unconstrained variable(s)
However, if you change the type of a
to u32
, the compiler would not complain about the unused input:
def main(private u32 a) {
}
Compile with zokrates compile -i unconstrained.zok
, the compilation succeeds without any error message:
Compiling unconstrained.zok
Compiled code written to 'out'
Number of constraints: 33
In the case of a u32
input, there is a bit decomposition and sum check happening which is the reason why it's considered constrained. Basically, the input is checked to be in the u32
range.
Thanks for your reply! Closing this issue for now.