cryptimeleon / mclwrap

A wrapper to bring the mcl pairing library into cryptimeleon
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Turbocharge mcl performance: Write our own mcl wrapper in C++ #32

Open JanBobolz opened 2 years ago

JanBobolz commented 2 years ago

We've recently benchmarked computation of 10k random Pedersen commitments with mclwrap vs directly in C++. The former took 3 times as long as the latter. Profiling the Java code, it seems like one big issue is garbage collection (around 50% of CPU time seems to have gone there), as well as some BigInteger copy overhead for computation of wnaf forms.

Idea

So the idea is: let's write an mcl wrapper in C++, such that mclwrap (java) calls mclwrap (C++) calls mcl (C++, statically linked, no overhead). This would mean that we completely stop using mcl's ffi code. Our wrapper should:

Benefits:

Necessary additions to math:

When developing this, maybe start a new project with a generic C++ wrapper (containing, for example, the wnaf computation code) and just instantiate that here.