Repository navigation
Spec: retire the Apis of vg_rsa_prime_search, vg_rsa_prime_search_init and vg_rsa_keygen_key - #4419
Merged
Merged
Conversation
…t and vg_rsa_keygen_key Since #4368 no Rust calls them: vg_rsa_generate calls the prime search and the key from its verified code, and nothing calls the search's init. - Spec loses primeInitSig, primeInitContract, primeInitApi, primeSearchApi and keyApi; Spec/RsaKeyGen/GenerationContract.lean is deleted. - primeSearchSig and primeSearchContract move, unchanged, to Proof/RsaKeyGen/SearchContract.lean; keySig, keyContract, keyOp and keyStatus to Proof/RsaKeyGen/Contract.lean. - The Spec docstrings that named the moved contracts describe what they meant directly. - The prime search's init is dead: its Impl and Proof modules are deleted on x86-64, x86, AArch64, PPC64LE and RISC-V. Arm keeps them, which DSA's key generation reuses, without init_verified. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHJ2FcxfeqKwuVNLR6Y
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 1: RSA key generation's outer loop)
This retires what #4368 left without a Rust caller, following #4303 and #4377. Since #4368,
vg_rsa_generatecalls the prime search and the key from verified code, on every target. Nothing calls the prime search's init.Trust change (removal only)
This PR removes trusted definitions from
Spec/and adds none. No contract that remains is weakened.Spec/RsaKeyGen/GenerationContract.leanis deleted. It held three groups of definitions:primeInitSig,primeInitContractandprimeInitApi: the init is dead.primeSearchApi.primeSearchSigandprimeSearchContract. These move, unchanged, toProof/RsaKeyGen/SearchContract.lean, which is untrusted. The prime search is now an internal function.Spec/RsaKeyGen/Contract.leanloses five definitions:keyApi.keySig,keyContract,keyOpandkeyStatus. Only the key's contract usedkeyOpandkeyStatus. All four move, unchanged, toProof/RsaKeyGen/Contract.lean, next to the contract of the key's own helper,vg_rsa_keygen_inverse.primeLenValid,otherPrimeand the candidate'scandidateOp,candidateStatusandcandidateLeak.Docstrings only, in four files. They named the moved contracts, and now say what those contracts meant directly:
Spec/RsaKeyGen/Generation.lean: the first tape's length is the code's choice, withinEntropy.RequestValid.KeySearch.lean: the timing may depend on each prime search's trace (primeSearch's) and each key's status (keyResultStatus).GenerationAgrees.lean:vg_rsa_generaterunsprimeSearchfor each prime.KeySearchContract.lean:primeSearch's;keySearchApi's summary now says what the search for each prime and the key do, instead of pointing at the retired functions;keySearchContract's leak (keySearch's trace) already contains.No definition in these four files changes.
Proofs and code
Spec.RsaKeyGen.{primeSearchSig, primeSearchContract, keySig, keyContract, keyOp, keyStatus}toProof.RsaKeyGen.*. Each module that uses them importsProof/RsaKeyGen/Contract.leanorSearchContract.lean.Impl/RsaKeyGen/<T>/SearchInit.leanandProof/RsaKeyGen/<T>/SearchInit.leanare deleted. No registration emits them since RSA key generation: the whole generation in verified code #4368.SearchInitonly for the helpers inProof/RsaKeyGen/InitWords.lean, which they now import directly.SearchInit, because DSA's Arm key generation reuses its code and proofs (Impl/Dsa/Arm/Generation.lean,Proof/Dsa/Arm/Gen/Init.lean). It loses onlyinit_verified, the proof against the deleted contract.VerifiedGarbageTest/RsaPrimeSearch.leannow:Proof/RsaKeyGen/SearchContract.lean;Proof.RsaKeyGen.primeSearchContract;primeInitandprimeSearch, have no compiler overrides.Generated code
Only
vg_rsa_generate's doc comment changes, in each target'srsa_keygen.rs: thekeySearchApisummary above. The functions themselves are unchanged. The prime search and the key were already internal since #4368.Overlap: the open dead-code PRs don't touch RsaKeyGen, and #4392 merged and kept RsaKeyGen whole.
Testing
All of these ran locally on
main(dfb1dd9):lake build, thenEmit.lean. Its audits passed: standard axioms only, and everyVG.Specdefinition is inSpec/.Static checksjob.check_lean_public_imports.py --base origin/mainon the 56 edited modules.cargo fmt --checkandcargo clippy --all-targets -D warnings.No Rust changed, and no emitted function's code changed. Nothing here can affect speed, so there is no benchmark run.
Generated by Claude Code