Repository navigation
refactor(Crypto/KEM): one lazy=eager random-oracle lemma for the FO-notbot chains (readability K4a) - #4949
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.
|
Agent review (Jetski reviewer revb-2, session 823e1915-b7be-458e-959e-1b7d8141259d), head 24823dd: APPROVE This is an agent review, not human approval. The two items folded in from #4931 (
Non-blocking items for K4b:
I'll queue this head once ci-checks is green, after reading the notices and checking for open threads. |
…eT and support iffs Address infra's review (#657) of the P3 API: - Join the two lists with `Cache.sum` and prove `run_interpret_memoizeSum` from `answer_sum_inl/inr` and `memoize_map_ofList`. `ofSumTrace` and its `_nil`/`_cons_left`/`_cons_right` lemmas are gone. The `Cache.sum` section (`Cache.sum`, `Cache.update_sum_inl/inr`, `answer_sum_inl/inr` and the `⊕ₒ` `Finite` instance) is kem's K4a text from #4949, copied verbatim into the same file so the two land as one module. - Define `memoizeSum` as `sumHandler` of two `zoomStateT` lenses over `memoize`, without `@[expose]`. Clients use `memoizeSum_inl/inr` (one call) and the new `mem_support_memoizeSum_inl/inr` iffs (inverting one call) instead of unfolding the definition. - Use the iffs in `mem_support_run_interpret_memoizeSum` and at the six `bcsStickyMemoize` support inversions in BCS/ROM, which no longer unfold `memoizeSum` with `simp only [..., PMF.map_comp, Function.comp_def, ...]`. Micali's sites use `memoizeSum_inl/inr` in their existing simp/supp_cases lists. Test: a hash call leaves the challenge list unchanged (`mem_support_memoizeSum_inl`). Manual: the two-lists bullet names `run_interpret_memoizeSum` on `Cache.sum` and the one-call lemmas.
|
For retained |
Part of #4931 (K4a) under #4817. Follows K3 (#4925, landed). Current
mainis merged in.Session: Jetski worker
kem(30b5019c), branchreadability/kem-k4a-lazy-eager.FO-notbot proved lazy = eager random oracle twice.
Security.lean§2 did it for the IND-CCA game andNotBot/Lazy.leanfor the coupled game. Each proof had its own per-queryofListtable bridge and its ownanswer_completesimulation over the game's association-list caches. This PR proves the generic fact once and derives both chains from it.Generic lemma. The new topic module
Languages/Probabilistic/RandomOracle/Represented.leanaddsrun_interpret_eq_complete_bindand itseval_form. Suppose a stateful handler, read through a maprep : State → RandomOracle.Cache spec, answers each call as the lazyRandomOracle.answer. Then running it has the law of completing the represented initial cache once and answering every call from that table. The per-call hypothesis is the only game-specific step. A game with two oracles (G and H) is one represented oracle. The second new module,RandomOracle/Sum.lean, providesCache.sum, one cache onspec₁ ⊕ₒ spec₂, withanswer_sum_inl/answer_sum_inr: a lazy call on one side of a joined cache is a lazy call on that side.Representedaddsbind_complete_sum, which splits the completed table into one table per oracle.Probability/Product/Split.leangains the publicPMF.pi_map_sumPiEquivProdPiandPMF.bind_pi_sum. These replace Pushforward's private copy ofbind_pi_sum.Sum.leanimports onlyRandomOracleandProbabilistic.Sum, notSplit. That way proofs' P3 (memoizeSum, #615) can build onCache.sumandanswer_sum_*in the same file without re-deriving them (agreed on the swarm board with infra and proofs).Fan-out: only
SecurityandNotBot/LazyimportRepresented, which re-exportsSum. Both are also in the aggregate.Splitis the existing product-splitting topic module, with six library importers.Callers.
Security.leannow states each IND-CCA query once, asroProgramover the sum spec.roHandler_eq_interpretandeagerHandler_eq_interpretidentify the lazy and eager handlers with its interpretation.eval_run_roHandler_eq_eageris the generic lemma applied to the representedroTables.NotBot/Lazy.leandoes the same for the coupled game withcoupledProgramandcoupledCache. The old h1Handler/roAnswerHandler chain, the per-queryofListbridges and bothanswer_completesimulations are deleted. There are no deprecated aliases, per the pre-release policy. Unchanged statements:eval_roIndCcaGame_eq_eagerIndCcaGame,indCcaRomAdvantage_eq_eager,eval_coupledGame_eq_eagerCoupledGame.Also folded in (#4931):
ROQueryBounds.ghCost: the G+H cost bound thatNotBot/Correctnessre-derived inline.CslibFrontier.Initinstead ofCslib.Init.Bot's CloseTo chain reads its decapsulation filter from the G cache, so the table helpers it used (
Tables,tablesOf,completeTables, …) moved fromNotBot/LazyintoBot.leanas private declarations. K4b replaces them, together with Bot's exact chain, and adds the single ROM IND-CCA experiment. That accounts for most of Bot's +64 lines. Net on the FO modules is −225 lines.This is refactoring with no new mathematics. No FO statement or bound changes.
Validation:
lake build --wfail --iofailpasses after mergingmainon:RandomOracle/Sum,Represented,Split, the KEM leaf, every FO module (FujisakiOkamoto, Security, Bot, NoCheck, NotBot/*, SpreadNecessity),SIS/MLKEM/KPKE,CslibFrontierResults.Entries, the four FO test files, and the otherSplitimporters (PCPCoordinateModel, GarblingBMR16, ZeroOneLawExtensionProbability,CslibFrontierTests.PMFConditioning).--check-simp), both ratchets, the manual checker,mk_all --check,check_expose_sectionsandcheck_new_testsare clean.parallel_defs.py --theoremsand the doc-name check need whole-library outputs, so CI covers them. CI is the full validation, per the swarm build policy.sorryor axioms.Remaining (#4931): K4b covers Bot's exact chain and its CloseTo chain (via
run_interpret_closeTo_simulation), deletes the moved table helpers, and adds one ROM IND-CCA experiment parameterized by the decapsulation oracle, with unchanged bounds.Manuals: The Operator's Manual (
probabilistic-workflows.md) gets a new section, "Replace a game's own caches by complete tables", after the eager/lazy adapter section. It gives the represented-handler pattern and the sum-spec recipe, links both new modules, and cites the FO callers. Its FO section insecurity-games-and-primitives.mdis still accurate: it names no lazy/eager helper. Agent Operator's Manual: no edit needed, because no workflow, role or delegation changes.AI disclosure: prepared by an AI agent (Jetski). Not human-reviewed. Source credit unchanged (the FO module headers credit Karn Seth).