Repository navigation
ML-KEM: remove dead declarations and modules - #4354
Merged
reaperhulk merged 4 commits intoNov 6, 2026
Merged
Conversation
reaperhulk
force-pushed
the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-mlkem
branch
from
November 6, 2026 19:33
31a3086 to
1784e87
Compare
reaperhulk
enabled auto-merge
November 6, 2026 19:39
This was referenced Nov 6, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 6, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWuV9czH33R5Wq5Tr46
… passed on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWuV9czH33R5Wq5Tr46
…t on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWuV9czH33R5Wq5Tr46
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWuV9czH33R5Wq5Tr46
reaperhulk
force-pushed
the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-mlkem
branch
from
November 6, 2026 20:16
1784e87 to
fee2d0c
Compare
This was referenced Nov 6, 2026
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-mlkem
branch
November 6, 2026 21:01
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 ML-KEM and ML-KEM-1024 proof and implementation declarations that nothing reachable uses: 986 declarations (944 ML-KEM, 42 ML-KEM-1024), including 24 whole modules.
Spec/,TCB/,src/or the generated crates changes.Emit.lean --checkpasses, so the emitted code is identical.How "dead" was decided
The method of
tools/deadcode/README.md(on the tooling branch):.ileanfiles of a full build.Artifacts/,Generic/,Variants/,TCB/andVerifiedGarbageTest/; the non-Spec modules the lakefile names; the modules the top-level*.leanfiles import..ileanfiles don't record:rw_lit,lit_decide,taint_decide): every module-level command of a module the roots import is live, with what it materializes.For this PR I added one more conservative rule (below, "Kept on purpose"): a name that a tactic, macro or elaborator body mentions is kept, as are the auxiliary declarations of
macro_rules/elab_rules. Quotations leave no.ileanreference, and a missing lemma insidefirst | … | …would only make a tactic fall through silently rather than fail the build.Removed
Modules (24):
Impl/MlKem/AArch64/Dot(the 32-bit fused dot product; the 16-bitDotWstays)Proof/MlKem/AArch64/Dot/{Accumulate,Arithmetic,Ready,Reduce}Proof/MlKem/AArch64/Kem16/EncryptProof/MlKem/AArch64/Noise/{LayoutAll,LayoutPair,ReadonlyLayoutTables}Proof/MlKem/AArch64/Ntt16/{Pass1,Readonly/At,Readonly/Pre}Proof/MlKem/AArch64/NttR/{VerifiedF,VerifiedFI}Proof/MlKem/AArch64/Optimized/{Contracts,Depth,KemNoise,KeyGenNoise,Taints,TransformTablesExec}Proof/MlKem/{KpkeKgRowsContract,Ntt16Contract}Proof/MlKem/X86_64/{Sample16,YNttLay42}Declarations: 962 more from 284 modules that remain. Among them:
SampleNTT(sampleFull,sampleFast,sampleSqueeze{,N},sampleNTT; the…Withforms stay);ylay*,yzeta*,vibflyL,ypackand their proofs; ML-DSA has its own);…_monolemmas ofProof/MlKem/KPke.lean,ntt_eq_ops/nttInv_eq_ops;*_ct,*_wpand frame lemmas.109 top-level
Verifiedproofs (and_ofhelpers) of routines that no registration exports. No registration file exports any of them on any target: AArch64's ML-KEM registration exports onlycheckEk,MlKem16/AArch64's artifact list is empty, and on the other targets they are reached only as internal callees, whose correctness and constant-time proofs stay. They are:Decaps.decaps_verified,Encaps.encaps_verified,KeyGen.keyGen_verified,CE.compressEncode_verified,DD.decodeDecompress_verified,Cbd16.verified,Cbd16W.verified,Cbd2.cbd2_verified,Codec16.{dec,enc}_verified,Decode12.decode12_verified,Encode12.encode12_verified,Mul.mul_verified,Ntt16.{ntt,ntt_inv}_verified,NttR.{fast,fastInv}_verified,Sample.sample_verified{,With},add_verified,sub_verified; ML-KEM-1024'sDecaps.decaps_verified,Encaps.encaps_verified,KeyGen.keyGen_verified,CE.compressEncode_verified,DD.decodeDecompress_verified;Add.{add,sub}_verified,Cbd2,CompressEncode,Decode12,Encode12,Mul,Ntt,NttInv,SampleandDecompress/DecodeDecompress.verified; ML-KEM-1024'sCompressEncode.verifiedandDecompress.verified;add,sub,cbd2,cbd2_16Y,compressEncode,decodeDecompress,decode12,encode12,mul,ntt,nttInv,sample,sample16,sample4_16,sample4_scalar,{dec,enc,kg}Mul{3,4},{dec,enc,kg}MulSse{3,4},kgNtt768,kgRow768,kpke{Dec,Enc,Kg}768Y_verified, withkpke{Dec,Enc,Kg}768_ofandsample4_16_of_correct; ML-KEM-1024'scompressEncode1024,decodeDecompress1024,kpke{Dec,Enc,Kg}1024Y_verifiedandkpke{Dec,Enc,Kg}1024_of.Outside the ML-KEM directories:
Artifacts/MlKem/X86_64.leanandArtifacts/MlKem16/AArch64.leanonly drop imports of deleted modules (check_registrationspasses).Proof/MlDsa/X86_64/KeyGen/Call.leanonly drops an import of a deleted module.Edits that come with the removal:
Impl/MlKem/AArch64/{DotW,OptimizedUsing}no longeropenthe deletedDotnamespace;Optimized/KemUContext,Kem16/KgRows,Kem16/URowandKem16P/URowimportNoise.Layout(andKemUContextImpl…Noise) directly, which deleted modules used to pass on.omit … in/set_option … inlines, emptysections and section headers are removed.Impl/MlKem/X86_64/NttAvx2,Proof/MlKem/AArch64/Ntt16/{Idx,Rows,Mem},Proof/MlKem/X86_64/{YNtt,YNttLay,YNttPack}).Kept on purpose
72 declarations the analysis still reports dead in scope, all kept for a stated reason:
.ileanreference):offsetNames(lom_unfold);Decaps.offs,Encaps.offs(dek,enk);X86.Enc.{ok_sc,okW_sc,sep_sc,ptrTo_sc}(sc_decide,sc_taint);X86.ea_at, used by ML-DSA's x86 tactics;AArch64.reduced_zero,coeffAt_zero,X86_64.reduced_zero(mlkem_impliesand ML-DSA's);{Arm,PPC64LE,RISCV64}.{KeyGen,Encaps,Decaps}.lay{,M}_sizes;setReg_*/setFlags_*/arithFlags_eq/sx*simp-set macros;xdLe_*,ctlOk_{call,ite},all_{call,ite},Codecs.{ce,dd}_{ctl,sp};ArithOk.{dm,em,km}_{ctl,sp}, whichs4_ctlreaches as($v).arith.dm_ctl.macro_rules/elab_rulesinAArch64/Lay,X86/TopKem,X86_64/{KgH16Sel,Sample4Impl,Top16Ctl}and the+++notation of the x86Implmodules.Dead
Spec/definitions noticed (not changed here)VG.Spec.MlKem.keyGenInternal_h(Spec/MlKem.lean): the only dead one ofSpec/MlKem(1 of 103). For the separate Spec PR.Checks
lake build --log-level=warningpasses, before and after rebasing ontomain(e7072b2);Emit.lean --checkpasses with the standard axiom audit, both times;check_lean_public_imports --base origin/mainpasses on the 312 modified modules.Static checksjob passes, withcheck_lean_single_importer --base origin/main;ci/run_unit_tests.pypasses (641 tests).cargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.sorry,native_decide,bv_decideormaxHeartbeats.mainhas since moved 4 commits (1,414 Lean files, none under ML-KEM): no added line there imports a deleted module or names a removed declaration. The CI Lean build on the merge commit is the final check.No
Spec/orTCB/file and no generated crate changes. No benchmark: the emitted code is unchanged.Generated by Claude Code