You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can see that we're not actually applying the condition to the addition which results in the range check failing due to an overflow in all cases.
The simplest solution to this is to just multiply the value being range checked by the condition which will turn off any under/overflow checks. The value which is being written to witness 5 will still be an invalid u32 but we won't use this outside of the conditional branch so this isn't important. This then gives the ACIR:
Aim
Consider the program
Expected Behavior
We should expect that this program should execute correctly for
x != 10
but fail in the case ofx == 10
due to an overflow.Bug
The ACIR generated for this program is as below (annotated)
We can see that we're not actually applying the condition to the addition which results in the range check failing due to an overflow in all cases.
The simplest solution to this is to just multiply the value being range checked by the condition which will turn off any under/overflow checks. The value which is being written to witness 5 will still be an invalid
u32
but we won't use this outside of the conditional branch so this isn't important. This then gives the ACIR:We could potentially be a bit smarter about this in order to avoid unnecessary constraints but this is fine for the time being.
To Reproduce
nargo execute
supplied program on master.Installation Method
None
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: