-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different result on two equivalent less-than comparisons #1327
Comments
I mean, the issue here is that To see that, you can save the following code into
Also, save the following into [
"21888242871839275222246405745257275088548364400416034343698204186575808495616",
"3"
] Then run the following: zokrates compile -i buggy_input.zok
zokrates setup
zokrates compute-witness --abi --stdin <input.json
zokrates generate-proof
zokrates verify You would see the following output, meaning that the verification thinks Compiling buggy_input.zok
Compiled code written to 'out'
Number of constraints: 258
Performing setup...
Verification key written to 'verification.key'
Proving key written to 'proving.key'
Setup completed
Computing witness...
Witness file written to 'witness'
Generating proof...
Proof written to 'proof.json'
Performing verification...
PASSED |
Description
In the code below, variable
b
is provided with valuep - 1
during runtime, wherep
is the largest value of the finite field; variablec
is assigned to be3
. The variablepMinusOne
is a constant variable statically assigned to bep - 1
. As such, variableb
holds the same value as variablepMinusOne
during runtime, andc > b
should have the same truth value asc > pMinusOne
. However,c > b
evaluates to true butc > pMinusOne
evaluates to false.Moreover, if you comment out the line
assert(c > pMinusOne);
, the verification passes.Environment
Steps to Reproduce
Save the code above into
buggy_input.zok
. Create a fileinput.json
and add the following content:Run the following commands from CLI:
zokrates compile -i buggy_input.zok zokrates setup zokrates compute-witness --abi --stdin <input.json zokrates generate-proof zokrates verify
You would see the following output:
Compilation failed: buggy_input.zok: Assertion failed (buggy_input.zok:6:5) make: *** [Makefile:13: out] Error 1
The error messages says that line 6 (
assert(c > pMinusOne);
) fails.Comment out line 6 and re-run the commands above, you would see the verification passes:
The text was updated successfully, but these errors were encountered: