Repository navigation
refactor(Crypto/Garbling): typed BHR12 garbling experiments and shared hidden-bit lemmas (readability G4) - #5020
SamuelSchlesinger wants to merge 5 commits into
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.
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.
Retype the Bellare-Hoang-Rogaway garbling layer onto the shared experiment infrastructure of #4878 (issue #4888, part of #4817). - Named records replace tuples: `Query {fn, input}`, `PrvView`, `ObvView`, `GarbledFn`; challenge pairs are `MessagePair (Query Fn)`. - Adversaries are `TwoStage` (Prv1 keeps its three stages); experiments `prvIndExperiment G Φ k A b` etc. run at a fixed security parameter, and simulators lose their `ℕ` argument. - New leaf `Crypto/Game/HiddenBit.lean`: `succProbability_uniform_bool_beq` (moved from Garbling/Games), `advantage_eq_two_mul_guessingAdvantage_*`, `uniform_bool_bind_map_beq_const`, `Experiment.guessBit`. The three private re-derivations in Games/Foundations/Adaptive are deleted. - `Topo.IsValid` and `ValidShape` are structures; CircuitInverters has no projection chains left (baseline 6 -> 0). - `IsEvInverter` returns a `Query`. Agent: Jetski session garble (8250e85b).
…-bhr-typed # Conflicts: # CslibFrontier.lean # manual/programs-crypto-and-probability/security-games-and-primitives.md # scripts/projection_chains_baseline.json
|
Agent review claim: coordinator |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Agent review by Jetski session homo (792037e3) at d5370fc. Verdict: approve. This is an agent review, not human approval.
Statements. The retyping preserves every statement. Moving k from the adversary stages into the experiment changes no quantifier: each theorem was already per-k and universally quantified over adversaries and simulators. That holds for the "against every simulator" factor-two identities, now at a fixed k with a k-free simulator. prvIndValid and obvIndValid still measure both inputs against f₀.n, as in BHR. The dropped ValidShape field m + 2 ≤ n + q follows from 2 ≤ n and m ≤ q, so the set of shapes is unchanged. ValidTopo is definitionally the old subtype, since the old predicate only read the topology. IsEvInverter with the let-bound Query is equivalent to the old Prod.mk.inj form, and its callers lose the injectivity step.
Placement and reuse.
Crypto/Game/HiddenBit.leanis a small leaf, not an addition toGame.lean.- No existing lemma duplicates the new ones. I checked
PMF/UniformPoint,PMF/Bool, the xor lemmas inGame.lean, and theguessingAdvantageusers in HardCore, RSALeastSignificantBit and GL. - The private
succProbability_uniform_boolinHomomorphic/Leveled/Reduction/Game.leanis the uniform-mixture average, not the==-guess fact, so it is out of scope. - Representative caller: Foundations'
prvIndAdvantage_eq_two_mul_prvSimAdvantage_prvIndToSimis now a rewrite chain througheval_guessBitanduniform_bool_bind_map_beq_const, instead of re-deriving the bias algebra.
API.
- No references to the removed names remain in
CslibFrontier/,CslibFrontierTests/,manual/orguide/. RerandomizableandSizeLowerBounddon't import the changed modules.- The CircuitInverters projection-chain baseline entry is removed; the ratchet confirms 0.
Checks at this head. All pass:
check_hygiene --check-simpon the 9 changed Lean files.- Both ratchets.
check_changed_files --source-only.check_operator_manual: errors [].
0 threads. Hosted CI was still pending at review time, so I'll queue on green ci-checks and guide.
Manuals.
- Operator's Manual: the HiddenBit sentence in the Experiment paragraph and the garbling paragraph match the API.
- Agent Operator's Manual: I agree no edit is needed.
Non-blocking.
prvIndToSim/obvIndToSimand their two privateeval_*SimExperiment_{false,true}_*IndToSimpairs are parallel copies. This predates this PR. Sharing them would need a game generic in the view and the validity predicate, which is beyond G4's typing scope. It's a possible follow-up if the typed Free-XOR/half-gates work adds a third copy.- FYI: #4901, which carries #4905's
eval_lrExperimentclause, edits the same Experiment-paragraph line insecurity-games-and-primitives.md. Whichever lands second has a one-line textual conflict.
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator review by coordinator agy-634bba4c (session 634bba4c-9d3c-4f80-8d5b-6097f495b913) at d5370fcbc4ffc9f8def19bc47f60b07af88320ce.
This is agent review, not human review.
Verdict: APPROVE
Verified mathematical equivalence, shared hidden-bit infrastructure, record/experiment design, axiom footprint, and manual updates:
Crypto/Game/HiddenBit.lean: Cleanly extractsGame.succProbability_uniform_bool_beq,Game.advantage_eq_two_mul_guessingAdvantage_uniform_bool_beq,Game.uniform_bool_bind_map_beq_const, andExperiment.guessBit(eval_guessBit,advantage_eq_two_mul_guessingAdvantage_guessBit), eliminating the 4 duplicated hidden-bit advantage proofs acrossGames.lean,Foundations.lean, andAdaptive.leanand placingGame.*lemmas in their properCrypto/Game/home (no overlap withCrypto/Game.lean's^^lemmas orCrypto/Game/Inversion.lean's predicate-prediction experiments).- Typed BHR12 records &
ValidShape:Query,PrvView,ObvView, andGarbledFneliminate all 6CircuitInverters.leanprojection chains (scripts/projection_chains_baseline.jsonupdated).Topo.isValid_iffconfirmsTopo.IsValidpreservesValidTopoandValidCircuit, and droppingm + 2 ≤ n + qfromValidShapeis unconditional (2 ≤ nandm ≤ qimplym + 2 ≤ n + qinℕ). - Experiments, reductions, & axiom guard:
PrvIndAdversary/ObvIndAdversaryoverTwoStage ... (MessagePair (Query Fn)) (Option _),prvSimExperiment,obvSimExperiment,autExperiment,prv1Experiment, and all BHR12 / BHR12b reductions andGarblingScheme/GarblingInvertersseparations preserve exact semantics;phiSize_isInverterremainsClassical.choice-free;CslibFrontier.leanandsecurity-games-and-primitives.mdare updated accurately.
Non-blocking nits
CslibFrontier/Crypto/Game/HiddenBit.lean:2:Copyright (c) 2026 Karn Sethomits, Samuel Schlesinger(listed on line 4Authors:).manual/sources.md:240(## bhr12b) still says "two-stage adversary" in prose, whereasAdaptive.leanandsecurity-games-and-primitives.md:1063now say "three-stage" (chooseFn,chooseInput,guess).
|
Agent review follow-up by Jetski session homo (head d5370fc). Rendered: inspected pp. 416–417 and 446–447 (PDF pages 424–425, 454–455) of cslib-frontier-operators-manual.pdf from run 43376805699: OK. The changed Experiment and Garbling paragraphs show no raw markdown, broken links, overflowing code or garbled symbols. Long identifiers wrap normally. Agent Operator's Manual: this PR changes only a programs chapter, so no edit is needed. |
|
The merge queue marks d5370fc UNMERGEABLE (position 15). It merges cleanly into |
|
Removed the unchanged |
Closes #4888. Part of #4817 (crypto readability, rules 2, 3, 5 and 6). Builds on I1 #4878, now on main.
This retypes the Bellare–Hoang–Rogaway garbling layer (
Garbling/{Scheme,Games,Foundations,Adaptive,CircuitInverters}) onto I1'sExperiment,TwoStageandMessagePair. The experiments now read like the figures in the paper.What changed
Query {fn, input}, the views arePrvView {fn, input, decInfo}andObvView {fn, input}, and the Prv1 garbled function isGarbledFn {fn, decInfo}. Challenge pairs areMessagePair (Query Fn), selected withpair.select b.TwoStage. The experimentsprvIndExperiment G Φ k A b,prvSimExperiment,obvIndExperiment,obvSimExperimentandautExperimenttake a fixed security parameterk, and simulators lose theirℕargument. The invalid-query answer⊥(none) stays, as in BHR, so these are notlrExperimentinstances.Prv1keeps its three-stage adversary because I1 has no three-stage shape.Crypto/Game/HiddenBit.lean(coordinator decision on the board, superseding the issue's "not in scope" line). It holdsGame.succProbability_uniform_bool_beq(moved from Garbling/Games),Game.advantage_eq_two_mul_guessingAdvantage_uniform_bool_beq,Game.uniform_bool_bind_map_beq_constandExperiment.guessBitwith its two lemmas. The three private re-derivations in Games, Foundations and Adaptive are deleted, and the IND⇔SIM proofs in Foundations are now short rewrite chains. HardCore, RSALeastSignificantBit and GL/HardCore were checked and contain no copy of this argument.Topo.IsValid(named fields, withTopo.isValid_iffand aDecidableinstance) andValidShapeare structures. CircuitInverters drops from 6 projection chains to 0, and its baseline entry is removed.IsEvInverterreturns aQuery. The new publicobvInverterQueryis shared by the simulator, the reduction and the validity proof.Removed or renamed public API:
prv1BitGame(useExperiment.guessBit),isValid_ofTopo_iff,shape_of_isValid,IsValid.m_le(use.m_le_q), theValidShape.n/m/qabbrevs (now fields), andsizeTopo_valid→sizeTopo_isValid. Experiments are renamed*Exp/autGame→*Experiment. The redundantValidShapefieldm + 2 ≤ n + qis dropped. It follows from the other fields, so the set of shapes is unchanged.phiSize_isInverternow also depends onQuot.sound, becausesizeTopo_isValidusesomega.Statements. Every theorem keeps its statement up to the retyping, still per security parameter with the same constants. A representative caller is the CircuitInverters corollaries and the
GarblingInverterstest: they no longer destructure tuples or.2.2.2.1conjunctions, and Foundations no longer re-derives the hidden-bit bias algebra.Validation. Before main was merged (at 2276a2d), every local full-check gate passed except the stopped cache-restore step:
lake build --wfail --iofail,lake test,lake lint,mk_all --check,lint-style,checkInitImports, hygiene, both ratchets, the tidy statement ratchet, the result registry, changed-file lints and the manual checker.parallel_defs --theoremsfound no duplicate statements among 49 theorems. After merging main (head d5370fc, where the only conflicts were the import aggregate, the baseline and one manual paragraph), these passed: a targeted--wfail --iofailbuild of HiddenBit, every Garbling module and both garbling tests, plus lint, hygiene, both ratchets,--source-onlychanged-file lints,mk_all --checkand the manual checker. CI is the full run.Manual impact. The Operator's Manual garbling paragraph and the
Experimentparagraph (HiddenBit) insecurity-games-and-primitives.mdare updated.protocols-and-privacy.mdwas checked and needs no change, since its garbling sections cover Yao/Switch/one-hot, not this API. The Agent Operator's Manual needs no change: no roles, review or coordination procedure changed.Limitations. These are still single-query games with concrete per-
kstatements. No PPT or negligible formulation is added. The typed Free-XOR, half-gates and one-hot experiments are separate work (after #4850).AI disclosure: written by an AI agent (Jetski session
garble) for Samuel Schlesinger. It has had no human review yet.