arnaucube
arnaucube/go-circom-prover-verifierPublic Self-hosted repository
go-circom-prover-verifier/README.md
README.mdRaw
 1# 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)
 2
 3Experimental Go implementation of the [Groth16 protocol](https://eprint.iacr.org/2016/260.pdf) zkSNARK prover & verifier compatible with [circom](https://github.com/iden3/circom).
 4
 5
 6Using [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.
 7
 8### Example
 9
10```go
11// read ProvingKey & Witness files
12provingKeyJson, _ := ioutil.ReadFile("testdata/provingkey.json")
13witnessJson, _ := ioutil.ReadFile("testdata/witness.json")
14
15// parse Proving Key
16pk, _ := circomprover.ParseProvingKey(provingKeyJson)
17
18// parse Witness
19w, _ := circomprover.ParseWitness(witnessJson)
20
21// generate the proof
22proof, pubSignals, err := circomprover.GenerateProof(pk, w)
23assert.Nil(t, err)
24
25proofStr, err := circomprover.ProofToString(proof)
26assert.Nil(t, err)
27publicStr, err := json.Marshal(circomprover.ArrayBigIntToString(pubSignals)
28assert.Nil(t, err)
29
30fmt.Println(proofStr)
31fmt.Println(publicStr)
32```