arnaucube
arnaucube/gnark-plonky2-verifierPublic Self-hosted repository
gnark-plonky2-verifier/README.md
README.mdRaw
 1# gnark-plonky2-verifier
 2
 3This is an in-progress implementation of a [Plonky2](https://github.com/mir-protocol/plonky2) verifier in Gnark (supports Groth16 and PLONK). It currently is able to verify some dummy circuits, but not much more as many of the custom gates used in Plonky2 are currently not implemented.
 4
 5Besides the verifier, there are some Gnark implementation of circuits in this repo that may be useful for other projects:
 6
 7- [Goldilocks](https://github.com/succinctlabs/gnark-plonky2-verifier/blob/main/field/field.go)
 8- [Poseidon](https://github.com/succinctlabs/gnark-plonky2-verifier/blob/main/poseidon/poseidon.go)
 9- [FRI](https://github.com/succinctlabs/gnark-plonky2-verifier/blob/main/plonky2_verifier/fri.go)
10
11## Requirements
12
13- [Go (1.20.1+)](https://go.dev/doc/install)
14
15## Benchmark
16
17To run the benchmark,
18```
19go run benchmark.go
20```
21
22Here are relevant numbers from a benchmark ran on an M1 Max with 10 CPU cores.
23
24```
2511:04:08 INF compiling circuit
2611:04:08 INF parsed circuit inputs nbPublic=0 nbSecret=0
2711:12:30 INF building constraint system nbConstraints=6740784
28Generating witness 2023-03-28 11:12:42.702566 -0700 PDT m=+514.333410376
29Running circuit setup 2023-03-28 11:12:42.702666 -0700 PDT m=+514.333509834
30Creating proof 2023-03-28 11:18:58.881518 -0700 PDT m=+890.519971543
3111:18:59 DBG constraint system solver done backend=groth16 nbConstraints=6740784 took=675.361625
3211:19:10 DBG prover done backend=groth16 curve=bn254 nbConstraints=6740784 took=10512.664584
33Verifying proof 2023-03-28 11:19:10.169636 -0700 PDT m=+901.808314709
3411:19:10 DBG verifier done backend=groth16 curve=bn254 took=6.288792
35bn254 2023-03-28 11:19:10.175992 -0700 PDT m=+901.814670834
36```
37
38The circuit can be significantly optimized by using more efficient arithmetic for Goldilocks, among other things.