Repository navigation
RSA: remove dead declarations and modules - #4344
Merged
reaperhulk merged 6 commits intoNov 6, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWybRGxJyfsRWhNtS11
…ing prefixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWybRGxJyfsRWhNtS11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWybRGxJyfsRWhNtS11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWybRGxJyfsRWhNtS11
… and variables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWybRGxJyfsRWhNtS11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWybRGxJyfsRWhNtS11
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-rsa
branch
November 6, 2026 18:24
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
…me_out beside their use #4344 removed them from Proof/Rsa/RISCV64/KeyLayout.lean as dead; only this search uses them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHGhkN8REQLPW8yxN5A
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 for DSA and #4314 for ECDSA, this removes the RSA family's proof and implementation declarations that nothing reachable uses. The scope is
Proof/andImpl/ofRsa,RsaKeyGen,RsaOaep,RsaPkcs1Enc,RsaPkcs1Sig,RsaPssandMgf1(Mgf1had nothing dead). It also deletes DSA'sProof/Dsa/X86/LoadSlot.lean, which #4305 left for RSA (below).1,889 declarations removed: 480 with 102 whole modules, and 1,409 more from 551 modules that remain. DSA's
LoadSlot(one dead theorem) is also deleted, for 103 modules in all. 707 files, +555 / −26,310.Spec/,TCB/,src/or the generated crates changes.Emit.lean --checkpasses: the emitted code is identical.lean/isci/lean_speed_allowed.py.check_lean_speed.pyasked for Mid1's allowance to be lowered (below).How "dead" was decided
This is the method of #4314, with the shared scripts of the dead-code tooling branch.
.ileanfiles of a full build at880b9378c.Artifacts/,Generic/,Variants/,TCB/andVerifiedGarbageTest/;*.leanfiles import..ileanfiles don't record:Two more kinds of invisible use. This scope showed two the scripts don't catch. I kept every instance of both:
Syntax declarations and what they use. The plan trimmed syntax modules down to nothing, which would have removed:
elabshdr_disj,rsa_stack_shapeandrsa_stack_use;macros,T2inInvBatchRt/Time/CompandnwordinFrontRt/Near;They are all kept, along with the lemmas their quotations name:
loop_all,call_all,frame_alland the*_stacklemmas inRsa/X86/StackTactic. Lemmas named only inside other macros' bodies are kept too. There are 32 of them, for exampleRecDet.b2n_le1andRecDet.ite_le1inRsa/PPC64LE/RdOps, and thes*_ltandsubFlags_*lemmas inRsaPss/Arm/Step.Names built at run time.
hdr_disjbuilds<list>_shape(Name.appendAfter) and looks the name up in the environment. So the 25*Ranges_shapelemmas of RsaKeyGen AArch64 and X86-64 are kept with what they use.Removed
103 modules: 102 under the RSA family's
Proof/andImpl/, and DSA'sLoadSlot:Impl:Arm.CheckCrtKey,PPC64LE.CheckCrtKeyX86.MulMod,X86_64.WordValidationProof:Checked,MontProductContractAArch64.{CrtKeyHead, CrtKeyMain}Arm.{CckCorrect, CckTaint}PPC64LE.{KcCck, KcCckCT, KcCckMain}X86.{CvHelperTiming, CvLoad, CvStore, InvHalf, KeyCopy, KeyEq, KeyRt.Gcd, KeyWord}X86_64.{Implies8, PrivOutcome}Impl.X86:CandidateImport,CandidateLoadGcd64CheckKeyCrt,KeyInverse,KeyLcm,KeyPrimesProductProof:CheckedPPC64LE.Cand.{Instances, Verified},RISCV64.Cand.{Instances, Verified}CandidateBitsTiming,CandidateDispatch,FastR2Timing,Inverse.Safety,InverseTiming,KeyArrayDivision,KeyConstant{,Timing},KeyCrtTiming,KeyD{Part,Product,Select,ecrement},KeyDivision{Correct,Timing},KeyExponent{ResultFrame,Timing},KeyGcdIsOne,KeyHalveStep,KeyHeaderTiming,KeyImport{Exponent,Prime,Timing},KeyInitialize,KeyInputInitialize,KeyInverse{Correct,Timing},KeyLcm{Correct,Timing},KeyLoad{Exponent,Inputs}Timing,KeyNoSpCode,KeyOdd{Finish,Modulus,Prepare},KeyOrder,KeyPartCorrect,KeyPrimes{Correct,Timing},KeyProduct{,Value},KeySafety,KeySmall,KeyVerified,KeyWidenCopy,KeyZero,OrScanTiming,Product{Bounds,Correct,Row,Timing,Window},TrialTiming,WitnessPolicyDecrypt,Encoding,RISCV64.CTMgfChecked,AArch64.CalleePrefix,Sign,AArch64.{RecoverVerified, VerifyVerified}Sign,Verify,X86_64.BufferXorProof.Dsa.X86.LoadSlot, as described below.1,409 declarations removed from 551 modules that remain, mostly:
*_ok,*_ct,*_wpand*_implieslemmas;₂versions remain (RSA-PSS);…Withforms, for example RsaKeyGen'smillerRabin,mrRound,kMainandcodeon AArch64 and x86-64.24 top-level
Verifiedproofs of routines that no registration exports. Each proves that an internal routine meets a contract as if it were exported on its own. No registration file exports any of them on any target. Their routines are reached only as internal callees, or through a generic caller that is proven separately.precomputedChecked_verified,publicChecked_verifiedCheckCrtKey.check_crt_key_verifiedKeyCheck.cck_verified,Priv.priv_verifiedPriv.priv_verifiedInstances.{crt, crtAdx, crtIfma}_verifiedcode_verified,crt_call_verified,publicChecked_verifiedCand.cand_verifiedandCand.candidate_verified. The Miller–Rabin generic registrations for these targets do not use them.Key.verifiedAArch64.Enc.enc_verified,X86_64.enc_verified{AArch64, X86_64}.{Rec, Ver}.code_verifiedOutside the RSA directories:
check_registrations.pypasses):Artifacts/RsaKeyGen/X86Generic/MillerRabin/{PPC64LE, RISCV64}/RsaKeyGenGeneric/RsaPrivateCrt/{X86, X86_64}/RsaPkcs1SigGeneric/RsaPublicPrecomputed/AArch64/RsaPkcs1SigGeneric/RsaPublicPrecomputed/AllMdHash/X86_64/RsaOaepProof/Variants/RsaPrivateCrt/X86/BaseImpl/Dsa/X86/ProbablePrimedrops its import of the deletedImpl/RsaKeyGen/X86/CandidateLoad. It used nothing from it.Proof/Dsa/X86/LoadSlot.leanis deleted. DSA: remove dead declarations and modules #4305 kept it only because RSA'sGeneric/RsaPrivateCrt/X86/*andProof/Variants/RsaPrivateCrt/X86/Base.leanimport it. Its one theorem,loadSlot_ok, is unused: those files use nothing from it. So both imports are dropped, and the module goes with them.ci/lean_speed_allowed.pylowersRsaKeyGen/Arm/Key/Mid1.lean'sdecide := trueallowance from 25 to 21, ascheck_lean_speed.pyasks now that the uses are gone.Other edits that come with the removal:
open/omit/include … inprefixes, leftovervariables, emptysections and namespace blocks, and their orphaned-- Formerly …comments are removed.Kept on purpose
*_shapelemmashdr_disjfinds by name.Impl.Rsa.X86_64.Crt.expLoop5Impl.Rsa.AArch64.{Public, Precomputed, Crt}.codeProof.Rsa.Mont{Window, Square, MulFixed}.*andProof.Rsa.MontMulFixedContract, all used by BignumProof.Rsa.X86_64.precomputedChecked_impliesProof.Rsa.KeyWorkspace.Arrs.nilandProof.Rsa.Arm.Keys.Arrs.nil, used by MillerRabinProof/Rsa/X86/StackTactic. The analysis counts all 15 of its declarations as dead, but it definesrsa_stack_shapeandrsa_stack_use, whichRsa/X86/RtShapeand FFDH's x86 proofs use.Dead
Spec/definitions in scope (not removed)These are listed only. Removing them is a trust change for the separate Spec PR.
Spec/RsaKeyGen/GenerationAgrees.lean:SearchAgrees,primeSearch_agrees,primeSearch_used_le,searchFrom,searchFrom_init, and 9 private helpers.Spec/RsaPkcs1Enc/Contract.lean:encryptContract,encryptSig.Spec/RsaPkcs1Sig/Contract.lean:recoverContract,recoverSig,verifyContract,verifySig.Spec/RsaPss.lean:SaltLength(with.signand.verify),dropWhile_db,eq_db,eq_db_of_take,verifyEncodingRfc,verifyEncoding_some.Not in this PR
Generic/MillerRabin/X86/RsaKeyGen.leanhas a-- shake: keep (the public artifact body usescode_all)comment. It was already stale before this PR, and is now more so:code_allis removed. Registration files only drop imports here, so it is left for a reviewed edit.Checks
lake buildpasses (28,824 jobs);Emit.lean --checkpasses, with the standard-axiom, compiler-override and spec-origin audits, so no crate changes;check_lean_public_imports --base origin/mainpasses on the modules whose imports changed.check_lean_single_importer.py --base origin/main. The steps are:check_lean_imports,check_lean_modules,check_lean_single_importercheck_case_collisions,check_registrations,check_lean_speedaudit_base check,algorithms_table --checkcheck_arch_gates,check_variants,check_skillsVG_CPU_FEATURESgrep,cpu_tests lintrun_unit_tests,check_mcdt,check_vectorscargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.sorry,native_decide,bv_decideormaxHeartbeats.main(683 Lean files changed upstream, none of this PR's): no upstream file imports a deleted module, and none 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