arnaucube 3691785054 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
2020-04-24 10:50:28 +02:00
2020-04-17 21:21:39 +02:00
2020-04-17 21:21:39 +02:00
2020-04-17 20:31:53 +02:00
2020-04-21 19:22:35 +02:00
2020-04-23 16:03:40 +02:00
2020-04-21 19:22:35 +02:00
2020-04-21 19:22:35 +02:00
2020-03-28 21:48:25 +01:00
2020-04-20 12:49:00 +02:00

go-circom-prover-verifier GoDoc Go Report Card Test

Experimental Go implementation of the Groth16 protocol zkSNARK prover & verifier compatible with circom.

Using bn256 (used by go-ethereum) for the Pairing curve operations.

Example

  • Generate Proof
import (
  "github.com/iden3/go-circom-prover-verifier/parsers"
  "github.com/iden3/go-circom-prover-verifier/prover"
  "github.com/iden3/go-circom-prover-verifier/verifier"
)

[...]

// read ProvingKey & Witness files
provingKeyJson, _ := ioutil.ReadFile("../testdata/small/proving_key.json")
witnessJson, _ := ioutil.ReadFile("../testdata/small/witness.json")

// parse Proving Key
pk, _ := parsers.ParsePk(provingKeyJson)

// parse Witness
w, _ := parsers.ParseWitness(witnessJson)

// generate the proof
proof, pubSignals, _ := prover.GenerateProof(pk, w)

// print proof & publicSignals
proofStr, _ := parsers.ProofToJson(proof)
publicStr, _ := json.Marshal(parsers.ArrayBigIntToString(pubSignals))
fmt.Println(proofStr)
fmt.Println(publicStr)
  • Verify Proof
// read proof & verificationKey & publicSignals
proofJson, _ := ioutil.ReadFile("../testdata/big/proof.json")
vkJson, _ := ioutil.ReadFile("../testdata/big/verification_key.json")
publicJson, _ := ioutil.ReadFile("../testdata/big/public.json")

// parse proof & verificationKey & publicSignals
public, _ := parsers.ParsePublicSignals(publicJson)
proof, _ := parsers.ParseProof(proofJson)
vk, _ := parsers.ParseVk(vkJson)

// verify the proof with the given verificationKey & publicSignals
v := verifier.Verify(vk, proof, public)
fmt.Println(v)

CLI

From the cli directory:

  • Show options
> go run cli.go -help
go-circom-prover-verifier
                 v0.0.1
Usage of /tmp/go-build620318239/b001/exe/cli:
  -proof string
        proof path (default "proof.json")
  -prove
        prover mode
  -provingkey string
        provingKey path (default "proving_key.json")
  -public string
        public signals path (default "public.json")
  -verificationkey string
        verificationKey path (default "verification_key.json")
  -verify
        verifier mode
  -witness string
        witness path (default "witness.json")
  • Prove
> go run cli.go -prove -provingkey=../testdata/small/proving_key.json -witness=../testdata/small/witness.json
  • Verify
> go run cli.go -verify -verificationkey=../testdata/small/verification_key.json
Description
No description provided
Readme GPL-3.0 4.4 MiB
Languages
Go 100%