Skip to content

brainpoolP384r1 x86-64: sign by the fixed-base comb for any a - #4425

Merged
alex merged 3 commits into
mainfrom
claude/perf-4141-brainpool-ecdsa
Nov 7, 2026
Merged

alex merged 3 commits into
mainfrom
claude/perf-4141-brainpool-ecdsa

Conversation

@alex

@alex alex commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Part of #4141 (findings: #4141 (comment), "Brainpool ECDSA"). Follows #4406, which added the general-a comb (TCombCfg.generalComb, Cfg.signG) for brainpoolP256r1; this applies it to brainpoolP384r1.

What was slow

Before #4406, brainpoolP256r1 had the same problem. The x86-64 signature computed [k]G with vg_brainpoolp384r1_mul, the ladder of complete additions: 384 doublings and additions, 17 field products each.

What changed

  • Impl/BrainpoolP384r1/CombTable7.lean (new): the 7-bit comb tables, [m 2^(7j)]G for m = 1 … 64, j < 55, affine. They come from the same procedure as Impl/BrainpoolP256r1/CombTable7.lean (the generator reproduces that file byte for byte). The tables aren't trusted; the next file checks them.
  • Proof/BrainpoolP384r1/Comb7.lean (new): the tables checked in the kernel (combChecksW, with the sums' certificate, combChecksW_of_fast). From the group law this gives combOk7 : CombOkW … 7 55 comb7 comb7Start, as Proof/BrainpoolP256r1/Comb7.lean does.
  • Impl/Ecdsa/BrainpoolP384r1/X86_64.lean: signBrainpoolP384r1 := brainpoolp384r1S.signG brainpoolp384r1Comb, where brainpoolp384r1S declares the static VG_BRAINPOOLP384R1_COMB as its gtab. That makes [k]G 55 additions instead of the ladder's 384 steps.
  • Contract, Verified.lean, RFC 6979 wrapper and registration: the same changes brainpoolP256r1 x86-64: sign by a fixed-base comb for any a #4406 made for brainpoolP256r1. Verified.lean uses signG_ok, and its constant-time check covers the table's symbol.
  • ECDH, verification and the public key keep the ladder.

No change to TCB/ or Spec/, and none to #4406's shared code. There's no new variant, so the README tables are unchanged.

Numbers

Benchmarks workflow run on x86_64, against f8911ef3, VG_CPU_FEATURES unset (all features): https://github.com/pyca/verified-garbage/actions/runs/42362046267

Benchmark Base Head Change OpenSSL Head vs OpenSSL
ecdsa_brainpoolp384r1_sha384_sign/64 768.38 µs 74.85 µs 90.3% faster 788.70 µs 10.5× faster
ecdsa_brainpoolp384r1_sha384_sign/1024 1.54 ms 143.83 µs 90.6% faster 790.72 µs 5.5× faster
ecdsa_brainpoolp384r1_sha384_sign/16384 780.15 µs 92.67 µs 88.1% faster 809.35 µs 8.7× faster
ecdsa_brainpoolp384r1_sha384_sign_prehashed/48 761.08 µs 72.08 µs 90.5% faster 784.54 µs 10.9× faster

Local, on an Intel(R) Xeon(R) Processor @ 2.1GHz with cargo bench: sign/64 went from 943 µs to 96 µs (OpenSSL 742 µs), and sign_prehashed/48 from 1011 µs to 93 µs (OpenSSL 755 µs).

Checks

These pass:

  • lake build of everything the change and current main reach
  • Emit.lean --check
  • the Static checks steps
  • check_lean_public_imports.py on the edited modules
  • cargo fmt --check
  • cargo test --release with Wycheproof (brainpool ECDSA, RFC 7027)

No Rust source changed.

Branch note: #4406 was squash-merged from this branch and a force-push wasn't available, so the branch carries a merge of main after its old commit. Against main, the diff is only this change (11 files).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHFtUGDUpzkcbWbx7P7

The x86-64 signature computed [k]G by the ladder of complete additions,
256 doublings and additions of 17 products each, since x86-64's comb
adds by the complete formulas for a = -3 and brainpoolP256r1's a is not
-3. Add TCombCfg.generalComb, the comb with the complete addition for any
a (rcb, with 3b R mod p in the slot of -y, as AArch64's generalComb), its
proof (generalComb_ok, from tcomb_ok's), and Cfg.signG, the signature
with [k]G by it, from the 7-bit comb tables AArch64, ARMv7 and RISC-V
already use (Proof/BrainpoolP256r1/Comb7.lean checks them): 37 additions.
The tables are the static VG_BRAINPOOLP256R1_COMB, which the signing
configuration declares as its gtab, so that combConsts and the RFC 6979
contract list it. ECDH, verification and the public key keep the ladder.

No change to TCB/ or Spec/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFtUGDUpzkcbWbx7P7
As brainpoolP256r1's: the signature computes [k]G by Cfg.signG, the comb
whose additions are the complete ones for any a, from new 7-bit comb
tables (Impl/BrainpoolP384r1/CombTable7.lean: [m 2^(7j)]G, m = 1 … 64,
j < 55), which Proof/BrainpoolP384r1/Comb7.lean checks in the kernel
(combChecksW, with the sums' certificate): 55 additions rather than the
ladder's 384 doublings and additions. The tables are the static
VG_BRAINPOOLP384R1_COMB, the signing configuration's gtab. ECDH,
verification and the public key keep the ladder.

No change to TCB/ or Spec/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFtUGDUpzkcbWbx7P7
…h merge)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFtUGDUpzkcbWbx7P7

# Conflicts:
#	crates/verified-garbage-asm-x86_64/src/consts/mod.rs
@alex
alex added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 307122b Nov 7, 2026
29 checks passed
@alex
alex deleted the claude/perf-4141-brainpool-ecdsa branch November 7, 2026 10:30
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