Repository navigation
brainpoolP256r1 x86-64: verify with [u]G by the signature's comb - #4414
Merged
Merged
Conversation
alex
force-pushed
the
claude/perf-4141-brainpool-verify
branch
from
November 7, 2026 09:26
638278e to
19d9427
Compare
alex
changed the base branch from
claude/perf-4141-brainpool-ecdsa
to
claude/perf-4141-brainpool-512-sign
November 7, 2026 09:26
alex
force-pushed
the
claude/perf-4141-brainpool-512-sign
branch
from
November 7, 2026 10:06
53108cf to
15edc59
Compare
Verification computed [u]G and [v]Q by two calls of vg_brainpoolp256r1_mul, the ladder of complete additions, 256 doublings and additions each. Compute [u]G by the signature's fixed-base comb for any a instead (Cfg.gMulG, from VG_BRAINPOOLP256R1_COMB: 37 additions), and keep the ladder for [v]Q: Cfg.verifyG (Impl/Ecdsa/Verify/X86_64/CombGeneral.lean), with its proof verifyG_ok (Proof/Ecdsa/Verify/X86_64/CombGeneral.lean), verify_ok's with pointsG_ok, which is pointsL_ok's with gMulG_ok'. The contract declares the comb's tables (Abi.withConsts brainpoolp256r1S.combConsts), as P-224's does; the entries are scanned in constant time, and only the pointers and the tables' address affect timing. No change to TCB/ or Spec/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHEXYPYjjPyLdLUmbW1
alex
force-pushed
the
claude/perf-4141-brainpool-verify
branch
from
November 7, 2026 10:20
19d9427 to
b00bbb7
Compare
alex
changed the base branch from
claude/perf-4141-brainpool-512-sign
to
main
November 7, 2026 10:20
alex
enabled auto-merge
November 7, 2026 10:22
alex
added a commit
that referenced
this pull request
Nov 7, 2026
Verification computed [u]G and [v]Q by two calls of vg_brainpoolp256r1_mul, the ladder of complete additions, 256 doublings and additions each. Compute [u]G by the signature's fixed-base comb for any a instead (Cfg.gMulG, from VG_BRAINPOOLP256R1_COMB: 37 additions), and keep the ladder for [v]Q: Cfg.verifyG (Impl/Ecdsa/Verify/X86_64/CombGeneral.lean), with its proof verifyG_ok (Proof/Ecdsa/Verify/X86_64/CombGeneral.lean), verify_ok's with pointsG_ok, which is pointsL_ok's with gMulG_ok'. The contract declares the comb's tables (Abi.withConsts brainpoolp256r1S.combConsts), as P-224's does; the entries are scanned in constant time, and only the pointers and the tables' address affect timing. No change to TCB/ or Spec/. Claude-Session: https://claude.ai/code/session_01TKUFHEXYPYjjPyLdLUmbW1 Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Nov 7, 2026
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.
Part of #4141 (findings: #4141 (comment), "Brainpool ECDSA": brainpoolP256r1 verification 1.1× OpenSSL). Built on #4406 (merged), whose comb this uses. #4418 (brainpoolP512r1) and the brainpoolP384r1 verification build on this PR's generic code.
What was slow, and why
On x86-64, Brainpool verification computes
[u]Gand[v]Qwith two calls ofvg_<curve>_mul. That function is a bit-by-bit ladder of complete additions: one doubling and one addition per scalar bit, for each scalar. I measured one call at about half of a verification (brainpoolP512r1: one ladder is ~2.1 ms, verification is 4.1 ms). #4406 found that BMI2/ADX field arithmetic speeds the ladder up by only 10–20%, so the cost is in the algorithm, not in the multiplications.What changed
Impl/Ecdsa/Verify/X86_64/CombGeneral.lean:Cfg.verifyG disCfg.verifyexcept for one step.[u]Gcomes from brainpoolP256r1 x86-64: sign by a fixed-base comb for any a #4406's comb for anya(Cfg.gMulG d: 37 complete additions for brainpoolP256r1, not 512).[v]Qkeeps the ladder (mulV: inline, constant time).Proof/Ecdsa/Verify/X86_64/CombGeneral.lean:pointsG_okispointsL_ok's proof with[u]GbygMulG_ok', its tables found through the configuration'sgtab(tbl_of_held_mem).verifyG_okisverify_ok's proof withpointsG_ok. Both are generic over the curve.verifyBrainpoolP256r1 := Cfg.verifyG brainpoolp256r1S brainpoolp256r1Comb. Its contract (Proof/Ecdsa/Verify/X86_64/BrainpoolP256r1/Contract.lean) now declares the comb's tables (Abi.withConsts brainpoolp256r1S.combConsts, the staticVG_BRAINPOOLP256R1_COMB), following P-224's verification contract. The satisfiability witness holds the tables at0x100000.taintSym_eraseInv). The comb scans its entries as the signature does, so only the pointers and the table's address affect timing.No change to
TCB/orSpec/. No new variant, and no Rust source changed: only the generatedecdsa_brainpoolp256r1files.Numbers
Local,
Intel(R) Xeon(R) Processor @ 2.10GHz(BMI2/ADX/AVX-512 IFMA),cargo bench, all features:ecdsa_brainpoolp256r1_sha256_verify_prehashed/32ecdsa_brainpoolp256r1_sha256_verify/64ecdsa_brainpoolp256r1_sha256_verify/16384Benchmarks workflow (x86_64,
ecdsa_brainpoolp256r1verify groups, with OpenSSL, against #4406's headffa15e2; it measured this commit before the rebase ontomain, which changes no brainpoolP256r1 code): https://github.com/pyca/verified-garbage/actions/runs/42359526499The next step for verification is
[v]Q, the remaining ladder. A public-scalar joint or window method for anyawould need a Jacobian doubling for anyain x86-64's joint framework (JDblOk, which currently has no hypothesis on the slot ofa). That is a separate change.Checks
lake build(all modules) andEmit.lean --checkonmain(d2f38e6), every Static checks step,check_lean_public_imports.pyon the edited modules, andcargo test --releaseof the brainpool tests with Wycheproof all pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHEXYPYjjPyLdLUmbW1