Perf: specialize the multiplication by D in twistededward packages #445
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR was motivated by #442 and #441. Twisted Edwards curves are not as optimized as Weierstrass ones in gnark-crypto, since the formers are only used for tests in gnark. Anyway, this PR is an example to push the performance a bit further.
Multiplication by the constant
D
is used is several places:X
coordinate retrievalThis PR specialize this multiplication for baby-Jubjub, Jubjub and Bandersnatch twisted Edwards curves. The same can be done for other curves but only these are actually used in projects (maybe BLS12-377 companion curve too e.g. Aleo, Penumbra?).
Type of change
How has this been tested?
This PR doesn’t change the logic or add new border cases, so existing tests cover correct behavior.
How has this been benchmarked?
Fr
: 5 doublings and 81 additions;Fr
: 6 doublings and 79 additions;Fr
: 6 doublings and 78 additions.