Repository navigation
FFDH/Miller-Rabin: remove dead declarations and modules - #4336
Merged
reaperhulk merged 2 commits intoNov 6, 2026
Merged
Conversation
Remove the declarations and modules under Proof/Ffdh, Impl/Ffdh, Proof/MillerRabin and Impl/MillerRabin that nothing reachable from the registrations, the TCB, the tests or the lakefile's roots uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvCMMw8GyH4m7pdZWZ
Keep the lemmas the ffrun tactic names and the local notations, which the .ilean files do not record as uses; import directly what deleted modules passed on; remove the unused St.at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvCMMw8GyH4m7pdZWZ
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-ffdh
branch
November 6, 2026 19:16
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
alex
pushed a commit
that referenced
this pull request
Nov 7, 2026
Main removed declarations only this branch still used (#4336, #4367, #4514): `fin64_exec_li_lit`, the RISC-V Miller–Rabin search pieces the sieved parameter candidate calls, and three of `ModExpWin`'s WP lemmas. They return, unchanged, as FFDH-only modules (`Proof/Ffdh/RISCV64/Li.lean`, `Impl/Ffdh/RISCV64/Search.lean`, `Proof/Ffdh/RISCV64/Search.lean`) and local lemmas in `Cached/Rows.lean`. The registrations drop `consts :=` (#4380). The generated code takes #4514's Montgomery schedule and #4468's dispatcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHHEKNw8eCDhgbwoFBL
alex
pushed a commit
that referenced
this pull request
Nov 15, 2026
Main removed declarations only this branch still used (#4336, #4367, #4514): `fin64_exec_li_lit`, the RISC-V Miller–Rabin search pieces the sieved parameter candidate calls, and three of `ModExpWin`'s WP lemmas. They return, unchanged, as FFDH-only modules (`Proof/Ffdh/RISCV64/Li.lean`, `Impl/Ffdh/RISCV64/Search.lean`, `Proof/Ffdh/RISCV64/Search.lean`) and local lemmas in `Cached/Rows.lean`. The registrations drop `consts :=` (#4380). The generated code takes #4514's Montgomery schedule and #4468's dispatcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHHEKNw8eCDhgbwoFBL
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 FFDH and Miller–Rabin proof and implementation declarations that nothing reachable uses: 964 declarations, including 63 whole modules.
Spec/,TCB/,src/or the generated crates changes.Emit.lean --checkpasses, so the emitted code is identical.Proof/Ffdh/,Impl/Ffdh/,Proof/MillerRabin/orImpl/MillerRabin/. No registration file changes.287 files, +88 / −14,490.
How "dead" was decided
This follows the method in
tools/deadcode/README.mdon the tooling branch..ileanfiles of a full build at the base (880b9378c).Artifacts/,Generic/,Variants/,TCB/andVerifiedGarbageTest/;*.leanfiles import..ileanfiles don't record:Removed
Modules: 63 whole modules.
Proof/Ffdh/, 3 underImpl/Ffdh/:Impl/Ffdh/AArch64,Impl/Ffdh/Arm/KeyPower,Impl/Ffdh/Arm/KeyPowerDetect;KeyBody,KeyFirst*,KeyGenerate*,KeyVerified,DomainVerified,DomainContractCT,VettedKeyGenerate*,ParameterCandidate/{CandidateScreenQ,SieveStep,…};Proof/Ffdh/{Choose,KeyGeneration},Proof/Ffdh/AArch64,AArch64/GenerateKey/Contract;PPC64LE/GenerateKey/Fn;X86/KeySearch/{ABI,Data,Entry};X86_64/ParameterCandidate/{Backend,LoadCT}.Proof/MillerRabin/and 1 underImpl/MillerRabin/: the RISC-V blinded loop (Impl/MillerRabin/RISCV64/BlindedandProof/MillerRabin/RISCV64/Blinded/{Ctx,Load,LoadCT,LoopCT,Round,RoundCT,WitnessCT}).Declarations: 642 more, from the 218 modules that remain. Some examples:
GenerateKey.generateKeyand its proof pieces (gkFront,smear,scalar,gkBody), whose shared pieces the cached form still uses;CR,G1…G3,Pa.bound, the*.outlemmas);smallMod,sieve,oddPrimes256,montPrep,r2AnyandmillerRabin, with their proofs. Only RSA key generation's pieces (montPrepWith,montPrepHi,roundCall,loadDraw, …) remain;*_ctand*_oklemmas.13 top-level
Verifiedproofs of routines that no registration exports. No registration file (Artifacts/,Generic/,Variants/) exports any of them, on any target. Where the routine is still emitted, it is reached through another export or as an internal callee, whose correctness and constant-time proofs stay:Proof.Ffdh.AArch64.verified:chooseagainstchooseContract;Proof.Ffdh.AArch64.CheckDomain.cd_verified: the generic AArch64vg_ffdh_check_domainagainstcheckDomainContract;Proof.Ffdh.AArch64.ParameterCandidate.pc_verified, againstsievedParameterCandidateContract;Proof.Ffdh.X86_64.ParameterCandidate.candidateCode_verified, againstsievedParameterCandidateContract;Proof.Ffdh.Arm.domain_verified,key_verified,keyGenerate_verified: ArmCheckDomain.code,GenerateKey.codeandKeyGenerate.codeagainstcheckDomainContractandgenerateKeyContract;Proof.Ffdh.Arm.VettedKeyGenerate.verifiedand the privatevettedKeyGenerate_verified, againstvettedGenerateKeyContract;Proof.MillerRabin.AArch64.RoundImpl.verifiedandProof.MillerRabin.X86_64.RoundImpl.verified: the generic round againstroundContract;Proof.MillerRabin.Arm.round_verifiedandRoundImpl.verifiedSpec: the ARMv7 round against the 56-byteroundContract. Its own-contract proof (round_verified_lite) andround_impliesstay.Other edits that come with the removal:
-- Formerly …sections) were left with no declarations and are removed.Proof/Ffdh/Arm/KeyFn:KeyOutputs,KeyTail;Proof/Ffdh/X86/KeySearch/Steps:TCB.X86.Target;Proof/MillerRabin/RISCV64/Blinded/Witness:Proof.MillerRabin.RISCV64.Prep,Impl.MillerRabin.RISCV64.Search.opens. Danglingopens of deleted namespaces or constants are dropped inPPC64LE/GenerateKey/Front,RISCV64/Blinded/{CTBase,Witness,Loop}andX86/KeySearch/Steps.Kept on purpose
Proof/Ffdh/Arm/{SharedDeriveInstances,SharedExchangeInstances,SharedCheckPublicInstances,KeySearch/*,KeyBackend,…}andImpl/Ffdh/Arm/{KeySearch,CombPrecompute,VettedGroups}, whichGeneric/RsaMont/Arm/{CachedFfdh,DerivePublic,Exchange,Domain}import. They are only trimmed.Proof/Ffdh/Arm/Block.leanthat theffruntactic template names (mov_exec,cmp_exec,gpr_putMem,z_subFlags, …). The.ileanfiles record no use for them, but live proofs runffrun. The first build caught this.slandn1inImpl/Ffdh/X86/{Cached,Candidate,Derive,Domain,KeyGen}, andsvinProof/Ffdh/PPC64LE/ParameterCandidate/Exit. Their macro rules look unreferenced in the graph. The first build caught this too.Rerunning the analysis on this branch finds exactly these 42 declarations dead in scope, and nothing else. FFDH has 42 dead declarations and 0 dead modules; Miller–Rabin has 0 and 0.
Not changed, outside scope
Impl/RsaKeyGen/RISCV64/Witness.leannamesmontPrep;Proof/RsaKeyGen/RISCV64/Cand/CTMr.leannamescheck_okandLInv.Proof/Ffdh/X86/Cached/PreTop.leanalready named a nonexistentbody_ok(the theorem ispcBody_ok). This PR doesn't touch it.Dead
Spec/definitions in scope (listed only)A separate session removes dead Spec definitions in one PR.
Spec/Ffdh(19):choose,generate,generateParameters,parametersFrom,privateComponents,publicComponents;initialKeyRetries,ParameterSearchResult.available,vettedKeySearchApi;sievedParameterCandidate_accepted,sievedParameterSearch_accepted;SievedAccepted's private lemmas:candidate_suffix,consume_accepted,drawWitness_suffix,drawWitnesses_suffix,draw_suffix,loop_suffix,screened_suffix,search_accepted.Spec/MillerRabin(all 11):mrIteration_eq_mrRound,mrSquarings_iff,mrSquarings_true,obviouslyComposite_dvd,powMod_double,powMod_two_pow,splitTwos_spec,sqIter,sqIter_one,sqIter_succ',witness_range.Checks
lake build --log-level=warningpasses;Emit.lean --checkpasses, with the standard axiom audit, and no file undercrates/changes;check_lean_public_imports.py --base origin/mainpasses on the 224 modified modules.lean-importsjob passes, withcheck_lean_single_importer.py --base origin/main. This includescheck_registrations,check_lean_speed,check_variants,run_unit_tests(641 tests) andcheck_mcdt.cargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.sorry,native_decide,bv_decideormaxHeartbeats.main: 18 Lean files changed upstream since the base, none under FFDH or Miller–Rabin. None of them imports a deleted module or 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