Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐”พโ‚œ multi-exponentiations #436

Merged
merged 5 commits into from
Jul 19, 2024
Merged

๐”พโ‚œ multi-exponentiations #436

merged 5 commits into from
Jul 19, 2024

Conversation

mratsim
Copy link
Owner

@mratsim mratsim commented Jul 18, 2024

This adds serial and parallel endomorphism accelerated ๐”พโ‚œ multi-exponentiations to provide a baseline for them before optimizations.

This is motivated by research in Ethereum SSLE (Secret Shared Leader Election), a technique to keep private who the next Ethereum block producer will be.

  • This avoids people DOS-ing the next block producer
  • There are way too many deanonymizing attacks and metadata analysis possible to only rely on the P2P layer for anonymization.

Benchmarks

The machine is a low power (15W~30W) Ryzen 7840U.

Serial ๐”พโ‚œ multi-exp vs ๐”พโ‚ MSM

image

There is a 3x ratio between single exponentiation and single scalar mul.
But it becomes 5x with multiexp / MSM.

This can be explained because with many points, you can use affine coordinates and Montgomery batch inversion to switch from a cost of ~12Mul (Jacobian coordinate) to an asymptotic cost of ~6M (affine coordinates)

Parallel

image

Application

A size 128 ๐”พโ‚œ multi-exp is 8ms when serial or for 256 ~ 15ms, parallelization only does a 4x speedup with 8 cores / 16 threads.

cc @asanso

@mratsim mratsim added the enhancement :shipit: New feature or request label Jul 18, 2024
@mratsim
Copy link
Owner Author

mratsim commented Jul 18, 2024

Upstream compilation regression here on this bench

type BenchMultiexpContext*[GT] = object
tp: Threadpool
numInputs: int
elems: seq[GT]
exponents: seq[getBigInt(GT.Name, kScalarField)]

nim-lang/Nim#23853

@mratsim mratsim merged commit 9268502 into master Jul 19, 2024
24 checks passed
@mratsim mratsim deleted the gt-multiexp branch July 19, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement :shipit: New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant