Add polynomials arithmetic in goff

Polynomials and ifft moved to goff (iden3/go-iden3-crypto/ff) instead of *big.Int.

Benchmarks:

- Before:
BenchmarkArithmetic/polynomialSub-4         	    2774	    441063 ns/op
BenchmarkArithmetic/polynomialMul-4         	       1	1135732757 ns/op
BenchmarkArithmetic/polynomialDiv-4         	     768	   1425192 ns/op
BenchmarkGenerateProof-4                    	       1	2844488975 ns/op

- With this commit:
BenchmarkArithmetic/polynomialSubE-4        	   23097	     54152 ns/op
BenchmarkArithmetic/polynomialMulE-4        	      25	  44914327 ns/op
BenchmarkArithmetic/polynomialDivE-4        	    8703	    132573 ns/op
BenchmarkGenerateProof-4                    	       1	1530398526 ns/op
This commit is contained in:
arnaucube
2020-04-20 12:37:49 +02:00
parent 3f5f8e2318
commit 324c817d42
7 changed files with 178 additions and 33 deletions

View File

@@ -9,6 +9,14 @@ Using [bn256](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256/c
- Generate Proof
```go
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")
@@ -20,7 +28,7 @@ pk, _ := parsers.ParsePk(provingKeyJson)
w, _ := parsers.ParseWitness(witnessJson)
// generate the proof
proof, pubSignals, _ := GenerateProof(pk, w)
proof, pubSignals, _ := prover.GenerateProof(pk, w)
// print proof & publicSignals
proofStr, _ := parsers.ProofToJson(proof)
@@ -42,7 +50,7 @@ proof, _ := parsers.ParseProof(proofJson)
vk, _ := parsers.ParseVk(vkJson)
// verify the proof with the given verificationKey & publicSignals
v := Verify(vk, proof, public)
v := verifier.Verify(vk, proof, public)
fmt.Println(v)
```