Skip to content
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

Fix smart contracts not verifying proofs #1302

Merged
merged 14 commits into from
Dec 11, 2023
Merged

Conversation

mitschabaude
Copy link
Member

@mitschabaude mitschabaude commented Dec 11, 2023

Fixes #1166
Fixes #1231

Description of the fix

Requiring a proof to verify is based on mutation of the proof value: verify() sets the shouldVerify field to Bool(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

  • adds a regression test to CI
  • add a unit test checking the result of sortMethodArguments and the outputs of picklesRuleFromFunction (the latter would have caught this bug)

src/tests/fake-proof.ts Outdated Show resolved Hide resolved
@mitschabaude mitschabaude merged commit 3978a97 into main Dec 11, 2023
13 checks passed
@mitschabaude mitschabaude deleted the fix/any-proof-verifies branch December 11, 2023 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants