-
Notifications
You must be signed in to change notification settings - Fork 16
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
Create assertions for non-strict comparison. #1
Create assertions for non-strict comparison. #1
Conversation
The assert does not produce a constraint, it just stops witness generation. So an adversarial prover could remove the assert line and generate an invalid proof that the verifier would accept. Also, simplify the sourceValue === claimedValue line by removing the IsZero circuit.
Also, several of the tests failed for me, but my changes didn't make any additional tests fail. My test output after importing `kv-merkle-tree` to fix compile error
|
Hey @BlakeMScurr ! Thanks for the pr ! :) For the tests did you install the node modules in the "./package" folder ? KV-Merkle-tree and other tests dependencies are imported from this folder. (I will add in the prepare script "cd ./package && yarn) |
Was passing a single signal to compconstant where it required a 254 bit binary decomposition.
This reverts commit c5ac5ac.
Ah thanks @gabin54 it works now! I hadn't installed the node modules in I fixed up a little mistake I made and now all the tests pass! |
Hey @BlakeMScurr, thank you for your PR! 🙏 Are you sure the check of the overflow is necessary ? For example in the Query system of iden3 they don't check the overflow https://github.com/iden3/circuits/blob/master/circuits/lib/query/query.circom#L29 But i asked the question here https://t.me/iden3io/7348 |
Hi @leosayous21! I'm not so sure about the overflow check. From my reading of the code it should be necessary, but circom can be subtle and I may be missing something. You're right, the iden3 library doesn't seem to do an overflow check. I will try to demonstrate an overflow, and if I can't, I'll revert the check! |
@leosayous21 I think I've demonstrated that the overflow check is necessary. Have a look at this repository and see if you agree and whether you can reproduce it. https://github.com/BlakeMScurr/comparator-overflow |
I loved so much this repo and what you did to test it ! 😍 The is252Bits can be remove to use directly Num2Bits because this works: template Is252Bits() {
signal input in;
component bits = Num2Bits(252);
bits.in <== in;
} The Num2Bits reconstructs the number using the number of bits used and compares it with the original value with a hard constraint here! https://github.com/iden3/circomlib/blob/master/circuits/bitify.circom#L38 |
Very good point! I've changed it like you suggested and I'll update my repo too. |
Done as per leosayous21's suggestion sismo-core/hydra-s1-zkps#1 (comment)
Thank you for your help on this! @BlakeMScurr i sent you some msg on twitter 🙂 |
assert(claimedValue<=sourceValue);
does not produce a constraint, it just stops witness generation. So an adversarial prover could remove the assert line and generate an invalid proof that the verifier would accept.assert
can't produce constraints because all constraints in circom are quadratic, and<=
is not quadratic.Note that
LessThan(n)
can fail for values greater than2^n
due to overflow, hence thatcompconstant
components.