/ benchmarks / bench_ec_g1_msm_bn254_snarks.nim
bench_ec_g1_msm_bn254_snarks.nim
1 # Constantine 2 # Copyright (c) 2018-2019 Status Research & Development GmbH 3 # Copyright (c) 2020-Present Mamy André-Ratsimbazafy 4 # Licensed and distributed under either of 5 # * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). 6 # * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). 7 # at your option. This file may not be copied, modified, or distributed except according to those terms. 8 9 import 10 # Internals 11 ../constantine/math/config/curves, 12 ../constantine/math/arithmetic, 13 ../constantine/math/elliptic/[ 14 ec_shortweierstrass_projective, 15 ec_shortweierstrass_jacobian], 16 # Helpers 17 ../helpers/prng_unsafe, 18 ./bench_elliptic_parallel_template 19 20 # ############################################################ 21 # 22 # Benchmark of the G1 group of 23 # Short Weierstrass elliptic curves 24 # in (homogeneous) projective coordinates 25 # 26 # ############################################################ 27 28 29 const Iters = 10_000 30 const AvailableCurves = [ 31 BN254_Snarks, 32 ] 33 34 # const testNumPoints = [10, 100, 1000, 10000, 100000] 35 # const testNumPoints = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072] 36 const testNumPoints = [1 shl 16, 1 shl 22] 37 38 proc main() = 39 separator() 40 staticFor i, 0, AvailableCurves.len: 41 const curve = AvailableCurves[i] 42 separator() 43 for numPoints in testNumPoints: 44 let batchIters = max(1, Iters div numPoints) 45 msmParallelBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, batchIters) 46 separator() 47 separator() 48 49 main() 50 notes()