Add asm field kernels for X25519/Ed25519 - #171
Merged
Merged
Conversation
Replace the Pascal radix-2^25.5 field arithmetic in the shared TX25519Field
(serves X25519, Ed25519, and the Ed25519 signer) with asm kernels: Mul, Sqr,
Add, Sub, Apm, CSwap, Carry and mul-by-word, on x86-64, i386 and aarch64.
Kernels are reached through a facade/backend (ClpCurveFieldSimd + ClpCurveField
{X86,Arm}Backend) mirroring the existing FpKernel wiring; the Pascal path stays
as the CRYPTOLIB_FORCE_SCALAR / unsupported-arch fallback.
Signed product-scanning schoolbook (imul/smull only) with the 2^255-19
reduction folded on the fly and one Int64 accumulator per column (proven
< 2^63). i386 squares via X*X with an in-place carry; aarch64 keeps the ten
columns register-resident.
Measured, same-thermal FORCE_SCALAR A/B: x86-64 X25519 scalar-mult 1.54x
(Mul 1.33x, Sqr 1.50x, Apm 2.44x, CSwap 1.82x); i386 small ops 1.2-1.9x.
Set the package optimization back to -O1: with the hot field paths now in asm,
curve performance no longer depends on the global opt level, so -O1 is used for
safe ARM7 codegen without regressing the curves.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace the Pascal radix-2^25.5 field arithmetic in the shared TX25519Field (serves X25519, Ed25519, and the Ed25519 signer) with asm kernels: Mul, Sqr, Add, Sub, Apm, CSwap, Carry and mul-by-word, on x86-64, i386 and aarch64.
Kernels are reached through a facade/backend (ClpCurveFieldSimd + ClpCurveField {X86,Arm}Backend) mirroring the existing FpKernel wiring; the Pascal path stays as the CRYPTOLIB_FORCE_SCALAR / unsupported-arch fallback.
Signed product-scanning schoolbook (imul/smull only) with the 2^255-19 reduction folded on the fly and one Int64 accumulator per column (proven < 2^63). i386 squares via X*X with an in-place carry; aarch64 keeps the ten columns register-resident.
Measured, same-thermal FORCE_SCALAR A/B: x86-64 X25519 scalar-mult 1.54x (Mul 1.33x, Sqr 1.50x, Apm 2.44x, CSwap 1.82x); i386 small ops 1.2-1.9x.
Set the package optimization back to -O1: with the hot field paths now in asm, curve performance no longer depends on the global opt level, so -O1 is used for safe ARM7 codegen without regressing the curves.