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

SRI - 815 Add verifier.sol for workstep circuits #818

Conversation

biscuitdey
Copy link
Collaborator

@biscuitdey biscuitdey commented Jul 18, 2024

Description

This PR adds the verifier contracts for the workstep circuits.
The verifier contracts are generated while compiling the circuits using the script (plonk.sh).

We are using three separate verifier contracts for the 3 worksteps
because the verification key values are hardcoded inside the contract.
Using one verifier contract (where we pass the verification key as a function
param) is not possible as the contract uses assembly inside solidity contract
and assembly does not accept local variables. Also, if we declare the values as
storage variables, then we would have to change the verifyFunction code it as
there is different syntax to use storage variables.

Related Issue

#815

How Has This Been Tested

Tests would be added in upcoming PRs.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Request to be added as a Code Owner/Maintainer

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I commit to abide by the Responsibilities of Code Owners/Maintainers.

@biscuitdey biscuitdey linked an issue Jul 18, 2024 that may be closed by this pull request
3 tasks
@biscuitdey biscuitdey changed the base branch from main to develop July 18, 2024 16:24
@biscuitdey
Copy link
Collaborator Author

@Therecanbeonlyone1969 Do we need all three workstep circuit contracts? OR can we use only the workstep1 verifier contract to verify all three proofs (workstep1, workstep2 and workstep3)?

@ognjenkurtic
Copy link
Collaborator

@Therecanbeonlyone1969 Do we need all three workstep circuit contracts? OR can we use only the workstep1 verifier contract to verify all three proofs (workstep1, workstep2 and workstep3)?

My understanding from the call is that we can use a single one, although not sure why would the command create one contract for each circuit. I see that they differ only in the first dozen const variables. Anyways, leaving to @Therecanbeonlyone1969 for review.

Copy link
Collaborator

@Therecanbeonlyone1969 Therecanbeonlyone1969 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ... are we doing 3 contracts because of the different verification keys by circuit? @biscuitdey

@biscuitdey
Copy link
Collaborator Author

LGTM ... are we doing 3 contracts because of the different verification keys by circuit? @biscuitdey

@Therecanbeonlyone1969 Yes. The verification key values (Qm, Ql, etc.) are hardcoded in each of the verifier contract.

@biscuitdey
Copy link
Collaborator Author

biscuitdey commented Jul 22, 2024

@ognjenkurtic @Therecanbeonlyone1969

We are using three separate verifier contracts for the 3 worksteps
because the verification key values are hardcoded inside the contract.
Using one verifier contract (where we pass the verification key as a function
param) is not possible as the contract uses assembly inside solidity contract
and assembly does not accept local variables. Also, if we declare the values as
storage variables, then we would have to change the verifyFunction() code as
there is different syntax to use storage variables.

Please re-approve PR.

@Therecanbeonlyone1969 Therecanbeonlyone1969 dismissed their stale review July 22, 2024 22:44

need to reapprove

Copy link
Collaborator

@Therecanbeonlyone1969 Therecanbeonlyone1969 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. As an improvement, next time, let's update the verifier code to take storage variables

@biscuitdey biscuitdey merged commit 63cbc54 into develop Jul 23, 2024
2 checks passed
@biscuitdey biscuitdey deleted the 815-sri-add-the-verifirersol-as-an-zkp-artifact-to-the-bpi-and-env branch July 23, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SRI - Add the Verifirer.sol as an zkp artifact to the BPI and env
3 participants