Browse Source

Add benchmarks, Rename repo, update README.md

ed255-patch-1
arnaucube 4 years ago
parent
commit
a439651faf
3 changed files with 58 additions and 4 deletions
  1. +2
    -2
      README.md
  2. +36
    -2
      prover_test.go
  3. +20
    -0
      verifier_test.go

+ 2
- 2
README.md

@ -1,6 +1,6 @@
# go-circom-prover [![GoDoc](https://godoc.org/github.com/iden3/go-circom-prover?status.svg)](https://godoc.org/github.com/iden3/go-circom-prover) [![Go Report Card](https://goreportcard.com/badge/github.com/iden3/go-circom-prover)](https://goreportcard.com/report/github.com/iden3/go-circom-prover)
# go-circom-prover-verifier [![GoDoc](https://godoc.org/github.com/iden3/go-circom-prover-verifier?status.svg)](https://godoc.org/github.com/iden3/go-circom-prover-verifier) [![Go Report Card](https://goreportcard.com/badge/github.com/iden3/go-circom-prover-verifier)](https://goreportcard.com/report/github.com/iden3/go-circom-prover-verifier)
Experimental Go implementation of the [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) zkSNARK prover compatible with [circom](https://github.com/iden3/circom).
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).
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.

+ 36
- 2
prover_test.go

@ -36,7 +36,16 @@ func TestSmallCircuitGenerateProf(t *testing.T) {
err = ioutil.WriteFile("testdata/small/public.json", publicStr, 0644)
assert.Nil(t, err)
// to verify the proof:
// verify the proof
vkJson, err := ioutil.ReadFile("testdata/small/verification_key.json")
require.Nil(t, err)
vk, err := ParseVk(vkJson)
require.Nil(t, err)
v := Verify(vk, proof, pubSignals)
assert.True(t, v)
// to verify the proof with snarkjs:
// snarkjs verify --vk testdata/small/verification_key.json -p testdata/small/proof.json --pub testdata/small/public.json
}
@ -64,6 +73,31 @@ func TestBigCircuitGenerateProf(t *testing.T) {
err = ioutil.WriteFile("testdata/big/public.json", publicStr, 0644)
assert.Nil(t, err)
// to verify the proof:
// verify the proof
vkJson, err := ioutil.ReadFile("testdata/big/verification_key.json")
require.Nil(t, err)
vk, err := ParseVk(vkJson)
require.Nil(t, err)
v := Verify(vk, proof, pubSignals)
assert.True(t, v)
// to verify the proof with snarkjs:
// snarkjs verify --vk testdata/big/verification_key.json -p testdata/big/proof.json --pub testdata/big/public.json
}
func BenchmarkGenerateProof(b *testing.B) {
provingKeyJson, err := ioutil.ReadFile("testdata/big/proving_key.json")
require.Nil(b, err)
pk, err := ParsePk(provingKeyJson)
require.Nil(b, err)
witnessJson, err := ioutil.ReadFile("testdata/big/witness.json")
require.Nil(b, err)
w, err := ParseWitness(witnessJson)
require.Nil(b, err)
for i := 0; i < b.N; i++ {
GenerateProof(pk, w)
}
}

+ 20
- 0
verifier_test.go

@ -26,3 +26,23 @@ func TestVerify1(t *testing.T) {
v := Verify(vk, proof, public)
assert.True(t, v)
}
func BenchmarkVerify(b *testing.B) {
proofJson, err := ioutil.ReadFile("testdata/big/proof.json")
require.Nil(b, err)
vkJson, err := ioutil.ReadFile("testdata/big/verification_key.json")
require.Nil(b, err)
publicJson, err := ioutil.ReadFile("testdata/big/public.json")
require.Nil(b, err)
public, err := ParsePublicSignals(publicJson)
require.Nil(b, err)
proof, err := ParseProof(proofJson)
require.Nil(b, err)
vk, err := ParseVk(vkJson)
require.Nil(b, err)
for i := 0; i < b.N; i++ {
Verify(vk, proof, public)
}
}

Loading…
Cancel
Save