Skip to content

euonymos/bench-montgomery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A quick benchmark for Montgomery multiplication

This repository contains the code for benchmarking Montgomery and naive multiplication for elements of the scalar field for BLS12-381 curve.

As a use case we chose a widespread task of calculating coefficients of a polynomial being given its roots:

(x+2)(x+3)(x+5)(x+7)(x+11) = x^5 + 28 x^4 + 288 x^3 + 1358 x^2 + 2927 x + 2310

Montgomery multiplication is done by the blst library which is already used in Plutus.

Naive multiplication is done using num-bigint library.

To run bench yourself, try nix run .#defaultPackage.x86_64-linux (change to your system if needed).

Each benchmark was executed 1000 times on Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz. Values show average time and standard deviation.

Size Montgomery Avg Montgomery σ Naive Avg Naive σ Speedup
10 101.734 µs 22.565 µs 685.302 µs 159.436 µs 6.74x
15 138.966 µs 26.496 µs 953.121 µs 251.909 µs 6.86x
20 186.083 µs 21.703 µs 1.363 ms 189.064 µs 7.33x
25 241.934 µs 30.409 µs 2.096 ms 370.952 µs 8.67x
30 298.265 µs 33.504 µs 2.926 ms 401.267 µs 9.81x
31 310.631 µs 33.857 µs 3.108 ms 334.523 µs 10.00x
32 328.822 µs 45.218 µs 3.461 ms 521.307 µs 10.52x
35 355.684 µs 49.508 µs 4.142 ms 579.682 µs 11.65x
40 396.741 µs 63.206 µs 5.474 ms 749.828 µs 13.80x
45 472.785 µs 85.491 µs 7.602 ms 1.501 ms 16.08x
50 534.158 µs 119.238 µs 10.226 ms 3.898 ms 19.14x
100 1.090 ms 239.000 µs 35.546 ms 8.156 ms 32.61x
200 3.042173ms 483.892µs 141.871796ms 21.302688ms 46.64
300 6.040093ms 1.034338ms 319.940927ms 50.53683ms 52.97
400 8.951528ms 901.017µs 500.398941ms 49.487447ms 55.90
1000 49.006538ms 4.043325ms 3.044053658s 223.957115ms 62.12

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published