Skip to content

Commit

Permalink
more precise benchmarks & updated circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
feltroidprime committed Mar 3, 2024
1 parent f6bc5aa commit b9ea65a
Show file tree
Hide file tree
Showing 7 changed files with 1,964 additions and 1,900 deletions.
78 changes: 43 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,47 +73,55 @@ make run



| OP | Weight in steps |
|-----------|-------------------|
| MULMOD | 8 |
| ADDMOD | 4 |
| ASSERT_EQ | 2 |
| POSEIDON | 10 |


| circuit | MULMOD | ADDMOD | ASSERT_EQ | POSEIDON | ~steps |
|-------------------------------------------|----------|----------|-------------|------------|----------|
| Double Step BLS12_381 | 22 | 9 | 2 | 0 | 216 |
| Double Step BN254 | 24 | 11 | 2 | 0 | 240 |
| Double-and-Add Step BLS12_381 | 32 | 13 | 4 | 0 | 316 |
| Triple Step | 36 | 14 | 4 | 0 | 352 |
| Double-and-Add Step BN254 | 36 | 17 | 4 | 0 | 364 |
| Fp6 SQUARE_TORUS | 12 | 16 | 0 | 24 | 400 |
| Fp12 MUL | 36 | 22 | 0 | 24 | 616 |
| Mul L by L | 18 | 8 | 0 | 44 | 616 |
| Fp12 SQUARE | 25 | 11 | 0 | 48 | 724 |
| Mul by L | 28 | 15 | 0 | 48 | 764 |
| Fp6 MUL_TORUS | 36 | 34 | 0 | 36 | 784 |
| Mul LL by LL | 32 | 18 | 0 | 48 | 808 |
| Mul by LL | 34 | 20 | 0 | 48 | 832 |
| Mul LL by L | 26 | 13 | 0 | 72 | 980 |
| Miller n=1 BLS12_381 | 4934 | 3995 | 137 | 3158 | 87306 |
| Final Exp BN254 | 4686 | 6059 | 3 | 3858 | 100310 |
| Miller n=1 BN254 | 5982 | 4801 | 177 | 3618 | 103594 |
| Final Exp BLS12_381 | 5128 | 7117 | 3 | 4662 | 116118 |
| Miller n=2 BLS12_381 | 8026 | 6235 | 273 | 4550 | 135194 |
| Miller n=2 BN254 | 10128 | 7855 | 353 | 5478 | 167930 |
| Miller n=3 BLS12_381 | 11350 | 8707 | 409 | 6174 | 188186 |
| BLS12FinalExp Fp12 Karabina No EXTF Trick | 7774 | 43002 | 0 | 0 | 234200 |
| Miller n=3 BN254 | 14450 | 11085 | 529 | 7514 | 236138 |
| OP | Weight in steps |
|--------------------|-------------------|
| MULMOD | 8 |
| ADDMOD | 4 |
| ASSERT_EQ | 2 |
| RLC | 28 |
| POSEIDON BN254 | 15 |
| POSEIDON BLS12_381 | 19 |


| circuit | MULMOD | ADDMOD | ASSERT_EQ | POSEIDON | RLC | ~steps |
|-------------------------------------------|----------|----------|-------------|------------|-------|----------|
| Double Step BLS12_381 | 22 | 9 | 2 | 0 | 0 | 216 |
| Double Step BN254 | 24 | 11 | 2 | 0 | 0 | 240 |
| Fp6 SQUARE_TORUS | 12 | 16 | 0 | 7 | 1 | 307 |
| Double-and-Add Step BLS12_381 | 32 | 13 | 4 | 0 | 0 | 316 |
| Triple Step | 36 | 14 | 4 | 0 | 0 | 352 |
| Double-and-Add Step BN254 | 36 | 17 | 4 | 0 | 0 | 364 |
| Mul L by L | 18 | 8 | 0 | 11 | 1 | 391 |
| Fp12 SQUARE | 25 | 11 | 0 | 13 | 1 | 493 |
| Mul LL by L | 26 | 13 | 0 | 13 | 1 | 509 |
| Mul by L | 28 | 15 | 0 | 13 | 1 | 533 |
| Mul LL by LL | 32 | 18 | 0 | 13 | 1 | 577 |
| Mul by LL | 34 | 20 | 0 | 13 | 1 | 601 |
| Fp12 MUL | 36 | 22 | 0 | 13 | 1 | 625 |
| Fp6 MUL_TORUS | 36 | 34 | 0 | 13 | 2 | 701 |
| Miller n=1 BLS12_381 | 4934 | 3995 | 137 | 1580 | 131 | 89414 |
| Miller n=1 BN254 | 5982 | 4801 | 177 | 1810 | 153 | 98848 |
| Final Exp BN254 | 4686 | 6059 | 3 | 1931 | 317 | 99571 |
| Final Exp BLS12_381 | 5128 | 7117 | 3 | 2333 | 384 | 124577 |
| Miller n=2 BLS12_381 | 8026 | 6235 | 273 | 2276 | 199 | 138510 |
| Miller n=2 BN254 | 10128 | 7855 | 353 | 2740 | 241 | 160998 |
| Miller n=3 BLS12_381 | 11350 | 8707 | 409 | 3088 | 267 | 192594 |
| MultiPairing n=1 BN254 | 10668 | 10860 | 180 | 3741 | 470 | 198419 |
| MultiPairing n=1 BLS12_381 | 10062 | 11112 | 140 | 3913 | 515 | 213991 |
| Miller n=3 BN254 | 14450 | 11085 | 529 | 3758 | 329 | 226580 |
| BLS12FinalExp Fp12 Karabina No EXTF Trick | 7774 | 43002 | 0 | 0 | 0 | 234200 |
| MultiPairing n=2 BN254 | 14814 | 13914 | 356 | 4671 | 558 | 260569 |
| MultiPairing n=2 BLS12_381 | 13154 | 13352 | 276 | 4609 | 583 | 263087 |
| MultiPairing n=3 BLS12_381 | 16478 | 15824 | 412 | 5421 | 651 | 317171 |
| MultiPairing n=3 BN254 | 19136 | 17144 | 532 | 5689 | 646 | 326151 |


| | Final Exp BN254 | Final Exp BLS12_381 | Miller n=1 BLS12_381 | Miller n=1 BN254 | Miller n=2 BLS12_381 | Miller n=2 BN254 | Miller n=3 BLS12_381 | Miller n=3 BN254 |
|---------------------|-------------------|-----------------------|------------------------|--------------------|------------------------|--------------------|------------------------|--------------------|
| SQUARE_TORUS | 189 | 315 | 0 | 0 | 0 | 0 | 0 | 0 |
| EXTF_SQUARE | 0 | 0 | 63 | 65 | 63 | 65 | 63 | 65 |
| MUL_TORUS | 62 | 33 | 0 | 0 | 0 | 0 | 0 | 0 |
| EXTF_SQUARE | 0 | 0 | 63 | 65 | 63 | 65 | 63 | 65 |
| EXTF_MUL_DENSE | 62 | 33 | 0 | 0 | 5 | 22 | 63 | 66 |
| SQUARE_TORUS | 189 | 315 | 0 | 0 | 0 | 0 | 0 | 0 |
| Double Step | 0 | 0 | 58 | 44 | 116 | 88 | 174 | 132 |
| Double-and-Add Step | 0 | 0 | 4 | 21 | 8 | 42 | 12 | 63 |
| Triple Step | 0 | 0 | 1 | 0 | 2 | 0 | 3 | 0 |
Expand Down
8 changes: 7 additions & 1 deletion src/extension_field_modulo_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,13 @@ def summarize(self):
"MULMOD": mul_count,
"ADDMOD": add_count,
"ASSERT_EQ": assert_eq_count,
"POSEIDON": self.transcript.permutations_count,
"POSEIDON": (
self.transcript.permutations_count
if self.transcript.permutations_count > 1
else 0
),
"RLC": self.accumulate_poly_instructions[0].n
+ self.accumulate_poly_instructions[1].n,
}

return summary
Expand Down
4 changes: 2 additions & 2 deletions src/precompiled_circuits/extf_mul.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func get_BN254_FP12_MUL_circuit() -> (circuit: ExtensionFieldModuloCircuit*) {
dw 116;
poseidon_indexes_ptr_loc:
dw 430;
dw 220;
}

func get_BLS12_381_FP12_MUL_circuit() -> (circuit: ExtensionFieldModuloCircuit*) {
Expand Down Expand Up @@ -881,5 +881,5 @@ func get_BLS12_381_FP12_MUL_circuit() -> (circuit: ExtensionFieldModuloCircuit*)
dw 116;
poseidon_indexes_ptr_loc:
dw 430;
dw 220;
}
Loading

0 comments on commit b9ea65a

Please sign in to comment.