Repository navigation
Elliptic curves: remove dead declarations and modules - #4348
Merged
reaperhulk merged 1 commit intoNov 6, 2026
Merged
Conversation
Remove the proof and implementation declarations of the elliptic-curve code (Weierstrass, EcKey and the per-curve directories) that nothing reachable from the registrations, TCB/ or the tests uses: 1,583 declarations, including 89 whole modules. No Spec/, TCB/ or generated crate changes; Emit.lean --check passes unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWx9jfFdMU8rNKTRmbk
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-curves
branch
November 6, 2026 19:08
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.
Like #4305 (DSA) and #4314 (ECDSA), this removes the elliptic-curve proof and implementation declarations that nothing reachable uses. The scope is
Proof/andImpl/ofWeierstrass,EcKey,P192,P224,P256,P384,P521,Secp256k1andBrainpoolP{256,384,512}r1: 1,583 declarations, including 89 whole modules.Spec/,TCB/,src/or the generated crates changes.Emit.lean --checkpasses, so the emitted code is identical.Artifacts/,Generic/,Variants/) changes.368 files, +195 / −18,463.
How "dead" was decided
The method of
tools/deadcode/README.mdon the tooling branch, as in #4314:.ileanfiles of a full build of73a7af173(main with ECDSA: remove dead declarations and modules #4314).Artifacts/,Generic/,Variants/,TCB/andVerifiedGarbageTest/;*.leanfiles import..ileanfiles don't record:materialize_*,rw_lit,lit_decide,taint_decide). Module-level commands of imported modules are live, and Lit modules that live code imports stay.Generic/<Curve>/. I countedEcdsa*/Ecdh*registrations as other algorithms', so the modules they import are protected.Removed
89 modules:
Proof/Weierstrass/: Arm 23, PPC64LE 21, AArch64 19, x86 8, x86-64 8, RISC-V 1,RootParity.Proof/P384/X86_64/(4) andImpl/P384/X86_64/PointOps.Proof/Secp256k1/Arm/Comb{CT,Lit}andProof/Secp256k1/X86_64/PointOpsContract.Mont*/Point*proofs and theirVerified/Contractmodules, the Arm UMAAL variants' proofs, and unused timing and forward-arithmetic pieces.816 declarations from 258 modules that remain. Mostly unused helpers,
*_ct/*_relCT/*_wplemmas and contract definitions.308 removed theorems state a
Verified. Each proves that an internal routine meets a contract as if it were exported on its own, but no registration exports any of them on any target. They are reached only as internal callees, whose correctness and constant-time proofs stay, so the emitted functions are unchanged. Among them:add/sub/mulproofs on Arm (with UMAAL), PPC64LE, x86 and RISC-V, and AArch64/x86-64mul/sqr;add/doubleproofs on Arm, PPC64LE and x86;pk_verifiedon Arm and AArch64 (the registrations export the combcombPk_verified);Mont.Wide8.verified.All 308, by namespace
Proof.EcKey.AArch64(1):pk_verifiedProof.EcKey.Arm(1):pk_verifiedProof.EcKey.Arm.BrainpoolP256r1(1):pk_verifiedProof.EcKey.Arm.P224(1):pk_verifiedProof.EcKey.Arm.P384(1):pk_verifiedProof.EcKey.Arm.Secp256k1(1):pk_verifiedProof.P384.X86_64.PointOps(2):addAffine_verified,addCached_verifiedProof.Secp256k1.X86_64.PointOps(3):addAffine_verified,addCached_verified,double_verifiedProof.Weierstrass.AArch64.Mont(10):brainpoolp384r1n_mul_verified,brainpoolp384r1p_mul_verified,brainpoolp512r1n_mul_verified,brainpoolp512r1p_mul_verified,p384n_mul_verified,p384p_mul_verified,p384p_sqr_verified,p521n_mul_verified,p521p_mul_verified,p521p_sqr_verifiedProof.Weierstrass.Arm.Mont(72):add_verified,mul_verified,mulU_verified,sub_verified, and for each ofp192,p224,p256,p384,p521,secp256k1,brainpoolp256r1,brainpoolp384r1,brainpoolp512r1and each modulusp/n:<curve><p|n>_add_verified,_sub_verified,_mul_verified, and_mulU_verified(all butp192andp521)Proof.Weierstrass.Arm.Point(30):pt0_verified,sum_verified;p192_{add,double}_verified;{p224,p256,p384,brainpoolp256r1,brainpoolp384r1}_{add,addU,double,doubleU}_verified;secp256k1_{add,addU,add0m,add0mU,double0,double0U}_verifiedProof.Weierstrass.PPC64LE.Mont(57):add_verified,mul_verified,sub_verified, and<curve><p|n>_{add,sub,mul}_verifiedforp192,p224,p256,p384,p521,secp256k1,brainpoolp256r1,brainpoolp384r1,brainpoolp512r1Proof.Weierstrass.PPC64LE.Point(16):pt0_verified,sum_verified;{p192,p224,p256,p384,brainpoolp256r1,brainpoolp384r1}_{add,double}_verified;secp256k1_add0m_verified,secp256k1_double0_verifiedProof.Weierstrass.RISCV64.Gen4,Gen6,P256Field,P256Order,P384Field,P384Order,P521Field,P521Order(3 each):add_verified,mul_verified,sub_verifiedProof.Weierstrass.RISCV64.P192Field,P224Field(6 each):add_verified,add_verified_n,mul_verified,mul_verified_n,sub_verified,sub_verified_nProof.Weierstrass.X86.Mont(54):<curve><p|n>_{add,sub,mul}_verifiedforp192,p224,p256,p384,p521,secp256k1,brainpoolp256r1,brainpoolp384r1,brainpoolp512r1Proof.Weierstrass.X86.Point(16):pt0_verified,sum_verified;{p192,p224,p256,p384,brainpoolp256r1,brainpoolp384r1}_{add,double}_verified;secp256k1_add0m_verified,secp256k1_double0_verifiedProof.Weierstrass.X86_64.Mont(5):p384n_mul_verified,p384p_mul_verified,p521n_mul_verified,p521p_mul_verified,p521p_mulX_verifiedProof.Weierstrass.X86_64.Mont.Wide8(1):verifiedOutside the scope:
Proof/Ecdsa/Verify/AArch64/drop imports of deleted modules. Nothing else changes in them.VerifiedGarbageTest/EcCompressedRoot.leandrops its import ofWeierstrass.RootParity. It imported the module but used none of its three lemmas.Other edits that come with the removal:
Mont{P192,Secp256k1,BrainpoolP256r1,BrainpoolP384r1,BrainpoolP512r1}and AArch64MontBrainpoolP{384,512}r1importMontFn/MontFnG;PointOpsCTimportsPointOpsAdd;PubNaf/StepDTimingimportsWinJStep.MontBrainpoolP512r1alsopublic importsProof.Framework.Lit(-- shake: keep). ECDSA'sAArch64/BrainpoolP512r1/Configuseslit_decideand got it through the deletedMontContract. Editing that ECDSA file is out of scope here; it can importLititself later, and then this import can go.sections, namespace blocks, and danglingopen … inlines and headers are removed.Kept on purpose
Tactics and the lemmas macros name. The analysis marks these dead because syntax quotations and
elabbodies leave no.ileanreference. The build showed they are used:list_memandnd_find(Proof/Weierstrass/Layout);forward_state(AArch64/Forward/Snapshot);def_literal(X86_64/FieldErase);sext2andzext0(X86_64/InvStep), which theirunmacro names.The unused
certificate_valuecommand (AArch64/Forward/Literal) is removed.32 Weierstrass modules imported by ECDSA/ECDH registrations, mostly AArch64
Naf*/JacWindow*/JacTree, x86WinLoop/WinEntryand x86-64Words/NafPrepTiming. They are kept whole even where their declarations look dead. Removing them belongs with ECDSA/ECDH.Declarations that other algorithms' code uses, mostly ECDH's, even when that code is dead too.
Impl.Secp256k1.pointandImpl.Weierstrass.X86.Point.fn0, which the Lit moduleWeierstrass/X86/PointLit/Secp256k1materializes.After the removal, rerunning the analysis finds no further removable declaration in scope except the 8 kept above.
Stale comments outside the scope (not edited)
These comments name removed declarations, in ECDSA files:
Impl/Ecdsa/AArch64.lean:191:PointOps.Curve.bAtProof/Ecdsa/RISCV64/*/MulVerified.lean(9 curves):Impl.Weierstrass.Mul.Curve.mulInRangeContractProof/Ecdsa/Verify/Arm/Main.lean:27:step_rep(Arm now has onlystep_rep')Proof/Ecdsa/X86_64/InvFnX.lean:16:PointOps.wrap_gprProof/Ecdsa/Verify/AArch64/AllocatedPointsTiming.lean:22: the header`ArithmeticTableChecks`Dead
Spec/definitions in scope (not removed here)VG.Spec.P521.feAtandVG.Spec.P521.montR(Spec/P521/Field.lean).Spec/modules.Checks
Lean:
lake buildpasses (28,742 jobs);Emit.lean --checkpasses with the standard axiom audit, and no crate changes;check_lean_public_imports --base 73a7af173passes on the modified modules.Static checks: every step of the
Static checksjob passes, withcheck_lean_single_importer --base origin/main.Rust:
cargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.No escape hatches: nothing adds
sorry,native_decide,bv_decideormaxHeartbeats.Against current
main(9 commits and 266 Lean files changed upstream since73a7af173, none of them files this PR touches):The CI build of the merge commit is the final check.
No benchmark: the emitted code is unchanged.
Generated by Claude Code