Skip to content

ECDSA: remove dead declarations and modules - #4314

Merged
reaperhulk merged 3 commits into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-ecdsa-dead-code
Nov 6, 2026
Merged

reaperhulk merged 3 commits into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-ecdsa-dead-code

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

Like #4305 for DSA, this removes every ECDSA proof and implementation declaration that nothing reachable uses: 2,077 declarations, including 109 whole modules.

  • Nothing in Spec/, TCB/, src/ or the generated crates changes. Emit.lean --check passes, so the emitted code is identical.
  • There are no dead Spec/Ecdsa definitions (0 of 64).

388 files, +143 / −26,290.

How "dead" was decided

  • Graph. A declaration-level graph built from the .ilean files of a full build.
  • Live roots. The live set starts from:
    • every declaration in Artifacts/, Generic/, Variants/, TCB/ and VerifiedGarbageTest/;
    • the non-Spec modules the lakefile names;
    • the modules the top-level *.lean files import.
  • Uses the .ilean files don't record:
    • Literals found by name. rw_lit, lit_decide and taint_decide look up materialize_* literals by name. So every module-level command in a module the roots import is live, along with the code it materializes, and Lit modules that live code imports are kept.
    • Tactics, macros and notation. A module that defines syntax is never deleted. That is why Proof/Ecdsa/Verify/AArch64/JacChecks stays, with only its jac_field_ct/jac_reg_ct tactics.
    • Attributes and instances. Anything carrying a simp-set or instance attribute is live in modules the roots import.
  • Final check. The full build is the arbiter.

The literal rule was added for this PR. I also re-checked #4305 against it: nothing #4305 removed would have been kept.

Removed

  • Modules: 109 whole modules under Proof/Ecdsa/ and Impl/Ecdsa/.
  • Declarations: 1,968 further declarations from 244 modules that remain, mostly unused helpers, *_ct and *_wp lemmas.
  • 155 top-level Verified proofs of routines that no registration exports. Each is a proof that an internal routine would satisfy a public contract if it were exported on its own. No registration file exports any of them on any target; they are reached only as internal callees, whose correctness and constant-time proofs stay. The emitted functions are unchanged. They include:
    • the per-curve sign_verified, Inverse.{p,n}_verified and Mul.mul_verified on x86, x86-64, AArch64 and ARMv7;
    • the per-curve mul_verified and sign_verified on RISC-V;
    • Mul.mul_verified on PPC64LE;
    • several verify_verified and jointVerify_verified.

Outside the ECDSA directories:

  • 11 of ECDSA's own registration files (Generic/<Curve>/<Target>/Ecdsa*.lean) only drop imports of deleted modules (check_registrations passes).
  • Proof/Ecdh/Arm/Validate.lean rewords one doc comment that named a removed declaration.

Other edits that come with the removal:

  • Three ARM Umaal modules and AArch64 P-521 Checks now import directly what deleted modules used to pass on.
  • Dangling open … in, omit … in, empty sections and namespace blocks are removed.
  • Doc comments that named removed declarations are reworded.

Kept on purpose

  • Proof/Ecdsa/X86/CombVerified and Proof/Ecdsa/Verify/X86/WindowPrep, which Generic/P256/X86/EcP256 and EcdhP256 import, with everything they use.
  • invFnX_gpr, which ECDH's CheckFn.correct uses.
  • Impl.Weierstrass.Arm.mulGenerator{P224,P256,P384,BrainpoolP256r1}, which the Weierstrass CombLit modules materialize.

Checks

  • Lean:

    • the full lake build passes;
    • Emit.lean --check passes with the standard axiom audit;
    • check_lean_public_imports --base 402c926c1b passes on the modified modules.
  • Static checks: every step passes.

  • Rust: cargo fmt --check and cargo clippy --all-targets -- -D warnings pass. No Rust changed.

  • No escape hatches: nothing adds sorry, native_decide, bv_decide or maxHeartbeats.

  • After merging current main (445 Lean files changed upstream, none under ECDSA):

    • no file imports a deleted module;
    • no upstream-changed file names a removed declaration in full.

    The CI Lean build on the merge commit is the final check.

No benchmark: the emitted code is unchanged.


Generated by Claude Code

…1 Checks

The deleted PackedTiming module had passed them on.

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