mirror of
https://github.com/arnaucube/go-circom-prover-verifier.git
synced 2026-02-07 03:16:46 +01:00
Add paralelization of polynomials in GenerateProof
- before: BenchmarkGenerateProof-4 1 1553842743 ns/op For a circuit of 9094 constraints takes 7.761949512s seconds to generate the proof. - now: BenchmarkGenerateProof-4 1 1331576862 ns/op For a circuit of 9094 constraints takes 5.745279126s to generate the proof. For bigger circuits (more constraints) the difference will be bigger. Executed on a Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, with 16GB of RAM
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/iden3/go-circom-prover-verifier/parsers"
|
||||
"github.com/iden3/go-circom-prover-verifier/types"
|
||||
@@ -27,8 +28,10 @@ func TestSmallCircuitGenerateProof(t *testing.T) {
|
||||
|
||||
assert.Equal(t, types.Witness{big.NewInt(1), big.NewInt(33), big.NewInt(3), big.NewInt(11)}, w)
|
||||
|
||||
beforeT := time.Now()
|
||||
proof, pubSignals, err := GenerateProof(pk, w)
|
||||
assert.Nil(t, err)
|
||||
fmt.Println("proof generation time elapsed:", time.Since(beforeT))
|
||||
|
||||
proofStr, err := parsers.ProofToJson(proof)
|
||||
assert.Nil(t, err)
|
||||
@@ -64,8 +67,10 @@ func TestBigCircuitGenerateProof(t *testing.T) {
|
||||
w, err := parsers.ParseWitness(witnessJson)
|
||||
require.Nil(t, err)
|
||||
|
||||
beforeT := time.Now()
|
||||
proof, pubSignals, err := GenerateProof(pk, w)
|
||||
assert.Nil(t, err)
|
||||
fmt.Println("proof generation time elapsed:", time.Since(beforeT))
|
||||
|
||||
proofStr, err := parsers.ProofToJson(proof)
|
||||
assert.Nil(t, err)
|
||||
@@ -99,7 +104,7 @@ func TestIdStateCircuitGenerateProof(t *testing.T) {
|
||||
// trustedsetup files (generated in
|
||||
// https://github.com/iden3/go-zksnark-full-flow-example)
|
||||
if false {
|
||||
fmt.Println("TestIdStateCircuitGenerateProof activated")
|
||||
fmt.Println("\nTestIdStateCircuitGenerateProof activated")
|
||||
provingKeyJson, err := ioutil.ReadFile("../testdata/idstate-circuit/proving_key.json")
|
||||
require.Nil(t, err)
|
||||
pk, err := parsers.ParsePk(provingKeyJson)
|
||||
@@ -110,8 +115,10 @@ func TestIdStateCircuitGenerateProof(t *testing.T) {
|
||||
w, err := parsers.ParseWitness(witnessJson)
|
||||
require.Nil(t, err)
|
||||
|
||||
beforeT := time.Now()
|
||||
proof, pubSignals, err := GenerateProof(pk, w)
|
||||
assert.Nil(t, err)
|
||||
fmt.Println("proof generation time elapsed:", time.Since(beforeT))
|
||||
|
||||
proofStr, err := parsers.ProofToJson(proof)
|
||||
assert.Nil(t, err)
|
||||
|
||||
Reference in New Issue
Block a user