Skip to content

x86-64 NIST-curve public-key functions and P-192 verify return without secret residue - #4899

Merged
reaperhulk merged 1 commit into
mainfrom
claude/residue-ec
Nov 10, 2026
Merged

reaperhulk merged 1 commit into
mainfrom
claude/residue-ec

Conversation

@reaperhulk

@reaperhulk reaperhulk commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

A residue burn-down, following #4892. It takes 26 lines off ci/residue_allowlist.txt. No trust change: nothing under TCB/ or Spec/ changes.

What is converted

  • compress, decompress and validate public key, 24 functions:
    • P-192 and P-224;
    • P-256, P-384 and P-521, each with its _adx variant.
  • vg_ec_p192_public_key.
  • vg_ecdsa_p192_verify. Its analysis wipes 6 granules of its 96-byte frame.

Every other function here has nothing on the stack to wipe; its scrub only clears registers.

How

  • Proof/EcKey/X86_64/Scrub/Out.lean (new): one PostOut proof per contract shape, generic over the curve: publicKeyOut, compressOut, decompressOut, validateOut and verifyHashOut.
  • The scrub for each registration (scrubKs, scrubOk, scrubReg) is in the module that proves its code, next to that code's literal (for example Proof/EcKey/Compressed/X86_64/P256.lean).
    • The curve's law is passed in as an argument, so only the registration files import the Law modules.
    • New modules importing these proofs would raise the importer counts of Divstep/Weierstrass, which ci/check_lean_speed.py limits; one of them is already at its limit.
  • The registration files only bind, for example (Proof.EcKey.Compressed.X86_64.P256.scrubReg hasLaw.inv true).

What stays listed, and why

  • The comb public keys (7): vg_ec_{p224,p256,p384,p521}_public_key, and _adx for P-256, P-384 and P-521. They read tables of constants (Abi.withConsts), which the residue analysis does not model yet.
  • secp256k1's and the brainpool curves' public-key functions, and ECDH (28): the analysis passes on all of them with nothing to wipe. They come in a follow-up PR, kept separate to keep this one small.

Checks

  • lake build (all modules), Emit.lean --check, the Static checks job (including check_lean_speed.py), check_lean_public_imports.py on the changed modules: pass.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings: pass.
  • cargo test with Wycheproof, with every CPU feature and with VG_CPU_FEATURES=none: pass.

Speed

Benchmarks run 42776698050: x86-64, the P-192 to P-521 public-key, validate and ECDSA verify groups, with every CPU feature and with none, against main, one interleaved run.

  • Every benchmark is within ±1.6%.
  • That includes ecdsa_p192_sha256_verify, the one function here that wipes stack: 1.3% faster at 64 B, 0.2% slower at 16 KiB.
  • The public-key and validate benchmarks are within 0.9%.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ajQWxYnEynffr2A7QLPVa

Return without secret residue (`X86_64.RScrub.withScrub`) from the x86-64
`vg_ec_<curve>_{compress,decompress,validate}_public_key` (and their `_adx`
variants) for P-192, P-224, P-256, P-384 and P-521, `vg_ec_p192_public_key`
and `vg_ecdsa_p192_verify`: 26 functions leave ci/residue_allowlist.txt.

The postconditions' locality is proven once per contract shape, for every
curve (`Proof/EcKey/X86_64/Scrub/Out.lean`). Each scrubbed registration is
in the module that proves its code (the residue analysis next to the code's
literal), taking the curve's law as an argument, so that the registration
files only bind and no new module imports the curves' heavy algebra
(`check_lean_speed.py`'s importer limit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWxYnEynffr2A7QLPVa
@reaperhulk
reaperhulk added this pull request to stack #4915 November 10, 2026 16:11
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit de841f1 Nov 10, 2026
36 checks passed
@reaperhulk
reaperhulk deleted the claude/residue-ec branch November 10, 2026 16:23
alex pushed a commit that referenced this pull request Nov 10, 2026
…work's

scrubAllCode and its proof move from Proof/Framework/X86_64/Scrub.lean to
their one user, Proof/Pbkdf2/Md/X86_64/ScrubStream.lean, so that this change
leaves Scrub.lean as main has it. Every function that is scrubbed imports
that module, the EC key and ECDH functions of #4899 and #4900 among them,
whose proofs CI's Lean shard rebuilt together, twice ending with the
runner's shutdown.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFEUkKJRQvsEBN9oBp
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