Skip to content

Ed448/X448: remove dead declarations and modules - #4342

Merged
reaperhulk merged 1 commit into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-deadcode-ed448
Nov 6, 2026
Merged

reaperhulk merged 1 commit into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-deadcode-ed448

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

Like #4305 (DSA) and #4314 (ECDSA), this removes the Ed448, X448 and Curve448 proof and implementation declarations that nothing reachable uses: 1,076 declarations, including 73 whole modules, plus 3 local notations nothing uses any more.

  • 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/ definitions in scope: Ed448 0 of 37, X448 0 of 21 (Curve448 has no spec).

277 files, +280 / −13,191.

How "dead" was decided

The method of tools/deadcode/README.md (on the tooling branch):

  • Graph. A declaration-level graph built from the .ilean files of a full build.
  • Live roots.
    • 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. Every module-level command of a module the roots import is live, along with what it references.
    • Tactics, macros and notation. A module that defines syntax is never deleted.
    • Attributes and instances. These are live in modules the roots import.
  • Final check. The full build decides.

Two refinements for this scope, both on the safe side:

  • local notation doesn't protect its module. It can't be used outside its file, so it doesn't count as syntax for keeping a module. Its auxiliary macroRules declaration, which no .ilean reference ever reaches, is kept wherever the module stays. I removed a notation only where its token no longer appears in the file.
  • Hand-written literals are live. lit_decide finds every N.lit_eq/N.lit pair in the environment by name (Proof/Framework/Lit.lean), not only those materialize_* makes. So Proof/Ed448/X86_64/VariantForLit, which the x86-64 registrations import, stays whole, with what it uses.

The plan was iterated to a fixed point. Three passes on the rebuilt tree then found a cascade the README's loop doesn't see: it leaves out deleted modules between rounds, but not trimmed declarations. Those passes deleted Comb56Contract, then Point56Contract, then Field56Contract, whose last users had gone. A final analysis finds nothing dead in scope but what is kept on purpose (below).

Removed

  • Modules: 73 whole modules: 31 under Proof/Ed448/ and 42 under Proof/X448/. They include:
    • the internal-function contract modules Proof/Ed448/{Contract,Point56Contract,Point64Contract,Comb56Contract} and Proof/X448/{Field56Contract,Field56MulContract,Field64Contract}, plus Arm/FnContract;
    • the AArch64 X448 ladder that the Fast one replaced (Proof/X448/AArch64/{Ladder,Ops,Row,MulLoop,Pointwise*,…}, Weak/{Ladder,Finish});
    • Proof/X448/Wide/{Mul,Columns,Tail*,…};
    • the AArch64 Ed448 window verifier (Window/{KInit,KLoop,SBase,Window,Digit}, VerifyMain, VerifyCT/*);
    • the x86-64 Ed448 window pieces (Window/{First,Joint,Loop,Round,Sign,SignedSelect,Digit}, BaseLoop, PowVariant);
    • the PPC64LE and RISC-V BaseCT/ScalarCT.
  • Declarations: 683 further declarations from 179 modules that remain. Most are unused helpers, *_ok and *_ct lemmas, and implementation definitions that no registration emits:
    • the 32-bit-limb RISC-V Impl.X448.RISCV64.x448 with its field operations (the registered code is R64);
    • the old AArch64 Impl.X448.AArch64.x448 and Weak.x448;
    • the AArch64 VerifyWindow code (window, wcross, kInit, table, verifyEquation, …);
    • the x86-64 non-variant publicKey, signCached, verify and scalarBase steps, where the registrations use the …For v forms.
  • 44 top-level Verified proofs of routines that no registration exports. No file in Artifacts/, Generic/ or Variants/ names any of them. Each proves that an internal routine meets a contract on its own; those routines are reached only inlined or through the variants' proofs, which stay. The emitted functions are unchanged.
    • Ed448 scalarBase_verified, scalarMulAdd_verified, scalarReduce_verified:
      • on AArch64, ARMv7, PPC64LE, RISC-V, x86 and x86-64;
      • with verifyEquation_verified on all but RISC-V;
      • also Sparse.verifyEquation_verified (AArch64), and scalarBaseFor_verified and verifyEquationFor_verified (x86-64).
    • Ed448 AArch64 CombBase.combBaseFn_verified and Point56.{add,double,mul,pow}Fn_verified.
    • Ed448 x86-64 FieldVariant.{add,double,pow}_verified.
    • X448 ARMv7 gf448_{add,sub,mul,mulA24}_verified.
    • X448 x86 {add,sub,mul,mulA24}Fn_verified.
    • X448 x86-64 pow223_verified and pow223With_verified.

Outside the Ed448/X448/Curve448 directories:

  • 3 of Ed448's own registration files (Generic/Curve448Field/X86_64/Ed448{SignCached,Verify}, Generic/Keccak/AArch64/Ed448Verify) only drop imports of deleted modules. check_registrations passes.

  • ci/lean_speed_allowed.py drops 4 DECIDE_SIMP_ALLOWED entries:

    • one for a deleted file (X448/AArch64/Inv);
    • three whose uses all went (X448/AArch64/{Carry,Main,Weak/Main}).

    check_lean_speed requires these counts to be exact.

Other edits that come with the removal:

  • Modules that imported a deleted module now import what it passed on, at the same visibility (and meta).
  • Leftover include … in/variable lines were removed: a removed theorem's range starts at theorem, so its modifier would otherwise apply to the next declaration. Empty namespace/section blocks and section headers with nothing under them are removed too.
  • About 40 module and declaration doc comments were reworded where they named removed declarations or deleted files. The modules that lost their main theorem now describe what they still hold (e.g. Field16Contract, the AArch64 Window/* helpers, Impl/X448/RISCV64).

Kept on purpose

  • Proof/Ed448/X86_64/VariantForLit (8 declarations): lit_decide finds its N.lit_eq literals by name. The x86-64 registrations import it.
  • 61 local notations (EV, FV, BFrame, …) in modules that stay, which their files still use. Their macroRules auxiliaries show as unreferenced in the .ilean files.
  • Nothing was kept because another algorithm's code refers to it, and no other algorithm's registration imports a module in scope.

Checks

  • Lean, on the pre-rebase base:

    • the full lake build --log-level=warning passes;
    • Emit.lean --check passes, with the standard axiom audit and no generated crate changed;
    • check_lean_public_imports.py --base origin/main passes on the 204 modified modules (48 analysed).
  • Static checks: every step of the Static checks job passes, with check_lean_single_importer.py --base origin/main.

  • 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.

  • Rebuilt analysis: nothing dead is left in scope beyond what is kept above.

  • After rebasing onto current main (437 Lean files changed upstream; the only one in scope is Spec/X448/Contract.lean, which adds vg_x448_exchange's spec):

    • the rebase was clean;
    • no file imports a deleted module;
    • no upstream-changed file names a removed declaration;
    • the static checks pass again.

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

No benchmark: the emitted code is unchanged.


Generated by Claude Code

Remove the Ed448, X448 and Curve448 proof and implementation declarations
that nothing reachable from the registrations, the trusted base or the tests
uses, and the modules left empty. No Spec/, TCB/ or generated code changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWvczSrPuzG4qdbYu6t
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit e99bc9d Nov 6, 2026
17 checks passed
@reaperhulk
reaperhulk deleted the claude/unify-random-bytes-crypto-xqmg0z-deadcode-ed448 branch November 6, 2026 18:27
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