Repository navigation
CFB/OFB/CTR finals: remove declarations and fields nothing uses - #4492
Merged
Merged
Conversation
A reachability check over what #4394, #4430 and #4451 touched (the transitive closure of every artifact's code and proof on each target, and names used by tactics and taint summaries) found these unused: * the abbrev VG.Proof.AesCtr.X86_64.cT, and the theorems VG.Proof.Modes.X86_64.xorByte_scal and fit_off, VG.Proof.Modes.RISCV64.cryptBuf_copy_chn, Setup.pt (AES-CFB x86) and TArgs.pt (AES-, Camellia- and SM4-CTR x86); * precondition fields no proof reads: FPre.sch_wrap and CPre.sch_wrap (AES-CFB and AES-CTR finals; on x86-64 also sp_lo, sp_hi, ret_sch, ret_arg and sv_wrap), KPre.ret_sch (Camellia and SM4 CTR finals, x86-64), XPre.pos (every target's final mode), XPre.fitK and fitR, and XDone.syms (x86), with their proofs where the structures are built. Also corrects the docstring of seqWith_changes_wp (RISC-V), which cited a lemma that no longer exists. No remaining statement, no code and no registration changes; the generated code is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W
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.
Part of #4139 (finding 4: CFB's partial last segment is XORed in Rust; the clean-up after it).
This is the
Impl/+Proof/half of a dead-code check over what #4394, #4430 and #4451 touched. #4487 was theSpec/half.How it was checked. For each target, I took the transitive closure of every artifact's code and proof through types and values, proof terms included. The roots were everything in
Artifacts/,Generic/,Variants/,TCB/andDispatch. Names that tactics, macros and taint summaries use by name count as used, as in #4333. I then grepped each declaration outside that closure acrosslean/andsrc/. Lemmas that are onlyrfland used throughsimporsig_prelists leave no proof-term trace, so I checked those by grep and kept them.Removed (31 files, net 101 lines):
VG.Proof.AesCtr.X86_64.cT;VG.Proof.Modes.X86_64.xorByte_scalandfit_off, andVG.Proof.Modes.RISCV64.cryptBuf_copy_chn(its siblingcryptBuf_copy_datis used);Setup.pt(AES-CFB on x86) andTArgs.pt(AES-, Camellia- and SM4-CTR on x86).FPre.of/CPre.of/KPre.ofand Arm's and RISC-V'sXPre:FPre.sch_wrapandCPre.sch_wrapin the AES-CFB and AES-CTR finals; on x86-64 alsosp_lo,sp_hi,ret_sch,ret_argandsv_wrap;KPre.ret_schin the x86-64 Camellia and SM4 CTR finals;XPre.posin every target's final mode;XPre.fitKandfitRon PPC64LE and x86-64;XDone.symson x86.seqWith_changes_wpon RISC-V citedseqWith_wp, which no longer exists. It now says what the theorem states.No remaining statement, no code and no registration changes. No TCB or Spec changes.
Found and left alone:
Spec.Cfb.aesCfbEncrypt/aesCfbDecrypt,Spec.Ofb.aesOfbandSpec.Ctr.aesCtrare unreached. Block ciphers: remove dead declarations and modules #4333 and Remove dead declarations and modules: second pass #4392 kept their CBC counterpart, so they stay too.ecbCore/ecbSpec, which CFB: verified final functions for the non-AES ciphers; delete Rust's partial-segment XOR #4394 restored, is still used. It is only ever applied to.encrypt, so its decryption branch is extra generality rather than dead code.Proof/Modes/{FbFinal,CfbFinalScratch,CtrFinal}.lean,Proof/Aes{Cfb,Ofb,Ctr}/Final.lean), or the Rust code.Checks:
lake buildandEmit.lean --checkpass at Spec: the CFB, OFB and CTR contracts' docs point a partial last block at the final functions #4487's merge. The generated code is unchanged.check_lean_public_imports.pyon the changed modules pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W