mirror of
https://github.com/arnaucube/go-circom-prover-verifier.git
synced 2026-02-06 19:06:43 +01:00
Add benchmarks, Rename repo, update README.md
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# go-circom-prover [](https://godoc.org/github.com/iden3/go-circom-prover) [](https://goreportcard.com/report/github.com/iden3/go-circom-prover)
|
# 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)
|
||||||
|
|
||||||
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.
|
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,7 +36,16 @@ func TestSmallCircuitGenerateProf(t *testing.T) {
|
|||||||
err = ioutil.WriteFile("testdata/small/public.json", publicStr, 0644)
|
err = ioutil.WriteFile("testdata/small/public.json", publicStr, 0644)
|
||||||
assert.Nil(t, err)
|
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
|
// 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)
|
err = ioutil.WriteFile("testdata/big/public.json", publicStr, 0644)
|
||||||
assert.Nil(t, err)
|
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
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,3 +26,23 @@ func TestVerify1(t *testing.T) {
|
|||||||
v := Verify(vk, proof, public)
|
v := Verify(vk, proof, public)
|
||||||
assert.True(t, v)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user