Skip to content

DSA: remove dead declarations and modules - #4305

Merged
reaperhulk merged 1 commit into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-dsa-dead-code
Nov 6, 2026
Merged

reaperhulk merged 1 commit into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-dsa-dead-code

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

This follows #4304 and removes every DSA proof and implementation declaration that nothing reachable uses: 594 declarations, including 41 whole modules. Nothing in Spec/, TCB/, src/ or the generated crates changes, and Emit.lean --check shows the emitted code is identical.

272 files, +12 / −6,001.

What "dead" means here

A declaration-level graph built from the .ilean files of a full build. 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.

Implicit uses leave no .ilean reference, so the analysis keeps those conservatively:

  • Every declaration that carries an attribute or is an instance stays live in any module the live set imports, since simp sets and instance search use them without a reference.
  • Module-level commands (attribute, #guard, materialize_*) keep what they reference live.

The full build is the final check. After removal, rerunning the analysis leaves no dead DSA declaration except one kept on purpose (below).

Removed

41 modules, all under Proof/Dsa/:

  • AArch64:
    • Generation.{ForceWitnessCT, RoundTail, TapeCT, TapeReset, TapeTake, WorkspaceCT, WrappedSeed}
    • RandomCT, VerifyingMain
  • Arm:
    • ArithVerified, ContextVerified
    • Prime.{Front, Taint2}
    • PublicValidation{ABI, CT, Correct, Verified}
  • Shared:
    • Generation.Sizes
    • ModArithContract, MontContextContract
    • PublicValidation, PublicValidationContract
  • PPC64LE: Sign.{Implies, Verified}
  • RISC-V: Params{Implies, Verified}, Sign{Implies, Verified}
  • x86:
    • Comb.{ABI, KeyCorrect, PrivateVerified, Registration, Satisfiable}
    • DerivingDispatch, DerivingDispatchCT
    • KeyRandom.Instance
    • MulVerified, PowVerified
    • VerifyBody, VerifyBodySpec, VerifyCompute

Some of these are top-level Verified proofs of functions that no registration emits any more:

  • vg_dsa_sign on PPC64LE and RISC-V, where sign is now only an internal callee; its code and sign_correct/sign_ct stay because other proofs use them;
  • RISC-V's params proof;
  • ARMv7's public-validation proof;
  • x86's comb private-key path.

458 declarations removed from 224 modules that remain, mostly unused helpers:

  • *_ct, *_wp and leftovers in the Refill* modules;
  • CodeDepth, CodeSafety, RoundCode, ValidateDepth, SubgroupState;
  • Generation/{PDomain, Layout};
  • RISC-V CTBase and VerifyCT, PPC64LE Ctx, and others.

Follow-on edits:

  • Imports of the deleted modules are dropped from their importers. Two of those are registration files, Artifacts/Dsa/X86.lean and Artifacts/Dsa/PPC64LE.lean, which lose only those imports.
  • A stale open is removed from X86/Comb/Correct.lean.
  • Doc comments in 8 files that named removed declarations are reworded.
  • ci/lean_speed_allowed.py drops its entry for Dsa/Arm/Prime/Inv.lean, as check_lean_speed.py asked once the uses that needed it were gone.

Kept on purpose: Proof/Dsa/X86/LoadSlot.lean. Its theorem is dead, but RSA's Generic/RsaPrivateCrt/X86/* registration files and Proof/Variants/RsaPrivateCrt/X86/Base.lean import the module. Removing it belongs with RSA.

Not in this PR

  • Dead Spec/ definitions. Removing them is a trust change for its own PR. Among them are five unused *DomainCheckedApi definitions in Spec/Dsa/DomainChecked.lean (their contracts are still used).
  • Dead code in other algorithms. The same analysis finds an upper bound of about 18,100 dead declarations outside DSA, out of about 289,000. The largest are ECDSA (≈2,100), Weierstrass (≈1,700), ML-DSA (≈1,300), ML-KEM (≈1,000), Ed25519, Bignum, FFDH and Mont. Removing them would mean a PR per algorithm.

Checks

  • Lean:
    • the full lake build passes (28,929 jobs);
    • Emit.lean --check passes, with no change to any crate;
    • check_lean_public_imports --base origin/main passes on all modified modules;
    • trim_lean_imports finds nothing more to trim.
  • Static checks: every step passes, including run_unit_tests (641 tests).
  • Rust: cargo fmt --check and cargo clippy --all-targets -- -D warnings pass. No Rust changed.
  • Forbidden constructs: no sorry, native_decide, bv_decide or maxHeartbeats added.

No benchmark is linked: the emitted code is unchanged.


Generated by Claude Code

Remove every declaration under Proof/Dsa/ and Impl/Dsa/ that nothing
reachable from the registrations (Artifacts/, Generic/, Variants/), TCB/,
the Lean tests or the lakefile's libraries refers to, directly or
transitively, found with a declaration-level graph built from the build's
.ilean files. A declaration with an attribute (an instance, a simp lemma)
in a module the roots import counts as used, since such uses leave no
reference; a module-level command's references count once its module is
used.

* 41 modules deleted (136 declarations), among them AArch64's
  Generation/{Tape*, WrappedSeed, RoundTail, ForceWitnessCT, WorkspaceCT},
  the unregistered `vg_dsa_sign` proofs on PPC64LE and RISC-V, RISC-V's
  unregistered parameter-check `Verified`, Arm's PublicValidation*
  proofs, x86's Comb.{ABI, Registration, Satisfiable, PrivateVerified,
  KeyCorrect} and Generation/Sizes.
* 458 declarations removed from 224 modules: unused lemmas in the Refill*
  modules, CodeDepth, CodeSafety, RoundCode, ValidateDepth,
  SubgroupState, Generation/{PDomain, Layout}, and the per-architecture
  proofs and code helpers nothing uses.

`Proof/Dsa/X86/LoadSlot.lean` stays: its one theorem is unused, but RSA's
x86 Generic and Variants files import the module. Docs that named removed
declarations are updated, and the speed allowlist drops the count of
`Arm/Prime/Inv.lean`, which no longer has its uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 577fc20 Nov 6, 2026
19 checks passed
@reaperhulk
reaperhulk deleted the claude/unify-random-bytes-crypto-xqmg0z-dsa-dead-code branch November 6, 2026 14:51
alex pushed a commit that referenced this pull request Nov 7, 2026
…SA modules it uses (work in progress)

Main's dead-code removals (#4305, #4336, #4344, #4367) deleted RISC-V
modules and declarations that only this search uses. Restore them as
they were before each removal.

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