koute / polkavm

A fast and secure RISC-V based virtual machine
Apache License 2.0
234 stars 47 forks source link

bench-curve25519-dalek #68

Open burdges opened 9 months ago

burdges commented 9 months ago

We should've some well optimized cryptographic code in the benchmarks.

As symmetric, I'd think blake2s hashing some pre-prepared random data.

As asymmetric, it's simplest to do curve25519-dalek I think. I suppose criterion does not fit VM benchmarks so well, so doing cargo bench maybe annoying. A simpler useful benchmark would be a variable base multi-scalar multiplication. In other words, invoke <EdwardsPoint as VartimeMultiscalarMul>::vartime_multiscalar_mul on some pre-prepared random points and scalars. We could do single scalar multiplications instead, but an MSM maybe gives a more meaningful comparison, thanks to being heavier.

Arkworks curve sound relevant of course, but one thing at a time. As curve25519-dalek is single threaded on all platforms, it's slightly easier to get honest benchmarks, and tells largely the same story. It's possible curve25519-dalek still needs backend features for some VMs, but likely still simpler than similar in arkworks.