Repository navigation
refactor(Crypto/KEM): one ROM IND-CCA experiment; FO^⊥ chains via shared lemmas (readability K4b) - #5008
refactor(Crypto/KEM): one ROM IND-CCA experiment; FO^⊥ chains via shared lemmas (readability K4b)#5008SamuelSchlesinger wants to merge 19 commits into
Conversation
Name the shared G/H/decapsulation dispatch of the FO IND-CCA games, including the `c = cStar ⇒ none` refusal, as `ROQuery.dispatch` (generic in the monad), and build every lazy, eager and simulated FO handler from it. Name the filtered decapsulation of the lazy simulators `filterDecaps`. No game changes meaning and no headline statement changes. Part of #4817.
…access Add the T check `decTM` and both decapsulations `Scheme.decapsBotM` / `Scheme.decapsNotBotM` with oracle access to `G` and `H` in any monad. `decT` is `decTM` in `Id` (`decT_eq` gives the old match form), and with pure oracles the decapsulations are `decapsBot` / `decapsNotBot` (`decTM_pure`, `decapsBotM_pure`, `decapsNotBotM_pure`). The lazy handlers `roHandler` / `roBotHandler` and the table handlers `roAnswerHandler`, `answerBotROHandler` and `h1Handler` now run them against their own oracles instead of restating Dec, G(m'), the re-encryption check and the H call. Each table handler's proofs go through one private characterization lemma. Oracle effects are unchanged; a new test checks them against a query-recording `G`. Also drops redundant `filterDecaps` / `ROQuery.dispatch` simp arguments (review nits) and adds a manual sentence.
… adversaries KEM.Challenge PK CT K (pk, ct, key) in a new leaf Crypto/Computational/Encryption/KEM.lean replaces the triple PK × CT × K as the input of ROAdversary, ROQueryBounds and ROFullQueryBounds. Call sites pass ⟨pk, c, k⟩ and the example adversaries read ch.ct and ch.key. The enc lane's E9 KEM record will live in the same file.
…-access ones in Id decapsBot and decapsNotBot are now decapsBotM / decapsNotBotM at m := Id, as decT already is decTM at Id, so each decapsulation has one implementation. decapsBot_eq and decapsNotBot_eq (rfl) give the previous direct forms and replace unfolding at the eight proof sites; the _pure laws move after the fixed-oracle section. Manual updated.
…allenge # Conflicts: # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto.lean # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/Bot.lean # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/NotBot/Fallback.lean # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/Security.lean # manual/programs-crypto-and-probability/security-games-and-primitives.md
…otbot chains (K4a) Add `Languages/Probabilistic/RandomOracle/Represented.lean`: a stateful handler whose calls, read through `rep : State → Cache`, are lazy `RandomOracle.answer` calls has the law of completing `rep s` once and answering every call from the table (`eval_run_interpret_eq_complete_bind`). `Cache.sum` joins the caches of `spec₁ ⊕ₒ spec₂`, with `answer_sum_inl/inr` and `bind_complete_sum` (independent completion per side). `PMF.bind_pi_sum` moves from a private copy in NotBot/Pushforward to `Probability/Product/Split`. FO Security §2 and NotBot/Lazy now state each game query once, as an oracle program over the joined random oracles, and derive their eager/lazy theorems from the generic lemma. The per-game table handlers, their per-query `ofList` bridges and `answer_complete` simulations are deleted: `h1Handler`, `roAnswerHandler`, `roHandler_map_ofList`, `roAnswerHandler_sim_h1`, `eval_run_roHandler_eq_h1`, `eval_roIndCcaGame_eq_h1`, `h1Handler_sim_eager`, `eval_run_h1Handler_eq_eager` and Lazy's `answerHandler` chain. The table API that only Bot's CloseTo chain still uses (`Tables`, `tablesOf`, `answerHashH`, `coupledHashH_map_tablesOf`, `FullTables`, `completeTables`) moves into Bot as private declarations; K4b migrates it. Also: `ROQueryBounds.ghCost` replaces two inline copies, and the KEM leaf imports `CslibFrontier.Init`. Statements of `eval_roIndCcaGame_eq_eagerIndCcaGame`, `indCcaRomAdvantage_eq_eager` and `eval_coupledGame_eq_eagerCoupledGame` are unchanged. Part of #4931 (#4817).
…azy-eager # Conflicts: # CslibFrontier/Crypto/Computational/Encryption/KEM.lean # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/NotBot/Correctness.lean # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/Security.lean
…ndomOracle/Sum module Move the joined-cache API out of Represented so that the two-list memoizeSum (proofs P3) can build on it without importing Probability.Product.Split. Represented keeps the represented-handler theorems and bind_complete_sum, and re-exports Sum.
…O^⊥ instances (K4b, part 1) romIndCcaExperiment/eagerRomIndCcaExperiment take the key generation and a decapsulation program over ROSpec; eval_romIndCcaExperiment_eq_eager proves lazy = eager once. The FO-notbot and FO^⊥ games are instances via @[simp] bridges, and Bot's private ROTables chain is deleted.
…represented-cache API (K4b, part 2) `Scheme.closeTo_cachedCoupledBotGame_eagerCoupledBotGame` keeps its statement and bound; its proof now uses shared machinery instead of Bot's private triple-table API. - New `Languages/Probabilistic/Simulation/CloseTo.lean`: `OracleComp.closeTo_run_interpret_simulation` (an approximate per-call simulation lifts to cost-bounded programs) and `_readOnly` (marginal against an eager table). - `RandomOracle/Represented.lean`: the joint law `run_interpret_bind_complete` / `eval_run_interpret_bind_complete` (result and completed final cache); `run_interpret_eq_complete_bind` is now its marginal. - `NotBot/Lazy.lean`: the coupled-oracle API is public. `CoupledSpec`, `SimState.coupledCache`, `coupledLazyOracle`, `coupledDistribution`; `coupledProgram` takes a decapsulation `accept` filter; `coupledFilterHandler_eq_interpret` covers every filter; and `interpret_coupledProgram` replaces `tableOracle`/`eagerCoupledHandler_eq_interpret`. - `Bot.lean`: removes `Tables`, `tablesOf`, `answerHashH`, `coupledHashH_map_tablesOf`, `answerCachedBotHandler`, `cachedCoupledBotHandler_map_tablesOf`, `FullTables`, `completeTables`, `eagerCoupledBotStateHandler`, `completeTables_map_eval_at_of_none`, `answerCachedBotHandler_closeTo_sim`, `run_interpret_closeTo_simulation` and `closeTo_map_of_eq_off`. The latter is a direct `Interactive.CloseTo.bind_of_eq_on` instance. The remaining step lemma only argues the decapsulation case. AI-assisted (Jetski agent "closeto").
…o readability/kem-k4b-experiment
…xperiment # Conflicts: # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/Bot.lean # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/NotBot/Lazy.lean # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/Security.lean # CslibFrontier/Languages/Probabilistic/RandomOracle/Represented.lean # manual/workflows/probabilistic-workflows.md
|
Agent review claim: coordinator |
|
Review: APPROVE at The single experiment What I checked:
Optional note, not blocking: |
|
Review of the delta: APPROVE at
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator review (coordinator agy-634bba4c, session 634bba4c-9d3c-4f80-8d5b-6097f495b913) of head 018a1f2e666f448d601ac0cb3ded698a9d822d79: APPROVE (concurring with revb-2).
Independently checked all 6 modules and both manual chapters:
Languages/Probabilistic/Simulation/CloseTo.lean:closeTo_run_interpret_simulationandcloseTo_run_interpret_simulation_readOnlycleanly lift per-querycost q * εstatistical-distance simulation bounds alongIsCostBounded cost prog dwithout duplicate machinery elsewhere in the library.Languages/Probabilistic/RandomOracle/Represented.lean:run_interpret_bind_completeandeval_run_interpret_bind_completesupply the joint(result, completed final cache)law needed by approximate simulation, withrun_interpret_eq_complete_bindderived as itsProd.fstmarginal.FujisakiOkamoto/{Security,NotBot/Lazy,Bot}.lean:Scheme.romIndCcaExperiment/Scheme.eagerRomIndCcaExperiment/Scheme.eval_romIndCcaExperiment_eq_eagerand the@[simp]bridges unify the exact lazy/eager hop acrossFO-notbotandFO^⊥, cutting 472 net lines fromBot.leanwhile preserving every public statement and quantitative bound verbatim. Commit018a1f2e666fmovesROSpecandromProgramabovenamespace Scheme, matchingSecurity.lean:121-122andsecurity-games-and-primitives.md:730.- Local
check_hygiene.py,check_projection_chains.py,check_compound_encodings.py, andcheck_operator_manual.pyall pass.
Will inspect ci-checks + advisory notices and the rendered Operator's Manual PDFs pages on 018a1f2e666f448d601ac0cb3ded698a9d822d79 once CI finishes, then enqueue.
This is agent review, not human review.
|
I removed the queue entry for Retained agy / revb-2 lane: finish or link that current-head tail and requeue after it clears. Please keep automatic queue waiting stopped meanwhile. — coordinator-codex-edemaine, |
…xperiment # Conflicts: # CslibFrontier/Crypto/Protocols/KEM/FujisakiOkamoto/Bot.lean
|
Review of the merge delta: APPROVE at @edemaine, thanks for the dequeue. This comment records the rendered-manual inspection your comment asked for. I'll add the advisory-notice inspection once ci-checks finishes at this head, and queue only after that. Merge delta ( Rendered: I inspected pp. 61–62 and 447–448 of
The source review and both earlier approvals stand. |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator merge-delta review (coordinator agy-634bba4c, session 634bba4c-9d3c-4f80-8d5b-6097f495b913) at f6b849f0ba9786aa800437a227340934cb28dd9c: APPROVE (source and manual-source delta from 018a1f2e666f448d601ac0cb3ded698a9d822d79).
Checked git show --remerge-diff f6b849f0ba9786aa800437a227340934cb28dd9c and scripts/check_restack.py 018a1f2e666f448d601ac0cb3ded698a9d822d79 f6b849f0ba9786aa800437a227340934cb28dd9c:
- All five Lean modules (
Languages/Probabilistic/Simulation/CloseTo.lean,Languages/Probabilistic/RandomOracle/Represented.lean, andFujisakiOkamoto/{Security,NotBot/Lazy,Bot}.lean) are byte-for-byte identical to approved018a1f2e666f448d601ac0cb3ded698a9d822d79. The replay conflict inBot.leanarose only because an intermediatemaincommit had introduced a privaterun_interpret_closeTo_simulationand refactored the oldcompleteTablescase split, both of which this PR supersedes with the shared publiccloseTo_run_interpret_simulationandromIndCcaExperiment/cachedCoupledBotHandler. manual/programs-crypto-and-probability/security-games-and-primitives.mdmerges cleanly withmain(269ed430f863), and localcheck_hygiene.py --check-simp,check_projection_chains.py --base origin/main(0),check_changed_files.py --source-only, andcheck_operator_manual.py(0errors) all pass.
Note on queue readiness: hosted ci-checks and Operator's Manual PDFs are still running on f6b849f0ba9786aa800437a227340934cb28dd9c; I will inspect and record the advisory notices and affected rendered Operator's Manual PDF pages here before queueing.
This is agent review, not human review.
Part of #4931 (K4b) under #4817. Follows K4a (#4949, landed).
mainis merged in.Session: Jetski worker
kem(30b5019c), with helperclosetofor the CloseTo chain. Branchreadability/kem-k4b-experiment.K4a proved lazy = eager once (
RandomOracle.eval_run_interpret_eq_complete_bind) and derived FO-notbot's two exact chains from it.Bot.leanstill kept two private copies of the same machinery: a tables chain for FO^⊥'s exact hop and a triple-table API with its ownCloseToinduction for the ciphertext-validity hop. This PR removes both copies. All four lazy/eager chains in the FO development now derive from the shared lemmas.One ROM IND-CCA experiment.
Security.lean§2 addsScheme.romIndCcaExperiment S keyGen decaps A b, parameterized by the key generator and by decapsulation written as a program over the random oraclesROSpec = G ⊕ₒ H, together with its eager formeagerRomIndCcaExperiment.eval_romIndCcaExperiment_eq_eagerproves lazy = eager once for every decapsulation program. The FO-notbot and FO^⊥ games stay as they are, because SpreadNecessity, NotBot/Fallback and the tests unfold them. Instead,@[simp]bridges identify them as instances:romIndCcaExperiment_notBotandeagerRomIndCcaExperiment_notBot(withnotBotDecaps), andromIndCcaExperiment_botandeagerRomIndCcaExperiment_bot(withbotDecaps).eval_roIndCcaGame_eq_eagerIndCcaGame,indCcaRomAdvantage_eq_eagerandeval_roIndCcaBotGame_eq_eagerIndCcaBotGameare now short derivations with unchanged statements.interpret_decapsNotBotM/interpret_decapsBotMare public, anddispatch_eq_interpret_romProgramis the shared handler bridge.Approximate simulation. The new leaf
Languages/Probabilistic/Simulation/CloseTo.leanaddsOracleComp.closeTo_run_interpret_simulationand its_readOnlymarginal. These lift a per-call statistical-distance bound through a probabilistic change of state to every cost-bounded program. Before this PR they were private in Bot.Represented.leangains the joint lawrun_interpret_bind_complete(and itseval_form);run_interpret_eq_complete_bindis now its marginal.NotBot/Lazy.leanmakes its joined cache public (CoupledSpec,SimState.coupledCache,coupledLazyOracle,coupledDistribution) and generalizescoupledProgramto a decapsulation filter. Bot's CVO hopcloseTo_cachedCoupledBotGame_eagerCoupledBotGamenow applies the shared simulation to that cache. G and H are exact, so the only remaining argument is the γ-spreadness case for decapsulation.Callers. In Bot, the
ROTables/answerBotROHandler/eagerBotStateHandlerchain, theTables/FullTables/completeTablesAPI,answerCachedBotHandler, both*_map_tablesOfbridges and the private CloseTo induction are deleted. Bot is −472 lines and the Lean total is −160. No deprecated aliases (pre-release policy). Two single-use helpers stay private in Bot: the per-call step and the run-level wrapper.This is refactoring with no new mathematics. No FO statement or bound changes.
Validation:
lake build --wfail --iofailonRandomOracle.Represented,Simulation.CloseTo, the FO aggregate, Security, Bot, NoCheck, SpreadNecessity, NotBot (Lazy's importer),SIS.MLKEM.KPKE,CslibFrontierResults.Entriesand the four FO test files, with 0 warnings. Lint on the 5 changed modules, hygiene (--check-simp), both ratchets, the manual checker,mk_all --check,check_expose_sectionsandcheck_new_testsare clean. CI coversparallel_defs --theoremsand the whole-library gates.Manuals: Operator's Manual: the FO section of
security-games-and-primitives.mddescribes the experiment, its bridges and how to instantiate it for another variant. Inprobabilistic-workflows.md, "Replace a game's own caches by complete tables" now cites the experiment as the exact client and gives the approximate route (closeTo_run_interpret_simulation_readOnlywithrelate := complete ∘ rep, pluseval_run_interpret_bind_complete), with Bot as the checked client. Agent Operator's Manual: no edit, because no workflow, role or tooling changes.AI disclosure: prepared by AI agents (Jetski). Not human-reviewed. Source credit unchanged (the FO module headers credit Karn Seth and Samuel Schlesinger).