-
Notifications
You must be signed in to change notification settings - Fork 519
Addition of a circuit that checks FRI proximity proofs #321
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
cb09cb4
feat: extended tests, use interface for hash instead of mimc
ThomasPiellard 2c5c4eb
feat: removed proof helper in merkle tree
ThomasPiellard c0629da
feat: removed deprecated test
ThomasPiellard bde197b
feat: modifs on rollup example to use new merkle proof circuit
ThomasPiellard 6ff8d2e
fix: call reset() on the hash function in leafSum
ThomasPiellard 6a7b754
feat: old Merkle proof circuits are removed
ThomasPiellard acfecb5
fix: fixed rollup tests
ThomasPiellard 054b64e
fix: fixed unconstrained public inputs
ThomasPiellard 8f7abc7
fix: all inputs are constrained in rollup example circuit
ThomasPiellard 4eb569d
feat: removed deprecated code
ThomasPiellard dee8267
feat: removed IgnoreUnconstrainedInputs option in rollup test
ThomasPiellard 5ccf897
feat: snark-fiatShamir test uses real string
ThomasPiellard de50c0e
feat: Fiat Shamir derivations OK
ThomasPiellard 64c24e4
refactor: the leaf is passed as argument for verifying Merkle proof
ThomasPiellard 2500faf
feat: merkle proofs + rounds consistency ok
ThomasPiellard 5a0f906
feat: hints wires are constrained
ThomasPiellard 15876a9
feat: add main method to verify proof regardless of the salt
ThomasPiellard 92c57e6
Merge branch 'develop' into feat/fri_verifier_circuit
gbotrel 3159ae1
build: fix staticcheck errors
gbotrel 430baad
build: re ran go generate
gbotrel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,8 @@ import ( | |
| "testing" | ||
|
|
||
| "github.com/consensys/gnark-crypto/ecc" | ||
| "github.com/consensys/gnark/backend" | ||
| "github.com/consensys/gnark/frontend" | ||
| "github.com/consensys/gnark/std/accumulator/merkle" | ||
| "github.com/consensys/gnark/std/hash/mimc" | ||
| "github.com/consensys/gnark/test" | ||
| ) | ||
|
|
@@ -77,26 +77,30 @@ func TestCircuitSignature(t *testing.T) { | |
| assert := test.NewAssert(t) | ||
|
|
||
| var signatureCircuit circuitSignature | ||
| for i := 0; i < BatchSizeCircuit; i++ { | ||
| signatureCircuit.MerkleProofReceiverBefore[i].Path = make([]frontend.Variable, depth) | ||
| signatureCircuit.MerkleProofReceiverAfter[i].Path = make([]frontend.Variable, depth) | ||
| signatureCircuit.MerkleProofSenderBefore[i].Path = make([]frontend.Variable, depth) | ||
| signatureCircuit.MerkleProofSenderAfter[i].Path = make([]frontend.Variable, depth) | ||
| } | ||
|
|
||
| assert.ProverSucceeded(&signatureCircuit, &operator.witnesses, test.WithCurves(ecc.BN254), test.WithCompileOpts(frontend.IgnoreUnconstrainedInputs())) | ||
|
|
||
| } | ||
|
|
||
| type circuitInclusionProof Circuit | ||
|
|
||
| // Circuit implements part of the rollup circuit only by delcaring a subset of the constraints | ||
| func (t *circuitInclusionProof) Define(api frontend.API) error { | ||
| if err := (*Circuit)(t).postInit(api); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| hashFunc, err := mimc.NewMiMC(api) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| merkle.VerifyProof(api, hashFunc, t.RootHashesBefore[0], t.MerkleProofsSenderBefore[0][:], t.MerkleProofHelperSenderBefore[0][:]) | ||
| merkle.VerifyProof(api, hashFunc, t.RootHashesBefore[0], t.MerkleProofsReceiverBefore[0][:], t.MerkleProofHelperReceiverBefore[0][:]) | ||
|
|
||
| merkle.VerifyProof(api, hashFunc, t.RootHashesAfter[0], t.MerkleProofsReceiverAfter[0][:], t.MerkleProofHelperReceiverAfter[0][:]) | ||
| merkle.VerifyProof(api, hashFunc, t.RootHashesAfter[0], t.MerkleProofsReceiverAfter[0][:], t.MerkleProofHelperReceiverAfter[0][:]) | ||
| t.MerkleProofReceiverBefore[0].VerifyProof(api, &hashFunc, t.LeafReceiver[0]) | ||
| t.MerkleProofReceiverAfter[0].VerifyProof(api, &hashFunc, t.LeafReceiver[0]) | ||
| t.MerkleProofSenderBefore[0].VerifyProof(api, &hashFunc, t.LeafSender[0]) | ||
| t.MerkleProofSenderAfter[0].VerifyProof(api, &hashFunc, t.LeafSender[0]) | ||
|
|
||
| return nil | ||
| } | ||
|
|
@@ -139,19 +143,33 @@ func TestCircuitInclusionProof(t *testing.T) { | |
| // verifies the proofs of inclusion of the transfer | ||
| assert := test.NewAssert(t) | ||
|
|
||
| // we allocate the slices of the circuit before compiling it | ||
| var inclusionProofCircuit circuitInclusionProof | ||
| for i := 0; i < BatchSizeCircuit; i++ { | ||
| inclusionProofCircuit.MerkleProofReceiverBefore[i].Path = make([]frontend.Variable, depth) | ||
| inclusionProofCircuit.MerkleProofReceiverAfter[i].Path = make([]frontend.Variable, depth) | ||
| inclusionProofCircuit.MerkleProofSenderBefore[i].Path = make([]frontend.Variable, depth) | ||
| inclusionProofCircuit.MerkleProofSenderAfter[i].Path = make([]frontend.Variable, depth) | ||
| } | ||
|
|
||
| assert.ProverSucceeded(&inclusionProofCircuit, &operator.witnesses, test.WithCurves(ecc.BN254), test.WithCompileOpts(frontend.IgnoreUnconstrainedInputs())) | ||
| assert.ProverSucceeded( | ||
| &inclusionProofCircuit, | ||
| &operator.witnesses, | ||
| test.WithCurves(ecc.BN254), | ||
| test.WithCompileOpts(frontend.IgnoreUnconstrainedInputs()), | ||
| test.WithBackends(backend.GROTH16)) | ||
|
|
||
| } | ||
|
|
||
| type circuitUpdateAccount Circuit | ||
|
|
||
| // Circuit implements part of the rollup circuit only by delcaring a subset of the constraints | ||
| func (t *circuitUpdateAccount) Define(api frontend.API) error { | ||
|
|
||
| if err := (*Circuit)(t).postInit(api); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| verifyAccountUpdated(api, t.SenderAccountsBefore[0], t.ReceiverAccountsBefore[0], | ||
| t.SenderAccountsAfter[0], t.ReceiverAccountsAfter[0], t.Transfers[0].Amount) | ||
| return nil | ||
|
|
@@ -195,6 +213,7 @@ func TestCircuitUpdateAccount(t *testing.T) { | |
| assert := test.NewAssert(t) | ||
|
|
||
| var updateAccountCircuit circuitUpdateAccount | ||
| (*Circuit)(&updateAccountCircuit).allocateSlicesMerkleProofs() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the cast?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type |
||
|
|
||
| assert.ProverSucceeded(&updateAccountCircuit, &operator.witnesses, test.WithCurves(ecc.BN254), test.WithCompileOpts(frontend.IgnoreUnconstrainedInputs())) | ||
|
|
||
|
|
@@ -239,8 +258,18 @@ func TestCircuitFull(t *testing.T) { | |
| // verifies the proofs of inclusion of the transfer | ||
|
|
||
| var rollupCircuit Circuit | ||
| for i := 0; i < BatchSizeCircuit; i++ { | ||
| rollupCircuit.MerkleProofReceiverBefore[i].Path = make([]frontend.Variable, depth) | ||
| rollupCircuit.MerkleProofReceiverAfter[i].Path = make([]frontend.Variable, depth) | ||
| rollupCircuit.MerkleProofSenderBefore[i].Path = make([]frontend.Variable, depth) | ||
| rollupCircuit.MerkleProofSenderAfter[i].Path = make([]frontend.Variable, depth) | ||
| } | ||
|
|
||
| // TODO full circuit has some unconstrained inputs, that's odd. | ||
| assert.ProverSucceeded(&rollupCircuit, &operator.witnesses, test.WithCurves(ecc.BN254), test.WithCompileOpts(frontend.IgnoreUnconstrainedInputs())) | ||
| assert.ProverSucceeded( | ||
| &rollupCircuit, | ||
| &operator.witnesses, | ||
| test.WithCurves(ecc.BN254), | ||
| test.WithBackends(backend.GROTH16)) | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocating the slices for the Merkle proof is only necessary when creating the full circuit and not for testing sub circuits