0xPolygonMiden / examples

Examples of using Polygon Miden
MIT License
18 stars 18 forks source link

feat: Verification of programs #76

Closed Dominik1999 closed 1 year ago

Dominik1999 commented 1 year ago

I added the ability to verify a program to the playground. This should close #67

The user can create a proof using the "Prove" button. Then the user can then verify that proof using the "Verify" button. If the Inputs, the Program or the Outputs are being tampered with after the proof was generated, the proof fails.

https://user-images.githubusercontent.com/35031754/223128878-e07cb7d3-0d44-445f-a22a-82f5dcba9c8b.mov

Note: I needed to return the whole stack, for now, to be able to use the program outputs as inputs in the verification step. This is a bad UX.

  /**
   * This handles the number of outputs that are returned to the user.
   * At the moment we return the whole stack always. This is not good UX.
   * But it is needed to use the Output again as Input for the verification step.
   */
  // const [numOutputs, setNumOutputs] = React.useState(16);
Dominik1999 commented 1 year ago

Thanks @Dominik1999 it's really cool to have this working! I left a few comments inline. Additionally, this isn't running successfully for me locally when I check out your branch. Can you double-check installing & building everything from scratch to see if you get errors?

Thanks a lot @grjte!

I refactored a bit and addressed your comments. When I run npm run build:miden && npm install && npm run start in the playground folder it builds and starts. Which error message are you seeing?

grjte commented 1 year ago

When I run npm run build:miden && npm install && npm run start in the playground folder it builds and starts. Which error message are you seeing?

Thanks @Dominik1999 it's running fine for me now! I think maybe I did npm install before build last time.

This is probably part of the UX discussion, but one thing I noticed - if I Prove and then I change programs and Run and then I attempt to Verify it fails because the proof and outputs don't match.

I think this is a bit confusing and maybe we should clear the session data when the example is changed or when Run is pressed. What do you think? So if any other action is taken after Prove (other than manually editing the inputs/outputs) then the proof data would be cleared - I think it would give clearer errors when attempting to Verify