mirror of
https://github.com/arnaucube/go-circom-prover-verifier.git
synced 2026-02-06 19:06:43 +01:00
Fix prover benchmark file paths, update readme, and other small updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# go-circom-prover-verifier [](https://godoc.org/github.com/iden3/go-circom-prover-verifier) [](https://goreportcard.com/report/github.com/iden3/go-circom-prover-verifier) [](https://github.com/iden3/go-circom-prover-verifier/actions?query=workflow%3ATest)
|
# go-circom-prover-verifier [](https://godoc.org/github.com/iden3/go-circom-prover-verifier) [](https://goreportcard.com/report/github.com/iden3/go-circom-prover-verifier) [](https://github.com/iden3/go-circom-prover-verifier/actions?query=workflow%3ATest)
|
||||||
|
|
||||||
Experimental Go implementation of the [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) zkSNARK prover & verifier compatible with [circom](https://github.com/iden3/circom).
|
Go implementation of the [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) zkSNARK prover & verifier compatible with [circom](https://github.com/iden3/circom).
|
||||||
|
|
||||||
|
|
||||||
Using [bn256](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256/cloudflare) (used by [go-ethereum](https://github.com/ethereum/go-ethereum)) for the Pairing curve operations.
|
Using [bn256](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256/cloudflare) (used by [go-ethereum](https://github.com/ethereum/go-ethereum)) for the Pairing curve operations.
|
||||||
@@ -82,9 +82,9 @@ Usage of /tmp/go-build620318239/b001/exe/cli:
|
|||||||
|
|
||||||
- Prove
|
- Prove
|
||||||
```
|
```
|
||||||
> go run cli.go -prove -provingkey=../testdata/small/proving_key.json -witness=../testdata/small/witness.json
|
> go run cli.go -prove -provingkey=../testdata/circuit5k/proving_key.json -witness=../testdata/circuit5k/witness.json
|
||||||
```
|
```
|
||||||
- Verify
|
- Verify
|
||||||
```
|
```
|
||||||
> go run cli.go -verify -verificationkey=../testdata/small/verification_key.json
|
> go run cli.go -verify -verificationkey=../testdata/circuit5k/verification_key.json
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/iden3/go-circom-prover-verifier/parsers"
|
"github.com/iden3/go-circom-prover-verifier/parsers"
|
||||||
@@ -34,15 +35,15 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error:", err)
|
fmt.Println("Error:", err)
|
||||||
}
|
}
|
||||||
return
|
os.Exit(0)
|
||||||
} else if *verify {
|
} else if *verify {
|
||||||
err := cmdVerify(*proofPath, *verificationKeyPath, *publicPath)
|
err := cmdVerify(*proofPath, *verificationKeyPath, *publicPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error:", err)
|
fmt.Println("Error:", err)
|
||||||
}
|
}
|
||||||
return
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
fmt.Println("use -help for the list of commands")
|
flag.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdProve(provingKeyPath, witnessPath, proofPath, publicPath string) error {
|
func cmdProve(provingKeyPath, witnessPath, proofPath, publicPath string) error {
|
||||||
|
|||||||
@@ -61,12 +61,12 @@ func testCircuitGenerateProof(t *testing.T, circuit string) {
|
|||||||
|
|
||||||
func BenchmarkGenerateProof(b *testing.B) {
|
func BenchmarkGenerateProof(b *testing.B) {
|
||||||
// benchmark with a circuit of 10000 constraints
|
// benchmark with a circuit of 10000 constraints
|
||||||
provingKeyJson, err := ioutil.ReadFile("../testdata/circuit1/proving_key.json")
|
provingKeyJson, err := ioutil.ReadFile("../testdata/circuit5k/proving_key.json")
|
||||||
require.Nil(b, err)
|
require.Nil(b, err)
|
||||||
pk, err := parsers.ParsePk(provingKeyJson)
|
pk, err := parsers.ParsePk(provingKeyJson)
|
||||||
require.Nil(b, err)
|
require.Nil(b, err)
|
||||||
|
|
||||||
witnessJson, err := ioutil.ReadFile("../testdata/circuit1/witness.json")
|
witnessJson, err := ioutil.ReadFile("../testdata/circuit5k/witness.json")
|
||||||
require.Nil(b, err)
|
require.Nil(b, err)
|
||||||
w, err := parsers.ParseWitness(witnessJson)
|
w, err := parsers.ParseWitness(witnessJson)
|
||||||
require.Nil(b, err)
|
require.Nil(b, err)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ type Vk struct {
|
|||||||
IC []*bn256.G1
|
IC []*bn256.G1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify verifies the Groth16 zkSNARK proof
|
||||||
func Verify(vk *types.Vk, proof *types.Proof, inputs []*big.Int) bool {
|
func Verify(vk *types.Vk, proof *types.Proof, inputs []*big.Int) bool {
|
||||||
if len(inputs)+1 != len(vk.IC) {
|
if len(inputs)+1 != len(vk.IC) {
|
||||||
fmt.Println("len(inputs)+1 != len(vk.IC)")
|
fmt.Println("len(inputs)+1 != len(vk.IC)")
|
||||||
|
|||||||
Reference in New Issue
Block a user