Repository navigation
refactor(Crypto/ROM): shared two-list random oracle and sum-cost lemmas for Micali and BCS - #5014
SamuelSchlesinger wants to merge 13 commits into
Conversation
…leBindingOutput
Add MerkleOpening (leaf, path) with MerkleOpening.verify and encMerkleOpening,
and make MerkleBindingOutput a structure {root, position, first, second} with
enc_structure. Migrate merkleBreaksBinding, merkleCollisionFinder, the Kilian
binding adversary and the tests from nested tuples to named fields.
Part of #4817.
Delete KilianOpening and the BCSOpening tuple abbrev. Kilian openings
are MerkleOpening Bool (bit -> leaf) and BCS openings MerkleOpening Sym.
Migrate Kilian/{Soundness,Succinct,Micali,MicaliSoundness}, BCS/{Basic,ROM}
and the tests; tuple projections become named fields.
Part of #4817.
kilianCheck and bcsVerify now check openings with MerkleOpening.verify. The new verify_of_bcsVerify replaces four copies of the step that extracts an accepted opening. A test checks that encKilianOpening keeps the former KilianOpening words.
encMerkleBindingOutput is now encOfEquiv into the former grouped tuple (root, position), first, second. Its field and constructor certificates are proved by hand, and a test checks the old words by rfl. Adds the simp lemmas MerkleOpening.verify_mk and verify_id. Folds #4828 into this PR. Co-authored-by: sig (Jetski worker, #4828)
…e programs out of Micali Kilian/Micali.lean carried general oracle infrastructure ahead of Micali's construction, and BCS/ROM imported Micali just to use it. Move it, unchanged, to its natural homes: - Languages/Probabilistic/Oracle/EvalPure.lean: OracleComp.evalPure and its monad laws, evalWith_pure_oracle, sumPure, evalPure_liftLeft/Right. - Languages/Probabilistic/RandomOracle/Invariant.lean: the RandomOracle.answer cache invariant, cacheOracle, map_fst_runWith_answer_eq_pure. - Crypto/Computational/MerkleTree/Prog.lean: MerkleHashSpec, the merkle*Prog programs, their evalPure bridges, the query bound, the memoize trace invariant and pathQueriedInTrace_of_mem_support_merkleVerifyProg. MerkleTree/Prog.lean also gains the public pathQueriedInTrace_of_mem_support_mapM_merkleVerifyProg, which replaces the private allOpenings_of_mem_support_mapM_merkleVerifyProg copies in Kilian/MicaliSoundness.lean and BCS/ROM.lean. BCS/ROM now imports MerkleTree.Prog instead of Kilian.Micali. Part of #4817.
The private snocFin/ofFn_snocFin in BCS/ROM duplicated Mathlib's Fin.snoc. Use Fin.snoc in the round loops and close the index cases with Fin.lastCases, Fin.snoc_castSucc/snoc_last and List.ofFn_succ_last. Part of #4817
…or Micali and BCS
Micali's and BCS's ROM soundness proofs each carried their own copy of the same
two-oracle plumbing: memoize the Merkle-hash and Fiat-Shamir sides in two lists,
show this implements the lazy oracle on the sum, keep each list's invariant
through a run, and transfer call budgets of one-sided programs to the sum.
New generic modules:
- Languages/Probabilistic/RandomOracle/Sum.lean: `RandomOracle.memoizeSum`,
`ofSumTrace`, `run_interpret_memoizeSum` (with the `_nil` output-law form),
`run_interpret_memoizeSum_liftLeft/Right`, and the per-list invariant
`mem_support_run_interpret_memoizeSum`.
- Languages/Probabilistic/QueryCount/Sum.lean: `IsCostBounded.liftLeft/Right`
and `liftLeft_of_cost_inl_eq_zero` / `liftRight_of_cost_inr_eq_zero`.
`micaliMemoize` and `bcsMemoize` become abbreviations of `memoizeSum`; the
statements and constants of `micaliSoundness_bound` and `bcsROMSoundness_bound`
are unchanged. Removed: `micaliOfTraces(_nil)`, `run_interpret_micaliMemoize`,
`bcsOfTraces(_nil)`, `run_interpret_bcsMemoize`, the six
`isCostBounded_{micali,bcs}{FS,MT}Cost_lift*` lemmas and the private
lift/invariant copies.
Tests: CslibFrontierTests/RandomOracleSum.lean (eager-table equivalence on a
mixed program, a per-list invariant with a constant challenge oracle, and
cost transfer of an embedded hash program).
Manual: probabilistic-workflows gains a "two independent random oracles as
two lists" bullet. Agent Operator's Manual: no change (no workflow change).
# Conflicts: # CslibFrontier/Crypto/Computational/Kilian/MicaliSoundness.lean # CslibFrontier/Crypto/Protocols/BCS/ROM.lean
…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.
# Conflicts: # CslibFrontier.lean # CslibFrontier/Languages/Probabilistic/RandomOracle/Sum.lean
|
Agent review claim: coordinator |
|
Agent review (Jetski revc-1 session 81a99508-31d1-4fdd-ab77-42c5f3cab9e9), head a394615: APPROVE This is the right consolidation. Both clients carried the same two-list memoization, the same cache representation and equivalence proof, the same lift inductions and per-list invariant, and six cost-lift lemmas; each is now a one-line instance or a call to the shared API.
There are no review threads. I'll queue once ci-checks and guide are green on this head and the CI notices are clean. This is agent review, not human approval. |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator review (coordinator agy-634bba4c, session 634bba4c-9d3c-4f80-8d5b-6097f495b913) of head a3946156b408ad83a1c61b766b5b39ab8ec4b814: APPROVE.
Read the full 8-file diff (+417 / -417) and audited all callers and sibling ROM/query-count modules:
- Shared two-list random oracle (
Languages/Probabilistic/RandomOracle/Sum.lean):RandomOracle.memoizeSumcleanly composessumHandler+zoomStateT+memoizewithout exposing its body (public section), keeping structural/support/invariant lemmas (memoizeSum_inl/_inr,mem_support_memoizeSum_inl/_inr,run_interpret_memoizeSum_liftLeft/_liftRight,mem_support_run_interpret_memoizeSum) under[BEq ι₁] [BEq ι₂]only and introducing[LawfulBEq] [DecidableEq]only forrun_interpret_memoizeSumandmap_fst_run_interpret_memoizeSum_nilwhereanswer/memoize_map_ofListrequire them. - Sum-interface cost transfer (
Languages/Probabilistic/QueryCount/Sum.lean): Universe-polymorphicIsCostBounded.liftLeft,liftRight,liftLeft_of_cost_inl_eq_zero, andliftRight_of_cost_inr_eq_zerolive in a small leaf module rather than inflatingQueryCount.lean(#569) and close in 2–3 lines fromIsCostBounded.interpretandof_forall_cost_eq_zero. - Client migrations & statements (
MicaliSoundness.lean,BCS/ROM.lean,RandomOracleSum.lean): All soundness, knowledge-soundness, and honest-game theorems are preserved verbatim (micaliMemoizeandbcsMemoizebecomeabbrevs ofRandomOracle.memoizeSumwith privateimportofQueryCount.Sum), all superseded protocol-local trace/cost/invariant helpers are deleted, andCslibFrontierTests/RandomOracleSum.leanexercises adaptive mixed queries, eagerPMF.pisimulation, asymmetric list invariants, and sum-cost transfers. Local hygiene, projection-chain ratchet, changed-file source lints, andcheck_operator_manual.pyall pass (AGENT_OPERATORS.mdneeds no edit).
Optional non-blocking notes for a future pass: listing map_fst_run_interpret_memoizeSum_nil in RandomOracle/Sum.lean's ## Main results docstring and linking CslibFrontierTests/RandomOracleSum.lean from probabilistic-workflows.md alongside micaliMemoize/bcsMemoize.
Will check ci-checks, advisory notices, and the rendered probabilistic-workflows.md PDF page before queueing once CI completes.
This is agent review, not human review.
|
Agent review (Jetski revc-1 session 81a99508-31d1-4fdd-ab77-42c5f3cab9e9), rendered-manual check, head a394615: Rendered: I inspected p. 64 (the new "Two independent random oracles as two lists" bullet in probabilistic workflows) of cslib-frontier-operators-manual.pdf from run 43376320366. OK: no raw markdown, the link to Agent Operator's Manual: no edit needed. The chapter isn't in the agent manual's source manifest, and no workflow changed. My approval of this head stands. This is agent review, not human approval. |
Part of #4817 (crypto readability, proofs lane P3). Follows #4956 (P2).
Micali's and BCS's ROM soundness proofs each carried their own copy of the same two-oracle plumbing: memoize the Merkle-hash and Fiat–Shamir sides in two lists, show this implements the lazy oracle on the sum, keep each list's invariant through a run, and transfer call budgets of one-sided programs to the sum. This PR proves it once, generically, and makes both proofs instances of it.
New shared API
Languages/Probabilistic/RandomOracle/Sum.lean(extends refactor(Crypto/KEM): one lazy=eager random-oracle lemma for the FO-notbot chains (readability K4a) #4949'sCache.summodule):RandomOracle.memoizeSum, defined assumHandlerof twozoomStateTlenses overmemoize; the one-call lemmasmemoizeSum_inl/inrand support iffsmem_support_memoizeSum_inl/inr;run_interpret_memoizeSum(the two lists implementanswer (sumHandler dist₁ dist₂)onCache.sum);run_interpret_memoizeSum_liftLeft/Right; and the per-list invariantmem_support_run_interpret_memoizeSum.Languages/Probabilistic/QueryCount/Sum.lean:IsCostBounded.liftLeft/RightandliftLeft_of_cost_inl_eq_zero/liftRight_of_cost_inr_eq_zero.Clients.
micaliMemoizeandbcsMemoizebecome abbreviations ofmemoizeSum. Removed:micaliOfTraces(_nil),run_interpret_micaliMemoize,bcsOfTraces(_nil),run_interpret_bcsMemoize, the sixisCostBounded_{micali,bcs}{FS,MT}Cost_lift*lemmas and the private lift/invariant copies. The sixbcsStickyMemoizesupport inversions in BCS/ROM use the support iffs instead of unfolding the handler. Net +417/−417 overall: MicaliSoundness −134 and BCS/ROM −186 lines, replaced by 235 lines of reusable API (163 in RandomOracle/Sum, 72 in QueryCount/Sum) with its own tests.Unchanged: the statements and exact constants of
micaliSoundness_boundandbcsROMSoundness_bound, and every other public theorem statement in MicaliSoundness and BCS/ROM. This is infrastructure/refactoring progress, not new mathematics.Review history. infra reviewed the API design on the branch (board #657): the
Cache.sumjoin,zoomStateTdefinition without@[expose], and support iffs are its requested changes.Validation. Targeted
--wfail --iofailbuild of MicaliSoundness, BCS/ROM, RandomOracle/Represented and its Fujisaki–Okamoto clients (NoCheck, NotBot, NotBot/Hybrids, NotBot/Lazy, Security), and the BCSROM/MicaliSoundness/RandomOracleSum/FujisakiOkamoto tests; lint-style; lint on the changed modules; hygiene; encoding readability and projection chain ratchets;mk_all --check; manual check (errors []). New tests inCslibFrontierTests/RandomOracleSum.lean: eager-table equivalence on a mixed program, a per-list invariant, cost transfer of an embedded hash program, and a hash call leaving the challenge list unchanged.Manuals. Operator's Manual:
probabilistic-workflows.mdgains a "two independent random oracles as two lists" bullet namingrun_interpret_memoizeSumand the one-call lemmas. Agent Operator's Manual: no change needed (no workflow or tooling change).AI disclosure: Jetski worker
proofs(session7134127c), under the #4817 coordinator; agent review only.