Fix smart contracts not verifying proofs #1302
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1166
Fixes #1231
Description of the fix
Requiring a proof to verify is based on mutation of the proof value:
verify()
sets theshouldVerify
field toBool(true)
. On the other hand, the smart contract wrapper clones all input arguments to the prover to avoid modifying them (which can easily lead to bugs because we run the method multiple times). The cloning made the contract unable to mutate the original proof.The short-term fix was to not clone proofs, similar to how we don't clone primitive provable types. It would be better if a future refactor made proof verification not dependent on mutating a method argument. Instead, we could introduce a global context which holds the proofs to potentially verify inside a circuit, and set properties on those. Also, it would be nice to have an error when we forget to verify a proof (and an explicit method to not verify them).
Changes
sortMethodArguments
and the outputs ofpicklesRuleFromFunction
(the latter would have caught this bug)