Skip to content

x86-64 Ed25519: order the comb's affine addition by its dependencies - #1351

Merged
alex merged 1 commit into
mainfrom
ed25519-comb-schedule
Oct 8, 2026
Merged

alex merged 1 commit into
mainfrom
ed25519-comb-schedule

Conversation

@alex

@alex alex commented Oct 8, 2026

Copy link
Copy Markdown
Member

The fixed-base comb's addition of a cached affine point (pointAddAffineOps) computed each sum or difference immediately before the multiplication that reads it, so a multiplication started while the addition's carry chain was still on its way to memory, and the independent multiplications were spread out.

This orders the operations by their dependencies instead — the three sums and differences, then the three multiplications of them, then the four sums and differences, then the four final multiplications. It is the same formula with the same operations, so the proof is unchanged: pointAddAffine_formula is still rfl on evalOps of the list, and no proof or contract moved.

Measurements

On a Sapphire Rapids Xeon restricted to VG_CPU_FEATURES=avx,avx2,bmi1,bmi2,adx (the _adx variants, as on a CPU without AVX512_IFMA), fastest of three interleaved runs of each side:

Benchmark Base Head Change
ed25519_keygen/32 10.60 µs 10.18 µs 3.9% faster
ed25519_sign/64 11.77 µs 11.37 µs 3.4% faster
x25519_generate/32 10.57 µs 10.22 µs 3.4% faster
x25519_public_key/32 10.18 µs 9.75 µs 4.1% faster

Ed25519 verification and the X25519 ladder, which do not use this addition, are unchanged (within noise).

Why

From the analysis of the rustls provider's handshake signing in #991: on a CPU without AVX512_IFMA, Ed25519 signing is the gap against aws-lc-rs (0.79 of its speed on a Cascade Lake–class Xeon), and nearly all of vg_ed25519_sign_cached_avx2_adx's time outside SHA-512 is the fixed-base multiplication, which performs this addition 52 times per signature. Measured against s2n-bignum's edwards25519_pepadd on the same machine, our addition was 117 ns against its 88 ns with the same seven field multiplications; the ordering is most of that difference.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RLVbycsRXKPfaW1swVZejG


Generated by Claude Code

The fixed-base comb's addition of a cached affine point computed each sum
or difference immediately before the multiplication that reads it, so a
multiplication started while the addition's carry chain was still on its
way to memory, and the independent multiplications were spread out.
Ordering the operations by their dependencies instead - the three sums and
differences, then the three multiplications of them, then the four sums and
differences, then the four final multiplications - is the same formula with
the same operations, so the proof is unchanged (`evalOps` of the list, by
`rfl`), and leaves nothing waiting.

On a Sapphire Rapids Xeon restricted to `avx,avx2,bmi1,bmi2,adx` (the
`_adx` variants, as on a CPU without AVX512_IFMA), of three interleaved
runs: Ed25519 key generation 3.9% faster, signing of 64 bytes 3.4%,
X25519 key generation 3.4% and its public keys 4.1%. Verification and the
X25519 ladder, which do not use this addition, are unchanged.

From the analysis of the rustls provider's handshake signing in #991:
without AVX512_IFMA, `vg_ed25519_sign_cached_avx2_adx` spends most of its
time in this addition, 52 times per signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLVbycsRXKPfaW1swVZejG
@alex
alex added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit e3fb870 Oct 8, 2026
39 checks passed
@alex
alex deleted the ed25519-comb-schedule branch October 8, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants