Reflection → Package → UC: shared lift helpers #
Examples/OneTimePad.lean lifts a shallow perfect-security result to a
composable statement about deep nominal packages, following the stack
shallow game → rawCode% → NomPackage.ofOracle → DeepNomAdvantage → sdist → UC.
This file extracts the reusable boilerplate of that lift so each perfect-security
example reduces to: reflect the two game bodies, prove their evaluations coincide,
and instantiate the ofOracle combinators below.
Main results #
spcomp_eq_of_isPure_coupling— for twoIsPurecomputations, an empty-heap perfect coupling (rHoare eqPre _ _ eqPost) upgrades to fullSPCompequality. This is what turns an existing shallow coupling into the.evalequality theofOraclecombinators consume, with no purity bridge on the adversary.AdvantageA_pure—AdvantageA g₀ g₁ SPComp.pure = Advantage g₀ g₁.UCEmulates_of_boolGame_sdist— fromsdist g₀ g₁ ≤ εon twoSPComp Boolgame families, concludeUCEmulates εover the trivial-leak spec via theSum.inl : Bool → Bool ⊕ Emptywrapper.evalOp_singleton_congr— dischargesrunPkg_link_congr's per-op obligation for a single-oracleofOraclepackage.runPkg_link_ofOracle_congr— linked runs coincide against every adversary when the two oracle bodies have equal evaluations.deepNomAdvantage_ofOracle_zero,sdist_ofOracle_zero,nomPkgSecure_ofOracle,uc_ofOracle— the full perfect stack, each a one-line consequence of body.evalequality.
From a pure coupling to SPComp equality #
For two heap-independent (IsPure) computations, an empty-heap perfect
coupling rHoare eqPre G₀ G₁ eqPost upgrades to full SPComp equality
G₀ = G₁. The coupling fixes the empty-heap distributions; purity extends
that agreement to every heap via push_inj.
This is the bridge that lets a shallow perfect-security coupling feed the
ofOracle combinators below without any IsPure/NoFail post-processing
hypothesis on the adversary.
Advantage / UC packaging #
The identity distinguisher is a no-op: AdvantageA g₀ g₁ pure = Advantage g₀ g₁.
From a statistical-distance bound on two SPComp Bool game families, conclude
UCEmulates over the trivial-leak interface (out = Bool, leak = Empty),
wrapping each output through Sum.inl : Bool → Bool ⊕ Empty. Post-composition
with the pure injection Sum.inl is non-expansive (sdist_comp_right), so the
wrapped distance is still ≤ ε and UCEmulates_of_sdist (identity simulator)
applies.
The ofOracle perfect stack #
The remaining combinators take two single-oracle ofOracle packages whose oracle
bodies have equal evaluations and derive the full package-level perfect-security
stack. Feed each with the .eval equality of the reflected game bodies (obtained,
for a shallow perfect coupling, via spcomp_eq_of_isPure_coupling).
Discharges runPkg_link_congr's per-op obligation for two ofOracle packages
that export the same single oracle (op, dom, codom): singleton membership
forces the queried operation to be that oracle, whereupon evalOp_ofOracle
reduces both sides to the reflected bodies, equal by hypothesis.
Linking any adversary package A with either of two ofOracle games produces
the same SPComp Bool, when the two oracle bodies have equal evaluations.
The single per-op obligation of runPkg_link_congr is evalOp_singleton_congr;
the interfaces agree by rfl.
Zero deep-nominal advantage against every adversary package: the reflected real/ideal games are perfectly indistinguishable in the deep package model.
Statistical distance zero between the two linked-game families. Since the
linked runs coincide against every adversary, the two functions are equal, and
sdist_self collapses the distance — no purity bridge on the adversary.
Package-level perfect security (NomPkgSecure): the reflected games emulate
each other with zero adversary-dependent error.
Perfect UC emulation of the linked-game families over the trivial-leak
interface (out = Bool, leak = Empty): the identity simulator suffices
because the linked runs coincide (sdist_ofOracle_zero).