Skip to content

Add per-arch ADX X25519 scalar-mult kernels and generate the fe51 tier - #182

Merged
Xor-el merged 2 commits into
masterfrom
feature/x25519-scalarmult-perf
Aug 23, 2026
Merged

Add per-arch ADX X25519 scalar-mult kernels and generate the fe51 tier#182
Xor-el merged 2 commits into
masterfrom
feature/x25519-scalarmult-perf

Conversation

@Xor-el

@Xor-el Xor-el commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Optimise X25519 scalar multiplication with new per-arch field kernels, selected once per scalar-mult through the CurveField facade/backend and folded into the ClpX25519 driver behind a single tier-dispatch point.

Kernels (all generator-emitted, oracle- and differential-validated):

  • x86-64: radix-2^64 (saturated, 4-limb) fused Montgomery ladder step using MULX + dual ADCX/ADOX, db-encoded, gated on BMI2+ADX. ~3.16x over the prior scalar path (~0.82x of OpenSSL on Kaby Lake).
  • aarch64: radix-2^64 comba fused ladder step (mul/umulh + adds/adcs, plain mnemonics), gated on AArch64 asm availability; qemu-validated.
  • i386: radix-2^32 (saturated, 8-limb) Comba kernel using 32-bit MULX, emitted by a distinct no-REX 32-bit encoder. 1.37x over the plain-mul fallback (native-measured, ship-gated); plain-mul kept as the pre-ADX fallback.

fe51 tier: bring the previously hand-written x86-64 and aarch64 fe51 (radix-2^51) mul/sqr kernels under the generator, retiring them with byte-identical machine code (i386 fe51 was already generated).

Rename the mislabelled Fe64 includes and selectors to their true representation: X25519 -> Fe51 (radix-2^51), X448 -> Fe56 (radix-2^56). The genuine radix-2^64 / radix-2^32 kernels are the SAT64* / ADX32* families.

Xor-el added 2 commits August 24, 2026 00:05
Optimise X25519 scalar multiplication with new per-arch field kernels,
selected once per scalar-mult through the CurveField facade/backend and
folded into the ClpX25519 driver behind a single tier-dispatch point.

Kernels (all generator-emitted, oracle- and differential-validated):
- x86-64: radix-2^64 (saturated, 4-limb) fused Montgomery ladder step
  using MULX + dual ADCX/ADOX, db-encoded, gated on BMI2+ADX. ~3.16x over
  the prior scalar path (~0.82x of OpenSSL on Kaby Lake).
- aarch64: radix-2^64 comba fused ladder step (mul/umulh + adds/adcs,
  plain mnemonics), gated on AArch64 asm availability; qemu-validated.
- i386: radix-2^32 (saturated, 8-limb) Comba kernel using 32-bit MULX,
  emitted by a distinct no-REX 32-bit encoder. 1.37x over the plain-mul
  fallback (native-measured, ship-gated); plain-mul kept as the pre-ADX
  fallback.

fe51 tier: bring the previously hand-written x86-64 and aarch64 fe51
(radix-2^51) mul/sqr kernels under the generator, retiring them with
byte-identical machine code (i386 fe51 was already generated).

Rename the mislabelled *_Fe64_* includes and selectors to their true
representation: X25519 -> _Fe51_ (radix-2^51), X448 -> _Fe56_
(radix-2^56). The genuine radix-2^64 / radix-2^32 kernels are the
SAT64* / ADX32* families.
@Xor-el
Xor-el merged commit 3287e6e into master Aug 23, 2026
28 checks passed
@Xor-el
Xor-el deleted the feature/x25519-scalarmult-perf branch August 23, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant