Skip to content
This repository was archived by the owner on Jul 14, 2023. It is now read-only.
Closed
Prev Previous commit
Next Next commit
Update 0000-arkworks-integration.md
  • Loading branch information
Achim Schneider authored May 4, 2023
commit 9fa947e3aa0d1b7a4cfd12d009117a46fec448b0
87 changes: 43 additions & 44 deletions proposals/0000-arkworks-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,55 +108,54 @@ Example implementations and benchmarks for the code can be found under: https://
### Benchmarking results
The following comparison table of benchmarking results should justify the introduction of the new host functions:

| extrinsic | arkworks(µs)[^1] |ark-substrate(µs)[^2]| speedup[^3] | dummy(µs)[^4] | wasm(µs)[^5] | native(µs)[^6] |
| --------------------------------------- | --------------- | --------------- | --------------- | --------------- | --------------- | --------------- |
| groth16_verification (bls12_381) | 23551.78 | 3548.19 |${\color{green}\bf 6.64 \boldsymbol{\times}}$| 5800.99 | | 3491.30 |
| bls12_381_pairing | 10402.36 | 1590.62 |${\color{green}\bf 6.54 \boldsymbol{\times}}$| 448.97 | | 1340 |
| bls12_381_msm_g1, 10 arguments | 7970.50 | 1122.22 |${\color{green}\bf 7.10 \boldsymbol{\times}}$| 87.63 | | 578.19 |
| bls12_381_msm_g1, 1000 arguments | 229069.53 | 35833.72 |${\color{green}\bf 6.39 \boldsymbol{\times}}$| 6486.63 | | 11010 |
| bls12_381_msm_g2, 10 arguments | 24854.55 | 3284.34 |${\color{green}\bf 7.57 \boldsymbol{\times}}$| 10738.18 | | 1630 |
| bls12_381_msm_g2, 1000 arguments | 716298.98 | 101603.89 |${\color{green}\bf 7.05 \boldsymbol{\times}}$| 9896.67 | | 32530 |
| bls12_381_mul_projective_g1 | 505.58 | 104.31 |${\color{green}\bf 4.85 \boldsymbol{\times}}$| 12.13 | | 48.27 |
| bls12_381_mul_affine_g1 | 439.51 | 89.42 |${\color{green}\bf 4.92 \boldsymbol{\times}}$| 9.74 | | 41.25 |
| bls12_381_mul_projective_g2 | 1498.49 | 231.95 |${\color{green}\bf 6.46 \boldsymbol{\times}}$| 18.22 | | 152.62 |
| bls12_381_mul_affine_g2 | 1255.50 | 201.16 |${\color{green}\bf 6.24 \boldsymbol{\times}}$| 16.41 | | 130.11 |
| bls12_377_pairing | 8998.99 | 1594.38 |${\color{green}\bf 5.64 \boldsymbol{\times}}$| 16.64 | | 1560 |
| bls12_377_msm_g1, 10 arguments | 6710.72 | 950.38 |${\color{green}\bf 7.06 \boldsymbol{\times}}$| 51.48 | | 516.45 |
| bls12_377_msm_g1, 1000 arguments | 196176.16 | 30106.65 |${\color{green}\bf 6.52 \boldsymbol{\times}}$| 4484.67 | | 11200 |
| bls12_377_msm_g2, 10 arguments | 22969.00 | 3503.74 |${\color{green}\bf 6.56 \boldsymbol{\times}}$| 89.93 | | 1970 |
| bls12_377_msm_g2, 1000 arguments | 698696.46 | 118429.47 |${\color{green}\bf 5.90 \boldsymbol{\times}}$| 7948.46 | | 38570 |
| bls12_377_mul_projective_g1 | 504.24 | 89.33 |${\color{green}\bf 5.64 \boldsymbol{\times}}$| 11.42 | | 49.48 |
| bls12_377_mul_affine_g1 | 419.75 | 80.46 |${\color{green}\bf 5.22 \boldsymbol{\times}}$| 11.11 | | 43.05 |
| bls12_377_mul_projective_g2 | 1539.78 | 270.16 |${\color{green}\bf 5.70 \boldsymbol{\times}}$| 16.64 | | 186.37 |
| bls12_377_mul_affine_g2 | 1290.96 | 234.93 |${\color{green}\bf 5.50 \boldsymbol{\times}}$| 17.18 | | 161.32 |
| bw6_761_pairing | 52506.13 | 6905.97 |${\color{green}\bf 7.60 \boldsymbol{\times}}$| 844.10 | | 5940 |
| bw6_761_msm_g1, 10 arguments | 47190.40 | 5653.72 |${\color{green}\bf 8.35 \boldsymbol{\times}}$| 161.28 | | 2790 |
| bw6_761_msm_g1, 1000 arguments | 1342834.87 | 168826.52 |${\color{green}\bf 7.95 \boldsymbol{\times}}$| 13526.84 | | 57820 |
| bw6_761_msm_g2, 10 arguments | 47136.15 | 5686.05 |${\color{green}\bf 8.29 \boldsymbol{\times}}$| 161.92 | | 2790 |
| bw6_761_msm_g2, 1000 arguments | 1344407.42 | 168580.08 |${\color{green}\bf 7.97 \boldsymbol{\times}}$| 13633.30 | | 57820 |
| bw6_761_mul_projective_g1 | 1927.85 | 305.39 |${\color{green}\bf 6.31 \boldsymbol{\times}}$| 21.99 | | 192.79 |
| bw6_761_mul_affine_g1 | 1598.12 | 265.21 |${\color{green}\bf 6.03 \boldsymbol{\times}}$| 21.35 | | 160.41 |
| bw6_761_mul_projective_g2 | 1919.98 | 308.60 |${\color{green}\bf 6.22 \boldsymbol{\times}}$| 21.64 | | 187.83 |
| bw6_761_mul_affine_g2 | 1599.12 | 270.36 |${\color{green}\bf 5.91 \boldsymbol{\times}}$| 21.57 | | 159.88 |
| ed_on_bls12_381_msm_sw, 10 arguments | 4139.53 | 678.09 |${\color{green}\bf 6.10 \boldsymbol{\times}}$| 36.30 | | 461.70 |
| ed_on_bls12_381_msm_sw, 1000 arguments | 108774.04 | 20241.58 |${\color{green}\bf 5.37 \boldsymbol{\times}}$| 2465.60 | | 7480 |
| ed_on_bls12_381_mul_projective_sw | 269.16 | 53.42 |${\color{green}\bf 5.04 \boldsymbol{\times}}$| 6.69 | | 28.77 |
| ed_on_bls12_381_mul_affine_sw | 234.34 | 49.17 |${\color{green}\bf 4.77 \boldsymbol{\times}}$| 6.17 | | 25.47 |
| ed_on_bls12_381_msm_te, 10 arguments | 6124.97 | 891.09 |${\color{green}\bf 6.87 \boldsymbol{\times}}$| 35.21 | | 529.61 |
| ed_on_bls12_381_msm_te, 1000 arguments | 122059.27 | 20473.18 |${\color{green}\bf 5.96 \boldsymbol{\times}}$| 2391.21 | | 7450 |
| ed_on_bls12_381_mul_projective_te | 217.60 | 45.47 |${\color{green}\bf 4.79 \boldsymbol{\times}}$| 7.69 | | 24.62 |
| ed_on_bls12_381_mul_affine_te | 224.69 | 47.91 |${\color{green}\bf 4.69 \boldsymbol{\times}}$| 7.61 | | 25.71 |
| ed_on_bls12_377_msm, 10 arguments | 6101.68 | 857.74 |${\color{green}\bf 7.11 \boldsymbol{\times}}$| 43.24 | | 421.93 |
| ed_on_bls12_377_msm, 1000 arguments | 124114.05 | 20309.37 |${\color{green}\bf 6.11 \boldsymbol{\times}}$| 2465.60 | | 5790 |
| ed_on_bls12_377_mul_projective | 216.51 | 45.31 |${\color{green}\bf 4.78 \boldsymbol{\times}}$| 7.00 | | 20.37 |
| ed_on_bls12_377_mul_affine | 213.23 | 43.56 |${\color{green}\bf 4.90 \boldsymbol{\times}}$| 8.47 | | 20.92 |
| extrinsic | arkworkrs(µs)[^1] |ark-substrate(µs)[^2]| speedup[^3] | dummy(µs)[^4] | native(µs)[^5] |
| --------------------------------------- | --------------- | --------------- | --------------- | --------------- | --------------- |
| groth16_verification (bls12_381) | 23335.84 | 3569.35 |${\color{green}\bf 6.54 \boldsymbol{\times}}$| 190.80 | 3440 |
| bls12_381_pairing | 9092.61 | 1390.80 |${\color{green}\bf 6.54 \boldsymbol{\times}}$| 24.64 | 1270 |
| bls12_381_msm_g1, 10 arguments | 6921.99 | 949.58 |${\color{green}\bf 7.29 \boldsymbol{\times}}$| 50.07 | 568.89 |
| bls12_381_msm_g1, 1000 arguments | 194969.80 | 30158.23 |${\color{green}\bf 6.46 \boldsymbol{\times}}$| 2169.47 | 10750 |
| bls12_381_msm_g2, 10 arguments | 21513.87 | 2870.33 |${\color{green}\bf 7.57 \boldsymbol{\times}}$| 50.06 | 1600 |
| bls12_381_msm_g2, 1000 arguments | 621769.22 | 100801.74 |${\color{green}\bf 7.50 \boldsymbol{\times}}$| 3640.63 | 31900 |
| bls12_381_mul_projective_g1 | 486.34 | 75.01 |${\color{green}\bf 6.48 \boldsymbol{\times}}$| 11.94 | 45.59 |
| bls12_381_mul_affine_g1 | 420.01 | 79.26 |${\color{green}\bf 5.30 \boldsymbol{\times}}$| 11.11 | 38.74 |
| bls12_381_mul_projective_g2 | 1498.84 | 210.50 |${\color{green}\bf 7.12 \boldsymbol{\times}}$| 14.63 | 146.93 |
| bls12_381_mul_affine_g2 | 1234.92 | 214.00 |${\color{green}\bf 5.77 \boldsymbol{\times}}$| 13.17 | 123.68 |
| bls12_377_pairing | 8904.20 | 1449.52 |${\color{green}\bf 6.14 \boldsymbol{\times}}$| 25.88 | 1470 |
| bls12_377_msm_g1, 10 arguments | 6592.47 | 902.50 |${\color{green}\bf 7.30 \boldsymbol{\times}}$| 29.20 | 582.19 |
| bls12_377_msm_g1, 1000 arguments | 191793.87 | 28828.95 |${\color{green}\bf 6.65 \boldsymbol{\times}}$| 1307.62 | 11000 |
| bls12_377_msm_g2, 10 arguments | 22509.51 | 3251.84 |${\color{green}\bf 6.92 \boldsymbol{\times}}$| 35.06 | 1860 |
| bls12_377_msm_g2, 1000 arguments | 632339.00 | 94521.78 |${\color{green}\bf 6.69 \boldsymbol{\times}}$| 2556.48 | 36020 |
| bls12_377_mul_projective_g1 | 424.21 | 65.68 |${\color{green}\bf 6.46 \boldsymbol{\times}}$| 11.76 | 46.54 |
| bls12_377_mul_affine_g1 | 363.85 | 65.68 |${\color{green}\bf 5.54 \boldsymbol{\times}}$| 10.50 | 39.81 |
| bls12_377_mul_projective_g2 | 1339.39 | 212.20 |${\color{green}\bf 6.31 \boldsymbol{\times}}$| 14.56 | 167.91 |
| bls12_377_mul_affine_g2 | 1122.08 | 208.74 |${\color{green}\bf 5.38 \boldsymbol{\times}}$| 13.08 | 141.49 |
| bw6_761_pairing | 52065.18 | 6791.27 |${\color{green}\bf 7.67 \boldsymbol{\times}}$| 34.70 | 6780 |
| bw6_761_msm_g1, 10 arguments | 47050.21 | 5559.53 |${\color{green}\bf 8.46 \boldsymbol{\times}}$| 67.79 | 2760 |
| bw6_761_msm_g1, 1000 arguments | 1167536.06 | 143517.21 |${\color{green}\bf 8.14 \boldsymbol{\times}}$| 4630.95 | 56680 |
| bw6_761_msm_g2, 10 arguments | 41055.89 | 4874.46 |${\color{green}\bf 8.42 \boldsymbol{\times}}$| 58.37 | 2960 |
| bw6_761_msm_g2, 1000 arguments | 1209593.25 | 143437.77 |${\color{green}\bf 8.43 \boldsymbol{\times}}$| 4345.36 | 74550 |
| bw6_761_mul_projective_g1 | 1678.86 | 223.57 |${\color{green}\bf 7.51 \boldsymbol{\times}}$| 27.54 | 221.73 |
| bw6_761_mul_affine_g1 | 1387.87 | 222.05 |${\color{green}\bf 6.25 \boldsymbol{\times}}$| 27.55 | 183.16 |
| bw6_761_mul_projective_g2 | 1919.98 | 308.60 |${\color{green}\bf 6.22 \boldsymbol{\times}}$| 26.99 | 221.75 |
| bw6_761_mul_affine_g2 | 1388.21 | 222.47 |${\color{green}\bf 6.24 \boldsymbol{\times}}$| 21.90 | 184.79 |
| ed_on_bls12_381_bandersnatch_msm_sw, 10 arguments | 3616.81 | 557.96 |${\color{green}\bf 6.48 \boldsymbol{\times}}$| 21.43 | 457.93 |
| ed_on_bls12_381_bandersnatch_msm_sw, 1000 arguments | 94473.54 | 16254.32 |${\color{green}\bf 5.81 \boldsymbol{\times}}$| 982.29 | 7460 |
| ed_on_bls12_381_bandersnatch_mul_projective_sw | 235.38 | 40.70 |${\color{green}\bf 5.78 \boldsymbol{\times}}$| 9.03 | 33.12 |
| ed_on_bls12_381_bandersnatch_mul_affine_sw | 204.04 | 41.66 |${\color{green}\bf 4.90 \boldsymbol{\times}}$| 8.78 | 29.50 |
| ed_on_bls12_381_bandersnatch_msm_te, 10 arguments | 5427.77 | 744.74 |${\color{green}\bf 7.29 \boldsymbol{\times}}$| 24.05 | 538.16 |
| ed_on_bls12_381_bandersnatch_msm_te, 1000 arguments | 106610.20 | 16690.71 |${\color{green}\bf 6.39 \boldsymbol{\times}}$| 1195.35 | 7460 |
| ed_on_bls12_381_bandersnatch_mul_projective_te | 183.29 | 34.63 |${\color{green}\bf 5.29 \boldsymbol{\times}}$| 9.55 | 24.83 |
| ed_on_bls12_381_bandersnatch_mul_affine_te | 181.84 | 33.99 |${\color{green}\bf 5.35 \boldsymbol{\times}}$| 9.50 | 29.47 |
| ed_on_bls12_377_msm, 10 arguments | 5304.03 | 700.51 |${\color{green}\bf 7.57 \boldsymbol{\times}}$| 24.02 | 523.27 |
| ed_on_bls12_377_msm, 1000 arguments | 105563.53 | 15757.62 |${\color{green}\bf 6.70 \boldsymbol{\times}}$| 1200.45 | 7370 |
| ed_on_bls12_377_mul_projective | 179.54 | 32.72 |${\color{green}\bf 5.49 \boldsymbol{\times}}$| 9.72 | 24.07 |
| ed_on_bls12_377_mul_affine | 177.53 | 33.24 |${\color{green}\bf 5.34 \boldsymbol{\times}}$| 9.76 | 23.90 |

[^1]: implemented in a Substrate pallet with [arkworks](https://github.com/arkworks-rs/) library by this repo: https://github.com/achimcc/substrate-arkworks-examples
[^2]: implemented in a Substrate pallet with [ark-substrate](https://github.com/paritytech/ark-substrate) library, executed through host-function call, computed by this repo: https://github.com/achimcc/substrate-arkworks-examples
[^3]: speedup by using ark-substrate and host calls, compared to native speed
[^4]: These extrinsics just receive the arguemnts, deserialize them without using them and then take a generator or zero element of the expected return group, serizlize it and return it. **Calling a host call through a extrinsic which does nothing has been benchmarked with 3.98µs**. Implementation in: https://github.com/achimcc/substrate-arkworks-examples/tree/dummy-calls
[^5]: executed through wasmtime by this repo: [https://github.com/achimcc/native-bench-arkworks](https://github.com/achimcc/wasm-bench-arkworks)
[^6]: native execution, computed by this repo: https://github.com/achimcc/native-bench-arkworks
[^5]: native execution, computed by this repo: https://github.com/achimcc/native-bench-arkworks


## Security considerations
Expand Down