Repository navigation
Spec: remove dead definitions - #4337
Merged
reaperhulk merged 1 commit intoNov 6, 2026
Merged
Conversation
Delete 37 Spec/ definitions that nothing refers to: unused Api declarations (DSA's domain-checked APIs, FFDH's vetted key search, the AES-GCM open_to and store_powers APIs), the contracts of functions no registration emits (AES-GCM open_to and its precomputed, prepared and prepared16 forms), P-521's unused field-arithmetic module, FFDH's component helpers and RSA-PSS's SaltLength. Doc comments that named them are reworded. No definition that stays changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvAPJDdZ8qVqLNfT8q
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-spec
branch
November 6, 2026 18:50
This was referenced Nov 6, 2026
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.
This is a trust change limited to deletions in
Spec/, plus rewording of the doc comments that named what was deleted. No definition, contract, signature,Apior theorem that stays is changed. No file outsidelean/VerifiedGarbage/Spec/is touched: noProof/,Impl/,TCB/, registration, Rust or generated-crate file.Emit.lean --checkpasses with no change to any crate.10 files, +2 / −388: 37 definitions removed, including one whole module,
Spec/P521/Field.lean.Method
This uses the same analysis as #4305 and #4314: a declaration graph from a full build's
.ileanfiles, with a live set from the roots (Artifacts/,Generic/,Variants/,TCB/,VerifiedGarbageTest/, lakefile-named and top-level-imported modules). It conservatively keeps attributed declarations and module-level commands. Atmainit finds 121 dead declarations inSpec/.A declaration was removed only if all of these hold:
Spec/refers to it at all, live or dead. The parallelProof//Impl/cleanups are removing the dead code, and touching it would conflict with them;Spec/that stays refers to it;docs/algorithms/*.toml, README table,ci/script, test or Rust comment names it;Removed (37)
DSA:
Spec/Dsa/DomainChecked.lean(5)signDomainCheckedApi,verifyDomainCheckedApi,randomSignDomainCheckedApi,generateKeyDomainCheckedApi,deriveKeyDomainCheckedApi.No registration emits these
Apis. Their*DomainCheckedContracts stay, since proofs use them.FFDH (5)
Spec/Ffdh.lean:parametersFrom,publicComponents,privateComponents: conversion helpers that nothing calls;Spec/Ffdh/KeyGeneration.lean:initialKeyRetries: unused;keyInitstates the same initial state;Spec/Ffdh/VettedKeyGenerationContract.lean:vettedKeySearchApi: no registration emits it.vettedKeySearchContractstays.AES-GCM (22)
Spec/Gcm/OutOfPlace.lean,vg_aes_gcm_open_toandvg_aes_gcm_open_to_precomputed, neither emitted by any registration:openToSig,openToPre,openToPost,openToLeak,openToContract,openToSafety,openToApi;openToPrecomputedSig,openToPrecomputedPre,openToPrecomputedContract,openToPrecomputedApi;Spec/Gcm/Prepared.lean,vg_aes_gcm_open_to_prepared, not emitted:openToPreparedSig,openToPreparedPre,openToPreparedContract,openToPreparedApi;Spec/Gcm/Prepared16.lean,vg_aes_gcm_open_to_prepared16, not emitted:openToPrepared16Pre,openToPrepared16Contract,openToPrepared16Api;Spec/Gcm/Powers8.lean:sealStorePowersApi,openStorePowersApi: no registration emits them;storePowersSummary,storePowersSafety: only those twoApis' documentation used them.P-521:
Spec/P521/Field.lean(2, whole module)feAt,montR. Nothing imports the module, and no contract ofvg_p521_mul_montorvg_p521_sqr_montwas ever stated in it.RSA-PSS:
Spec/RsaPss.lean(3)SaltLength,SaltLength.sign,SaltLength.verify: unused. The Rustrsa::pss::SaltLengthis a separate Rust type that does not refer to it.Doc rewording
Spec/Gcm/OutOfPlace.lean:vg_aes_gcm_open_tobullet;## Decryption out of placeheading is removed;Spec/RsaPss.lean:SaltLength;## Salt lengthsheading is removed.Spec/Gcm/Prepared.leanandSpec/Gcm/Prepared16.lean: a double blank line left beforeendis collapsed.Left for a follow-up: used only by dead proofs (17)
Each of these is referenced by dead
Proof/code that the parallel cleanups are deleting. Removing them now would conflict with those PRs. Once those merge, rerun the analysis.Ffdh.choose:Proof.Ffdh.chooseContract,Proof.Ffdh.AArch64.*;Ffdh.ParameterSearchResult.available:Proof.Ffdh.Generation.consume_available.Spec/Gcm/Powers8.lean, used byProof.AesGcm.*StorePowers*andProof.AesGcm.AArch64.Fast.*:openStorePowersSig,openStorePowersPost,openStorePowersContract;sealStorePowersSig,sealStorePowersPost,sealStorePowersContract;storePowersOk.RsaPkcs1Enc.encryptSig,encryptContract, used byProof.RsaPkcs1Enc.{AArch64,X86_64}.*.RsaPkcs1Sig.recoverSig,recoverContract,verifySig,verifyContract, used byProof.RsaPkcs1Sig.AArch64.*.RsaPss.dropWhile_db,eq_db, used byProof.RsaOaep.*andProof.RsaPss.*.Kept on purpose (67): dead to the graph, but read by people
Named outside
Spec/(5, plus 6 lemmas they need)Ccm.aesCcmEncrypt,Ccm.aesCcmDecrypt,Gcm.aesGcmDecrypt:VerifiedGarbageTest/{Ccm,Gcm}.lean) name them as what the vectors check.MlDsa.keyGenInternal_tr,MlKem.keyGenInternal_h:src/mldsa_common.rsandsrc/mlkem_common.rscite them;Sha3.Length's six lemmas, which they use.Theorems relating the spec to its standard, which reviewers read (56)
Spec/holds theorems for two reasons: proofs use them, or a reviewer reads them instead of checking a definition against the standard by hand. These are the second kind. Their own docs, or those of the files around them, say so: for example, ChaCha20's "a reviewer need not match its definition against the RFC", orGenerationAgrees.lean's "a reviewer readsgeneratePrime… and the statements here". Removing them would make the spec harder to review, which is not what a dead-code cleanup is for. The kept theorems:MillerRabin.lean: BoringSSL's Miller–Rabin is FIPS 186-5 B.3.1's;RsaKeyGen/GenerationAgrees.lean: the prime search is FIPS 186-5 A.1.3'sgeneratePrime;Ffdh/SievedAccepted.lean: the sieved search accepts only what the plain test accepts.keystreamOf_eq,encrypt_eq_keystreamOf(RFC 8439 §2.4.1), and their private lemmas.blake2s_eq_finalHash(its BLAKE2b twin is live).encryptWith_ctx,decryptWith_ctxfor GCM, GCM-SIV and OCB.verifyEncodingRfc,verifyEncoding_some,eq_db_of_take:verifyEncodingis RFC 8017'sEMSA-PSS-VERIFY.PreparedPowersRepr.powers8and.prepared16. The docs ofPowers8.leanandPrepared16.leanrest on them, for example "a contextvg_aes_gcm_preparewrote … so these APIs also take it".HashTable.index_hashes.Definitions that live docs use to state meaning (3)
Ffdh.generate:generateKeyContract's doc says the contract is "one attempt ofgenerate".Ffdh.generateParameters:SievedAccepted.lean's statements are about it.Entropy.Refill: the entropy protocol's description, andGenerationAgrees.lean, state the host's side with it.If reviewers would rather these go too, that is a deletion-only follow-up.
Checks
lake build --log-level=warningpasses (28,928 jobs);lake env lean --run Emit.lean --checkpasses, with no change to any generated crate, and the audits pass;check_lean_public_imports.py --base origin/main -mon the 9 modified modules: "Public imports OK".Static checksjob passes:check_lean_imports,check_lean_modules;check_lean_single_importer --base origin/main;check_case_collisions,check_registrations,check_lean_speed;audit_base check,algorithms_table --check;check_arch_gates,check_variants,check_skills;VG_CPU_FEATURESgrep,cpu_tests lint;run_unit_tests(641 tests),check_mcdt,check_vectors.cargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.sorry,admit,native_decide,bv_decide,axiomormaxHeartbeatsadded (this PR adds 2 lines of doc text).Spec/declarations remain, exactly the 17 left for the follow-up plus the 67 kept on purpose.No benchmark is linked: the emitted code is unchanged.
Generated by Claude Code