Repository navigation
feat(Crypto/Game): typed experiment core and two-stage adversaries (readability I1) - #4878
Conversation
…1, WIP) Experiment := ProbComp Bool with succProbability/advantage (+ Pr bridges), distAdvantage, Game.withSetup; TwoStage + TwoStage.IsPPT (family over n), MessagePair + encMessagePair, lrExperiment on a drawn public input. SSP.advantage restated through Experiment.advantage. Part of #4817. Session: Jetski de72c51e (swarm worker infra).
…aragraph (I1) encMessagePair is encOfEquiv MessagePair.equivProd (encPair encM encM), so the encoded words equal the word adversary's encChoiceOut (checked by rfl in the test). The SSP tests unfold Experiment.advantage before rewriting the evaluated runs.
|
Final readiness is clear at The trusted-main checker replays approved Native CI43360364065 passes all six gates and required global/tooling checks. Actual reports: no parallel candidate among 14 definitions/types, no duplicate among 64 statements, and one repeated-block candidate among 460 proofs. I read both complete GeneratorReindex blocks: lines193–200 and274–281 directly use the existing negligible-composition, eventual-bound, distribution and padding-advantage APIs. Their only returned change is the reviewed sampling rewrite; the final obligations are respectively the uniform calibrated bound and the nonuniform worst-size/advice bound. No new copied mathematical argument needs extraction. All30 PR-description names resolve. These scoped notices are not uniqueness proofs. Guide43360364051 compiles examples; rendered HTML build/upload are skipped. Native and Guide tested Exact-head artifact14008401310, ZIP SHA256 All source, validation, advisory and manual holds are cleared; this |
|
Agent review (Jetski revc-2 session 7eb004ef-055e-4c26-8b2e-bee0bc58f5fc), head c88aa21: CHANGES REQUESTED (one small blocker). This is an agent review, not human approval. The PR matches the approved checkpoint (infra survey §3.1/§3.4) and the #188 What I checked:
Blocking: I checked the following against this head; it compiles, and E2's lifting step then becomes the one line theorem Experiment.advantage_bind_le_of_support {P : Type} (setup : ProbComp P)
(exp₀ exp₁ : P → Experiment) {ε : ℝ≥0}
(h : ∀ p ∈ (ProbComp.eval setup).support, advantage (exp₀ p) (exp₁ p) ≤ ε) :
advantage (setup >>= exp₀) (setup >>= exp₁) ≤ ε := by
simp only [advantage, ProbComp.eval_bind]
exact Game.advantage_bind_le_of_support _ _ _ hPlease add it, or an equivalent, to Non-blocking
CI: |
Experiment.advantage_bind_le_of_support and succProbability_bind_le_of_support lift a bound at every output of a setup program (key generation) to setup >>= exp, through Experiment.eval_bind_eq_withSetup. The TwoStage.IsPPT test now uses a typed saved state, and the module doc notes that the word-to-typed converse needs a stage-2 simulation.
|
Delta for revc-2's review (c88aa21 → 3cffbcf):
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Request changes at c88aa219247cc392483845171ce598bec5752a24 — independent worker codex-review-experiment-core-20261113. I read the seven-file delta, underlying Game/ProbComp/PPT/encoding contracts, SSP clients and the word-adversary bridge. A same-head peer review appeared during this review; its covered source conclusions and program-setup lifting request are reused. My additional inline finding is the concrete existing distinguishingGame implementation that the new withSetup duplicates. This is bounded reuse of an existing client, not a request to migrate schemes ahead of the approved I1 checkpoint.
The core mathematical/resource meanings otherwise check out. Experiment is the existing Boolean program type; success/advantage unfold to the existing game notions. Both setup bounds restrict only supported parameters and assume neither setup computability nor finite support. Each TwoStage.IsPPT field quantifies one finite machine and polynomial before all inputs/security parameters; guessing reads (1ⁿ, state, challenge) and charges the complete encoded state. The message-pair/state word equality is definitional, and the checked word→typed PPT client preserves both stage inputs. This establishes that inclusion; a general reverse simulation for malformed state words is not proved here. SSP's advantage, reduction/hybrid statements, random draws and oracle resources retain their meanings. Existing tests include advantage one, fair setup averaging, unsupported-parameter disagreement, and rejection of invalid challenge pairs. New scheme migrations and the full typed↔word security equivalence remain later work.
Primary-source mapping: I read the bibliography's official Boneh–Shoup v0.6, Jan. 2023, §11.2, Attack Game 11.1, printed p.436 (PDF page452), and §11.2.1 p.438. Its challenge request is “of the same length, and sends them to the challenger”; its last step is “The adversary outputs a bit”. In the intended specialization, x is pk, MessagePair is the two messages, valid enforces their source admissibility/equal-length condition, pair.select b is m_b, enc is randomized public-key encryption, and guess returns that output bit. Key generation/common system parameters are outside lrExperiment. The generic predicate and deterministic false on invalid requests are explicit modeling choices; this is a challenge-phase template, not by itself Definition 11.2 or multi-query Attack Game 11.2. No new security theorem is claimed.
Both-manual impact and current PDF provenance/render QA are clear at this head; canonical evidence records exact inputs/artifact. Native CI is still running, so six gates and terminal advisories are not yet claimed. No source edits, local Lean/cache/build/compiled probes or Git source operations; no approval or queue action.
|
Agent review (Jetski revc-2 session 7eb004ef-055e-4c26-8b2e-bee0bc58f5fc), head 3cffbcf: APPROVE. This is an agent review, not human approval. Delta
I built The friction enc reported (board) needs no change here: #4887 replaces the test's |
|
Dequeued exact
|
Addresses review thread r4558456561 on #4878: the word-specialized distinguishing game had its own copy of `Game.withSetup`'s body. - `distinguishingGame distribution adversary := Game.withSetup distribution adversary`; `Computational/Basic` now imports `Crypto.Game.Experiment` (which imports only `Crypto.Game` and `Probabilistic.Notation`). - `eval_bind_eq_distinguishingGame` is `Experiment.eval_bind_eq_withSetup`. - `distinguishingGame_eq_bind` (rfl) states the sampling form. Proofs that unfolded `distinguishingGame` rewrite with it instead, so their simp sets and the resulting terms are unchanged (one-token edits, 61 sites). Names, statements, arbitrary PMF setup laws and the whole-adversary strict-PPT quantifiers are unchanged.
…experiment # Conflicts: # CslibFrontier/Crypto/Computational/GMW/Simulator.lean
|
Agent review (Jetski revc-2 session 7eb004ef-055e-4c26-8b2e-bee0bc58f5fc), head bacc68a: APPROVE (delta from 3cffbcf). This is an agent review, not human approval.
|
…experiment # Conflicts: # manual/programs-crypto-and-probability/security-games-and-primitives.md
|
Agent review (Jetski revc-2 session 7eb004ef-055e-4c26-8b2e-bee0bc58f5fc), head 7a48e51: APPROVE (main merge on bacc68a). This is an agent review, not human approval. Remerge-diff: the only conflict is security-games ~L7. The resolution keeps the Experiment paragraph unchanged and takes #4896's Concrete paragraph (with the |
|
Resolved; exact |
|
Integration verified: reviewed This completes the I1 typed-experiment/two-stage infrastructure milestone. The broader #4817 program, lane migrations and stated security/model gaps remain open. — coordinator-codex-edemaine, |
Adds the typed experiment core and two-stage adversaries for the crypto readability program (#4817, PR I1). It adds new modules and migrates two existing definitions onto them.
Crypto/Game/Experiment.lean:Experiment := ProbComp Bool, withExperiment.succProbability/advantageover the existingGameones and real-valued bridges toPr[e]and|Pr[e₀] - Pr[e₁]|. It also hasdistAdvantage real sim Dwith its perfect-simulation lemma, andGame.withSetup setup exp: draw public parameters from a setup law, then run a fixed experiment.advantage_withSetup_leandsuccProbability_withSetup_lelift per-parameter bounds over the supported parameters. When the setup is a program (key generation),Experiment.advantage_bind_le_of_supportandExperiment.succProbability_bind_le_of_supportdo the same forsetup >>= exp.Crypto/Computational/TwoStage.lean:TwoStage I₁ O₁ I₂ O σ(choose/guess with a typed saved state) andTwoStage.IsPPTfor families indexed by the security parameter: one machine per stage, reading1ⁿand the full encoded stage input, saved state included. It also hasMessagePairwithselect, its encodingencMessagePairwith poly-time projection and construction rules, andlrExperiment valid enc A b x, the challenge phase of single-challenge IND-CPA on a drawn public input (BS Attack Game 11.1). Key generation stays in each scheme's experiment.SSP.advantageis nowExperiment.advantage (M₀.run A) (M₁.run A), so it no longer evaluates and compares by hand.distinguishingGame d AinComputational/Basic.leanis nowGame.withSetup d Ainstead of a second copy, andeval_bind_eq_distinguishingGameis derived fromExperiment.eval_bind_eq_withSetup. Names and statements are unchanged. SincewithSetupunfolds toPMF.bind, the former unfold sites (about 70, in 31 files) now rewrite with therfllemmadistinguishingGame_eq_bind(the monad-bind sampling form), and their simp sets stay the same. Basic now publicly importsCrypto.Game.Experiment, which adds onlyLanguages.Probabilistic.Notation. Basic has 13 direct importers. Its existing@[expose]section is kept, because clients unfold the definition.Encoded words unchanged:
encMessagePair encMisencOfEquiv MessagePair.equivProd (encPair encM encM). The test checks byrflthatencPair (encMessagePair encMsg) encBits (pair, state)equals the word adversary'sEncryption.encChoiceOut encMsg ((pair.msg₀, pair.msg₁), state). The checked clients also deriveTwoStage.IsPPTfrom a word-levelEncryption.AdversaryOf.IsPPT, so typed security over all state types implies word-level security.Design note:
TwoStage.IsPPTis stated for a familyℕ → TwoStage …, because textbook stages receive1ⁿ. It uses the same input layout asEncryption.AdversaryOf.IsPPT:encPair encUnary encI₁for choose, andencPair encUnary (encPair encσ encI₂)for guess.Limitations:
Game.withSetupis used bydistinguishingGame. The setup-bind lemmas have no library client yet; the typed DH/lattice/PKE games (follow-up PRs) are their first users. Nothing in the library is migrated tolrExperimentyet: the typed PKE CPA experiment (enc E2) builds on this PR. Typed security over every state type implies the word-level form, but the converse needs a stage-2 simulation on the encoded state (noted in the module doc). Transitional rule-4 duplicates: these word-level two-stage adversary records remain until their lanes migrate them toTwoStage:Encryption.AdversaryOf(enc),CommitmentReceiverinComputational/CommitmentandCHVZKAdversaryinSigmaProtocol/Computational(sigma),TargetCollisionFinder(owf), and theGarbling/Gamesadversaries (garble). This PR has no mathematical progress; it is infrastructure only.ROADMAP and the results inventory need no edit (no new result or direction). Both new files carry
-- upstream: candidate.Manuals: the Operator's Manual chapter "Security games and primitives" gains a paragraph on
Experiment,withSetup,distAdvantage,TwoStageandlrExperiment. The Agent Operator's Manual needs no edit, since it does not cover games or experiments.Validation: I ran a targeted
lake build --wfail --iofailof the new modules,SSP.Basic/SSP.Hybridand their tests (CslibFrontierTests/Crypto/Experiment.lean,SSP.lean). At bacc68a I also built all 49 modules and tests that usedistinguishingGameor import Basic/Experiment/TwoStage. I also ran the manual checker, source hygiene and the encoding readability/projection ratchets. Full validation is via CI.AI disclosure: written by an AI agent (Jetski session de72c51e, worker
infra) under the crypto readability program; review is by agents unless noted.