Repository navigation
Block ciphers: remove dead declarations and modules - #4333
Merged
reaperhulk merged 1 commit intoNov 6, 2026
Merged
Conversation
Remove the proof and implementation declarations of Blowfish, Camellia, CAST5, IDEA, RC2, RC4, SEED, SM4 and Triple DES that nothing reachable from the registrations, the TCB or the tests uses: 766 declarations, including 15 whole modules, among them 80 top-level `Verified` proofs of routines no registration exports. Declarations named inside tactic and macro definitions, and the `taint_summary`s that other proofs use by name, are kept. No Spec/, TCB/ or generated crate changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvMak1dHwTxf2VtG2z
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-ciphers
branch
November 6, 2026 18:59
alex
pushed a commit
that referenced
this pull request
Nov 7, 2026
…leave consts to the default #4333 removed SM4 Arm's ecbCore and ecbSpec, which only the final functions use now: define them in their modules. #4380 leaves registrations' tables of constants to the default; drop the CAST5 final entries' consts likewise (the generated code is unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W
This was referenced Nov 7, 2026
Merged
Merged
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 proof and implementation declarations that nothing reachable uses, for the block and stream ciphers: Blowfish, Camellia, CAST5, IDEA, RC2, RC4, SEED, SM4 and Triple DES. That is 766 declarations, including 15 whole modules.
Spec/,TCB/,src/or the generated crates changes.Emit.lean --checkpasses, so the emitted code is identical.Spec/definitions for these algorithms (0 of 555 across the nine).274 files, +101 / −5,988.
How "dead" was decided
This follows the method of #4305 and #4314.
.ileanfiles of a full build.Artifacts/,Generic/,Variants/,TCB/andVerifiedGarbageTest/;*.leanfiles import..ileanfiles don't record:CmacTripleDesandSm4Gcmcount as other algorithms here.One rule added for this PR. In the first build,
Proof/Rc2/PPC64LE/Run.lean'srruntactic failed because it namesread_one,write_eightand other lemmas inside itsmacro_rules, and those uses leave nothing in the.ileanfiles. So a declaration is now also kept when a syntax definition names it: asyntax,macro,macro_rules,elab,tactic_templateornotationblock, in the declaration's own module or a module that imports it. Whatever such a declaration uses is kept too.Removed
Modules (15):
Impl/Sm4/Arm/{Ctr,Fb}Proof/Sm4/Arm/{CbcVerified,CtrVerified,FbVerified,ModeCore}Proof/Sm4/RISCV64/PreparedVerifiedProof/Rc2/AArch64/Cbc/ConstantTimeProof/Rc2/RestoreMemoryProof/TripleDes/ContractProof/TripleDes/{Arm,PPC64LE,X86,X86_64}/VerifiedBlockProof/TripleDes/X86/BlockCTDeclarations: 650 more from 252 modules that remain. Most are unused helpers,
*_ct,*_wpand*_implieslemmas, satisfiability witnesses and internal contracts. This includes the internal contracts ofProof/Camellia/Prepared.leanandProof/Sm4/Prepared.lean. TheirLayout,HoldsandKeeps, which the proofs use, stay.80 top-level
Verifiedproofs of routines that no registration exports. Each one proves that an internal routine meets a contract as if it were exported on its own. No registration file names any of them, on any target; I checked this against every*_verifiedname inArtifacts/,Generic/andVariants/. The registrations export the modes' and streams' framed proofs instead. These routines are reached only as internal callees, and their correctness proofs (*_correct,*_wp) stay wherever those are used. The removed proofs are:AArch64.{prepare,crypt}_verifiedAArch64.Serial.{prepare,crypt}_verified{PPC64LE,X86,X86_64}.crypt_verified{key,encrypt,decrypt}_verifiedon AArch64, Arm, PPC64LE, RISCV64, X86 and X86_64Cbc.{encrypt,decrypt}_verifiedon all six targetsX86.Cbc.cbc_verified{PPC64LE,X86}.{encrypt,decrypt}_blocks_verifiedX86.ecb_verified{prepare,crypt}_verifiedon AArch64, Arm, PPC64LE, RISCV64 and X86X86_64.crypt_verifiedAArch64.ecb_verifiedArm.{cbcEncryptChained,cbcDecryptChained,cfbEncrypt,cfbDecrypt,ofb,ctr}_verified{PPC64LE,RISCV64}.Modes.ctr32_verified{encrypt,decrypt}_verifiedon AArch64, Arm, PPC64LE, X86 and X86_64X86.Ecb.{encrypt,decrypt}_verifiedX86_64.Bitsliced{,Sse}.{encrypt,decrypt}_verifiedAArch64.cbcEncryptChained_verifiedOutside the nine algorithms'
Proof/andImpl/directories: five of their own registration files only drop imports of deleted modules:Artifacts/Sm4/RISCV64andArtifacts/TripleDes/{Arm,PPC64LE,X86,X86_64}.check_registrationspasses. No other algorithm's file changes.Other edits that come with the removal:
*_verifiedproof; they now describe the*_correcttheorems that remain and drop the constant-time claims whose proofs are gone.Kept on purpose
180 declarations named inside syntax definitions (the new rule above). Examples:
exec_*,*_memand*_storerewrites that the ARM, AArch64 and x86crun/rruntactics of CAST5, Blowfish and RC4 list;read_one,read_four,read_eightandwrite_*in the PPC64LE and RISC-VRunmodules;*_keeps_x30lemmas that the*_keeps_x30tactics use.Some of these are reached only by tactics no live proof calls. This PR leaves them, since the
.ileanfiles can't tell.VG.Proof.Rc2.X86.Cbc.{wideContract,narrowRd,narrowWr}andVG.Proof.Seed.X86.wideContract. Therc2_cbc_narrowandnarrow_seed_x86_verifiedtactic templates name them by full name.Proof/TripleDes/X86_64/BitslicedSse/ConstantTime. It holds thetaint_summarysencSumanddecSum, whichEcbCall/Verifieduses by name (using BitslicedSse.encSum). Only its two dead theorems,{encrypt,decrypt}_constantTime, are removed. This is the second gap the build caught: a summary used in another module'staint_summary … usingcommand leaves no reference.Cast5's
slotnotation (Proof/Cast5/Arm/Round.lean). Itsmacro_rulesauxiliary declaration looked dead, butBlockandEcbuse it.A rerun of the analysis on the result finds 181 dead declarations in scope: exactly the kept set above.
Checks
lake build --log-level=warningpasses;lake env lean --run Emit.lean --checkpasses with the standard axiom audit, so no generated crate changes;check_lean_public_imports.py --base origin/main -m <modified modules>passes.Static checksjob passes, includingcheck_lean_single_importer.py --base origin/main,check_registrations.py,check_lean_speed.pyandrun_unit_tests.py.cargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.sorry,admit,native_decide,bv_decideormaxHeartbeats.Spec/orTCB/file changes.No benchmark: the emitted code is unchanged.
Generated by Claude Code