Commit Graph

58 Commits

Author SHA1 Message Date
Eduard S
6d4b1abc10 Test all fields of parsed binary pk 2020-05-22 12:37:08 +02:00
Eduard S
e652f34753 Merge pull request #19 from iden3/fix/pk-parse-benchmarks
Fix pk parser benchmarks
2020-05-21 16:19:07 +02:00
arnaucube
42961f6b94 Fix pk parser benchmarks
Parsers were working correctly, but the benchmarks had errors.

The benchmarks in the commit d1b3979eb6
are incorrect, correct ones are:

```
BenchmarkParsePk/ParsePkJson_circuit1k-4         	       2	 529437960 ns/op
BenchmarkParsePk/ParsePkBin_circuit1k-4          	       2	 607792597 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit1k-4        	       2	 540594611 ns/op
BenchmarkParsePk/ParsePkJson_circuit5k-4         	       1	2769819086 ns/op
BenchmarkParsePk/ParsePkBin_circuit5k-4          	       1	3094913319 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit5k-4        	       1	2404651389 ns/op
BenchmarkParsePk/ParsePkJson_circuit10k-4        	       1	5374917709 ns/op
BenchmarkParsePk/ParsePkBin_circuit10k-4         	       1	5756633515 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit10k-4       	       1	4782081310 ns/op
BenchmarkParsePk/ParsePkJson_circuit20k-4        	       1	10374987398 ns/op
BenchmarkParsePk/ParsePkBin_circuit20k-4         	       1	11528361584 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit20k-4       	       1	9541829245 ns/op
BenchmarkParsePk/ParsePkJson_circuit50k-4         	       1	25979727146 ns/op
BenchmarkParsePk/ParsePkBin_circuit50k-4          	       1	28434810627 ns/op
BenchmarkParsePk/ParsePkGoBin_circuit50k-4        	       1	23860248412 ns/op
```

The size of ProvingKey file for a circuit of 20k and 50k constraints:
```
circuit 20k constraints:
10097876 bytes of proving_key.go.bin
10097876 bytes of proving_key.bin
29760049 bytes of proving_key.json

circuit 50k constraints:
24195028 bytes of proving_key.go.bin
24194964 bytes of proving_key.bin
71484081 bytes of proving_key.json
```
2020-05-21 13:19:45 +02:00
Eduard S
386758370e Merge pull request #18 from iden3/feature/pk-own-format
Add own go-circom ProvingKey Bin format
2020-05-21 11:25:53 +02:00
arnaucube
2b8a15ca1a Add cli to convert Pk to go-circom binary file 2020-05-20 18:07:10 +02:00
arnaucube
d1b3979eb6 Add own go-circom ProvingKey Bin format
Add parsers from bin to pk and from pk to bin.

```
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.
2020-05-20 13:35:06 +02:00
Eduard S
de95d7a3e4 Merge pull request #16 from iden3/feature/pk-bin
Add ProvingKey binary parser
2020-05-20 12:31:36 +02:00
arnaucube
5c2aaec1ca Add ProvingKey binary parser
The time on the parsing doesn't improve, as the data from the binary
file needs to be converted to `affine` representation, and then parsed
into the `bn256.G1` & `bn256.G2` formats (Montgomery). But the size of
the ProvingKey files in binary is much smaller, so will be better
handled by the smarthpones.

- Parse time benchmarks:
```
BenchmarkParsePk/Parse_Pk_bin_circuit1k-4         	       2	 563729994 ns/op
BenchmarkParsePk/Parse_Pk_json_circuit1k-4        	  635641	      1941 ns/op
BenchmarkParsePk/Parse_Pk_bin_circuit5k-4         	       1	2637941658 ns/op
BenchmarkParsePk/Parse_Pk_json_circuit5k-4        	       1	2986560185 ns/op
BenchmarkParsePk/Parse_Pk_bin_circuit10k-4        	       1	5337639150 ns/op
BenchmarkParsePk/Parse_Pk_json_circuit10k-4       	       1	6149568824 ns/op
BenchmarkParsePk/Parse_Pk_bin_circuit20k-4        	       1	10533654623 ns/op
BenchmarkParsePk/Parse_Pk_json_circuit20k-4       	       1	11657326851 ns/op
```

- Size of ProvingKey file for a circuit of 50k constraints:
```
circuit 20k constraints:
10097812 bytes of proving_key.bin
29760049 bytes of proving_key.json

circuit 50k constraints:
24194964 bytes of proving_key.bin
71484081 bytes of proving_key.json
```
2020-05-20 12:25:27 +02:00
arnau
bedd64cc70 Merge pull request #15 from iden3/feature/proofjson
Add JSON Marshal/Unmarshal to Proof
2020-05-15 12:00:33 +02:00
Eduard S
0d4e2581bd Add JSON Marshal/Unmarshal to Proof 2020-05-15 11:43:47 +02:00
Eduard S
1aa316cbd2 Merge pull request #11 from iden3/feature/proof-parsers
Add proof parsers to string (decimal & hex)
2020-05-07 12:15:08 +02:00
arnaucube
0f48cfa2a5 Add proof parsers to string (decimal & hex)
Also adds ProofToSmartContractFormat, which returns a ProofString as the
proof.B elements swap is not a valid point for the bn256.G2 format.

Also unexports internal structs and methods of the prover package.
Also apply golint.
2020-05-06 14:45:44 +02:00
Eduard S
6ec118d4e2 Merge pull request #10 from iden3/feature/tables2
Add G1/G2 table calculation functionality
2020-05-06 11:43:06 +02:00
druiz0992
423d5f0ce7 Add G1/G2 table calculation functionality 2020-05-06 09:27:15 +02:00
arnaucube
a314ecc02f Add witness parser from binary file 2020-04-30 10:33:17 +02:00
arnaucube
700f2a4503 Fix prover benchmark file paths, update readme, and other small updates 2020-04-29 10:27:31 +02:00
arnau
02fc1ea6f7 Merge pull request #7 from iden3/feature/paralelism2
Implement more agressive parallelism
2020-04-28 20:14:06 +02:00
arnaucube
16054cc679 Remove inner prints 2020-04-28 20:09:16 +02:00
arnau
296dc53736 Merge pull request #6 from iden3/ed255-patch-1-1
Fix setting node version in gh workflow
2020-04-28 20:08:00 +02:00
Eduard S
8f09322e16 Implement more agressive parallelism 2020-04-28 18:21:54 +02:00
Eduard S
0977fac08c Fix setting node version in gh workflow 2020-04-28 15:15:19 +02:00
arnau
dc4ac0b350 Merge pull request #5 from iden3/feature/refactor-circuits
Feature/refactor circuits
2020-04-26 21:37:19 +02:00
arnaucube
d3f43ce1a0 Refactor circuits, update prover & verifier tests 2020-04-26 21:32:52 +02:00
arnaucube
5b77df54b7 Update proof sync.WaitGroup scooped variables & Add time prints in cli proof generation 2020-04-26 21:20:41 +02:00
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
arnau
569d16844d Merge pull request #4 from iden3/fix/verify
Fix mutation of inputs in Verify
2020-04-23 18:21:55 +02:00
Eduard S
40b280fc96 Fix mutation of inputs in Verify 2020-04-23 16:03:40 +02:00
arnaucube
bbcbba3113 Fix verifier inputs field check 2020-04-22 18:24:05 +02:00
arnaucube
37e5995f80 Fix verifier mod import path 2020-04-22 17:49:28 +02:00
arnaucube
6256fcc9db Update go mod & usage 2020-04-21 19:22:35 +02:00
arnau
e6fe08e699 Merge pull request #3 from iden3/feature/calculateH-mul
Use fft on calculateH polynomial multiplication
2020-04-21 15:45:38 +02:00
arnaucube
9b93bad028 Use fft on calculateH polynomial multiplication
For a circuit arround 22500 constraints:
- before: the proof was generated aprox in `80 seconds`
- now: the proof is generated aprox in `16 seconds`
2020-04-21 15:38:50 +02:00
arnau
fb3bbedde5 Merge pull request #2 from iden3/feature/polynomials-goff
Add polynomials arithmetic in goff
2020-04-20 12:51:04 +02:00
arnaucube
324c817d42 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
2020-04-20 12:49:00 +02:00
arnaucube
3f5f8e2318 Add CLI 2020-04-17 21:21:39 +02:00
arnaucube
e1147db72f refactor in sub packages 2020-04-17 20:31:53 +02:00
arnau
96b4b5b308 Merge pull request #1 from iden3/feature/gh-actions
Add Github Actions
2020-04-14 16:45:19 +02:00
arnaucube
8df45c7a91 Update compile-circuits.sh to adapt null from json, update GH Actions to install snarkjs & circom for testdata generation 2020-04-14 16:43:10 +02:00
arnau
c584fc1288 Create main.yml 2020-04-11 20:57:25 +02:00
arnaucube
a439651faf Add benchmarks, Rename repo, update README.md 2020-04-09 11:20:22 +02:00
arnaucube
0e453eb1ff Add Verifier Groth16 compatible with circom 2020-04-08 11:26:01 +02:00
arnaucube
2a18bbd5fe Add Verification Key & Proof parsers from json 2020-04-08 11:06:00 +02:00
arnaucube
7aa69a5b2c Add testdata big&small circuits, update proof parsers, add compile-circuits.sh 2020-04-06 15:03:59 +02:00
arnaucube
c03cb1af00 Add Proof to string in circom/snarkjs format 2020-04-06 11:54:21 +02:00
arnaucube
198eeee493 Fix use H polynomial 2020-04-06 11:52:55 +02:00
arnaucube
d5c971e59a Update exposed methods, update README.md, add godoc & goreport cards 2020-04-03 16:48:04 +02:00
arnaucube
89e71b617a Add README.md 2020-04-02 17:03:30 +02:00
arnaucube
001af791cc Proof generation works, add h pol calculation 2020-04-02 16:59:35 +02:00
arnaucube
f8481a66aa Add ifft 2020-04-01 23:21:16 +02:00
arnaucube
a99f4510da Add zkSNARK Groth16 prover 2020-03-29 23:54:28 +02:00