Repository navigation
AEADs: remove dead declarations and modules - #4345
Merged
reaperhulk merged 1 commit intoNov 6, 2026
Merged
Conversation
Remove the AES-GCM, GHASH, GCM-SIV, AES-GCM-SIV, SM4-GCM, Poly1305, ChaCha20 and ChaCha20-Poly1305 proof and implementation declarations that nothing reachable from the registrations, the TCB or the tests uses: 1,198 declarations, 24 of them whole modules. Nothing in Spec/, TCB/ or the generated crates changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwM7EdmaMkyjpzzob6
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-aead
branch
November 6, 2026 18:25
alex
pushed a commit
that referenced
this pull request
Nov 6, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHEMqEdVZRt8M1hMXb1
This was referenced Nov 6, 2026
reaperhulk
pushed a commit
that referenced
this pull request
Nov 6, 2026
Resolve the import list of Proof/AesGcm/X86_64/Instances.lean (both sides' imports), and restore preparedPowersRepr(16)_zeroMem and preparedPowersRepr(16)_of_zeroMem, which #4345 removed as unused and open_to's satisfiability proofs use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvqXkQxFyWZxghqxBG
reaperhulk
pushed a commit
that referenced
this pull request
Nov 6, 2026
Resolve the import list of Proof/AesGcm/X86_64/Instances.lean, and state saved_crFrame, which #4345 removed from Proof/AesGcm/X86_64/Fn.lean as unused, in OpenSplit/Run.lean, its only user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvqXkQxFyWZxghqxBG
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 AEADs' proof and implementation declarations that nothing reachable uses. The scope is the directories
AesGcm,Gcm,GcmSiv,AesGcmSiv,Sm4Gcm,Poly1305,ChaCha20andChaCha20Poly1305underProof/andImpl/. In total it removes 1,198 declarations, 248 of them in 24 whole modules.Spec/,TCB/,src/or the generated crates changes.Emit.lean --checkpasses, so the emitted code is identical.Spec/files are untouched. DeadSpec/definitions in scope are listed at the end for the separate Spec pass.395 files, +222 / −12,689.
How "dead" was decided
This follows
tools/deadcode/README.md, the method used for #4305 and #4314..ileanfiles of a full build.Artifacts/,Generic/,Variants/,TCB/andVerifiedGarbageTest/;*.leanfiles import..ileanfiles don't record:Removed
Modules (24)
Impl/AesGcm/AArch64/PreparedProof/AesGcm/AArch64/Fast/{OpenPrepared,OpenStore,Prepared,SealStore}Proof/AesGcm/AArch64/Gather/PreparedProof/AesGcm/AArch64/Prepared/{Derive,Powers,Verified}Proof/AesGcm/ScratchPrepared8Proof/AesGcm/X86_64/{Prepared,Prepared16}/BlocksToProof/ChaCha20/AArch64/Mixed5/LoopProof/ChaCha20/AArch64/Rows6/{Chunk,Loop,Tail}Proof/ChaCha20/ContractProof/ChaCha20/{PPC64LE,RISCV64}/SharedProof/Gcm/{Powers8Contract,PrecomputedContract}Proof/Gcm/X86_64/StitchAvx/{Aes,Dec,Gh}Declarations
950 further declarations come from 362 modules that remain. All 1,198 by directory:
Most are unused helpers,
*_ct/*_wplemmas and contracts.70 top-level
Verifiedproofs of routines no registration exportsEach proves that a routine would satisfy a public contract if it were exported on its own. No registration file exports any of them on any target.
The routines are now reached only as internal callees: through the generic
…Impl/variant interfaces (BlocksImpl,XorImpl,GcmImpl, …) or the stitched and prepared paths. Their correctness and constant-time proofs stay, and the emitted functions are unchanged.ghash_verifiedon x86, x86-64 (+Pclmul,Vpclmul), AArch64 (+Pmull.ghash{,P,W}_verified), ARMv7, PPC64LE (Vpmsum) and RISC-V.blocks_verifiedon x86, x86-64, AArch64, ARMv7 and RISC-V;Radix64.blocks_verified;blocksAvx2/blocksAvx512/blocksIfma_verified; RISC-VfinalizeScratch_verified.block_verifiedon x86, x86-64, AArch64 and ARMv7;xor_verifiedon every target and variant:Xor,Avx2(+xorVL),Avx512,Avx512VL,Avx512Split.xorSplit,Mixed8,Neon4,Rows6, x86xorSsse3;XorImpl.verified.Gather.sealGather_verifiedandGather.Whole.sealGather_verified.{encrypt,decrypt}Blocks{,P,Prepared,Prepared16}_verified,encryptBlocksTo{,P,Prepared,Prepared16}_verified,open{Prepared,Prepared16}_verified;Fast.{seal,open}{Prepared,St,StS}_verified,Gather.sealGatherPrepared_verified,derive_verified;seal_verified,Blocks.encrypt_verified,SplitBlocks.encrypt_verified,Gather.sealGather_verified.Outside the scope's directories
Artifacts/ChaCha20/{PPC64LE,RISCV64},Generic/AesGcm/X86_64/AesGcm) only drop the import of a deleted module.check_registrationspasses.ci/lean_speed_allowed.pylowers twodecide := trueallowances (ChaCha20/AArch64/Rows6/Save: 1 → 0,Poly1305/AArch64/Blocks: 20 → 2), ascheck_lean_speedrequires.Other edits that come with the removal
check_lean_public_imports --base origin/mainpasses).omit … in,set_option … inandopen … inthat belonged to removed declarations;sections, namespace blocks and section headings.Proof/Gcm/Prepared8Contractmodule doc now describes only the format it still defines.Kept on purpose
Used by another algorithm.
Proof.Gcm.ctr32Sigandctr32Contractstay: AES'sctr32_verifiedproofs use them.local notations (vdword,ofVDwords,dw) in 12 Gcm/AesGcm/AesGcmSiv modules. Their uses leave no reference in the.ileanfiles, and removing them broke the build.19 declarations named inside tactic macros (
tactic_template,macro) of their own algorithm's modules. A quotation's names are not recorded either, so the build failed without them:Sm4Gcm.Arm.{store32_eq, store8_eq, encodable_of_decide}(arun,Sm4Gcm/Arm/Run);Gcm.RISCV64.{readW_wr_ne0, readW_wr_ne0', splitStore_eq}(Gcm/RISCV64/Law);AesGcmSiv.X86.readW_writeB_off,AesGcmSiv.{AArch64.Lay.a_w', AArch64.Lay.n_w', Arm.Lay.n_w'};X86.APre.{a_sub, ret_stk, t_sub},X86_64.APre.{a_d, stk_a', stk_d', stk_t'},X86_64.ret_stk, andRegion.Disjoint.dsymm, whichX86_64.ret_stkuses.Rerunning the analysis now reports only these and the notations' auxiliary declarations as dead in scope.
Checks
lake build --log-level=warningpasses, after rebasing onto currentmain;Emit.lean --checkpasses with the standard axiom audit, and no generated crate changes;check_lean_public_imports --base origin/mainpasses on the modified modules.check_lean_single_importer --base origin/main).cargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.sorry,native_decide,bv_decideormaxHeartbeats.main(426 Lean files changed upstream):No benchmark: the emitted code is unchanged.
Not changed, for follow-ups
Out-of-scope stale doc reference:
Proof/AesSiv/RISCV64/Env.lean:24namesLay.cal, which is removed here fromProof/AesGcm/RISCV64/Env. It is AES-SIV's file, so it is left for that algorithm's pass.Dead
Spec/definitions in scope. These are only listed here; the separate Spec PR removes them.Spec/Gcm(34):aesGcmDecrypt,encryptWith_ctx,decryptWith_ctx;PreparedPowersRepr.powers8,PreparedPowersRepr.prepared16;Spec/Gcm/OutOfPlace:openTo{Api,Contract,Leak,Post,Pre,Safety,Sig},openToPrecomputed{Api,Contract,Pre,Sig};Spec/Gcm/Prepared:openToPrepared{Api,Contract,Pre,Sig};Spec/Gcm/Prepared16:openToPrepared16{Api,Contract,Pre};Spec/Gcm/Powers8:{seal,open}StorePowers{Api,Contract,Post,Sig},storePowers{Ok,Safety,Summary}.Note:
Spec/Gcm/Powers8'svg_aes_gcm_store_powers(Spec: vg_aes_gcm_store_powers, GCM's eight powers of H from a key context #4317) just landed and awaits its implementation. It is not in this list.Spec/GcmSiv(2):encryptWith_ctx,decryptWith_ctx.Spec/ChaCha20(5):encrypt_eq_keystreamOf,keystreamOf_eq, and the privatelength_chacha20Block,length_flatMap_const,zipWith_append_of_le.Generated by Claude Code