mirror of
https://github.com/arnaucube/go-circom-prover-verifier.git
synced 2026-02-07 19:36:42 +01:00
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:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
bn256 "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
|
||||
"github.com/iden3/go-circom-prover-verifier/types"
|
||||
"github.com/iden3/go-iden3-crypto/utils"
|
||||
)
|
||||
|
||||
// Proof is the data structure of the Groth16 zkSNARK proof
|
||||
@@ -123,13 +124,18 @@ func calculateH(pk *types.Pk, w types.Witness) []*big.Int {
|
||||
polCT[j] = fAdd(polCT[j], fMul(w[i], pk.PolsC[i][j]))
|
||||
}
|
||||
}
|
||||
polAS := ifft(polAT)
|
||||
polBS := ifft(polBT)
|
||||
polATe := utils.BigIntArrayToElementArray(polAT)
|
||||
polBTe := utils.BigIntArrayToElementArray(polBT)
|
||||
polCTe := utils.BigIntArrayToElementArray(polCT)
|
||||
|
||||
polABS := polynomialMul(polAS, polBS)
|
||||
polCS := ifft(polCT)
|
||||
polABCS := polynomialSub(polABS, polCS)
|
||||
polASe := ifft(polATe)
|
||||
polBSe := ifft(polBTe)
|
||||
polABSe := polynomialMulE(polASe, polBSe)
|
||||
|
||||
hS := polABCS[m:]
|
||||
return hS
|
||||
polCSe := ifft(polCTe)
|
||||
|
||||
polABCSe := polynomialSubE(polABSe, polCSe)
|
||||
|
||||
hSe := polABCSe[m:]
|
||||
return ElementArrayToBigIntArray(hSe)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user