iden3 / go-circom-prover-verifier

Go implementation of the Groth16 zkSNARK Prover and Verifier compatible with Circom
GNU General Public License v3.0
38 stars 13 forks source link

Add own go-circom ProvingKey Bin format #18

Closed arnaucube closed 4 years ago

arnaucube commented 4 years ago

Add own go-circom ProvingKey Bin format Add parsers from bin to pk and from pk to bin. Add cli to convert from proving_key.json to proving_key_go.bin (which is used in the compile-circuits.sh script).

BenchmarkParsePk/ParsePkJson_circuit1k-4                  595215              1954 ns/op
BenchmarkParsePk/ParsePkBin_circuit1k-4                        2         522174688 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit1k-4                 623182              1901 ns/op
BenchmarkParsePk/ParsePkJson_circuit5k-4                       1        2861959141 ns/op
BenchmarkParsePk/ParsePkBin_circuit5k-4                        1        2610638932 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit5k-4                 612906              1907 ns/op
BenchmarkParsePk/ParsePkJson_circuit10k-4                      1        5793696755 ns/op
BenchmarkParsePk/ParsePkBin_circuit10k-4                       1        5204251056 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit10k-4                603478              1913 ns/op
BenchmarkParsePk/ParsePkJson_circuit20k-4                      1        11404022165 ns/op
BenchmarkParsePk/ParsePkBin_circuit20k-4                       1        10392012613 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit20k-4                620488              1921 ns/op

For the 10k constraints circuit is arround 1_368_976x improvement. For the 20k constraints circuit is arround 5_409_689x improvement.

ed255 commented 4 years ago

I would be nice if the extension for the new go binary format would be ".go.bin" so that it can be differentiate by extension from the snarkjs ".bin" format.

arnaucube commented 4 years ago

resolves #17

ed255 commented 4 years ago

Awesome!