Skip to content

Conversation

@mratsim
Copy link
Owner

@mratsim mratsim commented Nov 27, 2024

The parallel MSM skips the top window if the number of bits is exactly divided by MSM parameter c.

This is easy to reproduce with 3 points and by removing the endomorphism acceleration (which multiply the number of points by 2x or 4x) here:

proc multiScalarMul_dispatch_vartime_parallel[bits: static int, F, G](
tp: Threadpool,
r: ptr (EC_ShortW_Jac[F, G] or EC_ShortW_Prj[F, G]),
coefs: ptr UncheckedArray[BigInt[bits]],
points: ptr UncheckedArray[EC_ShortW_Aff[F, G]], N: int) =
## Multiscalar multiplication:
## r <- [a₀]P₀ + [a₁]P₁ + ... + [aₙ]Pₙ
let c = bestBucketBitSize(N, bits, useSignedBuckets = true, useManualTuning = true)
# Given that bits and N change after applying an endomorphism,
# we are able to use a bigger `c`
# but it has no significant impact on performance
case c
of 2: withEndo(msmImpl_vartime_parallel, tp, r, coefs, points, N, c = 2)
of 3: withEndo(msmImpl_vartime_parallel, tp, r, coefs, points, N, c = 3)
of 4: withEndo(msmImpl_vartime_parallel, tp, r, coefs, points, N, c = 4)
of 5: withEndo(msmImpl_vartime_parallel, tp, r, coefs, points, N, c = 5)
of 6: withEndo(msmImpl_vartime_parallel, tp, r, coefs, points, N, c = 6)

This might help for #479, cc @Vindaar

@mratsim mratsim added bug 🪲 Something isn't working correctness 🛂 labels Nov 27, 2024
@mratsim
Copy link
Owner Author

mratsim commented Nov 27, 2024

failure go test on Windows

image

@mratsim
Copy link
Owner Author

mratsim commented Nov 28, 2024

image

@mratsim mratsim merged commit 68a6cbb into master Dec 3, 2024
18 checks passed
@mratsim mratsim deleted the msm-para-edge branch December 3, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Something isn't working correctness 🛂

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants