Documentation

CatCryptCore.Deep.OracleGamePackage

Oracle-Exporting Game Packages from Reflected Code #

DeepPackage.ofCode (Deep/GamePackage.lean) packages a closed RawCode Bool as the main export (0, Unit, Bool). This file provides the missing dual: a reusable constructor DeepPackage.ofOracle that turns a shallow oracle implementation impl₀ : dom → RawCode codom into a package that exports a single oracle (op, dom, codom) for other packages to call. Fed through rawCode%, a shallow SPComp oracle becomes an oracle-exporting deep package with no hand-written RawCode, no hand-written impl literal, and no hand-written validity proof.

Main definitions #

Main results #

The oracle-package constructor #

noncomputable def CatCrypt.Deep.DeepPackage.ofOracle {L : Core.LocSet} (op : ) (dom codom : Type) (impl₀ : domRawCode codom) [∀ (x : dom), IsValid L (impl₀ x)] :

The single-export DeepPackage that exports the oracle (op, dom, codom) and implements it by the shallow family impl₀.

It has locations L, no imports, and exactly one export. The impl field matches an incoming request (op', dom', codom') against the singleton export list: membership forces dom' = dom and codom' = codom, and the bundle ValidCodeBundle.auto (impl₀ x) is cast across both type equalities (recall (op, dom, codom) parses as (op, (dom, codom)), so the two equalities are extracted from nested Prod.mk.injEq). Validity is discharged automatically from [∀ x, IsValid L (impl₀ x)].

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem CatCrypt.Deep.evalOp_ofOracle {L : Core.LocSet} (op : ) (dom codom : Type) (impl₀ : domRawCode codom) [∀ (x : dom), IsValid L (impl₀ x)] (x : dom) :
    (DeepPackage.ofOracle op dom codom impl₀).evalOp op dom codom x = (impl₀ x).eval

    Evaluating the exported oracle of DeepPackage.ofOracle recovers the shallow body (impl₀ x).eval: a game oracle's package evaluation is exactly the shallow game body's eval.

    noncomputable def CatCrypt.Deep.NomPackage.ofOracle (op : ) (dom codom : Type) (impl₀ : domRawCode codom) [∀ (x : dom), IsValid (impl₀ x)] :

    The stateless nominal wrapper of DeepPackage.ofOracle: no locations, so the location invariant reduces to ∅ = ∅.image _.

    Equations
    Instances For

      DeepPackage.ofCode c is the op = 0, (dom, codom) = (Unit, Bool) instance of DeepPackage.ofOracle: running it recovers c.eval, so the main-export packaging is a special case of the oracle-export packaging.

      Feeding the constructor from shallow code by reflection #

      A shallow oracle f : dom → SPComp codom becomes an oracle package with no hand-written RawCode: reflect the (inlined) body under the domain binder with rawCode%, which handles the bound variable as a free variable. A bare fun x => rawCode% (f x) referencing a top-level def f does not elaborate — the reifier normalizes to weak-head-normal form under reducible transparency, which leaves f x opaque; inlining f's body exposes the SPComp head.

      A shallow one-bit oracle: XOR the query with a fresh uniform key.

      Equations
      Instances For

        The oracle package for sampleOracle, produced by reflecting the inlined body under the domain binder — no hand-written RawCode, impl literal, or validity proof.

        Equations
        Instances For

          Worked reduction: reflected oracle games vs a forwarding adversary #

          The two closed shallow game bodies are the one-time-pad ciphertext for a fixed message (realRaw) and a fresh uniform bit (idealRaw) — the real/ideal pair of one-time secrecy. Each is reflected into RawCode and packaged as an oracle game exporting (1, Unit, Bool); the adversary forwards the oracle unchanged. The advantage of the whole deep-package/adversary construction collapses, by reflection and linking correctness, to the shallow Advantage of the two bodies — the quantity a bijection coupling bounds.

          Real body: one-time-pad encryption of the fixed message true.

          Equations
          Instances For

            Ideal body: a fresh uniform bit.

            Equations
            Instances For

              Real oracle game, exporting (1, Unit, Bool).

              Equations
              Instances For

                Ideal oracle game, exporting (1, Unit, Bool).

                Equations
                Instances For

                  Forwarding adversary: exports the main procedure (0, Unit, Bool) and implements it by a single oracle call (1, Unit, Bool), returning the result unchanged. Built through the same ofOracle constructor.

                  Equations
                  Instances For

                    Worked reduction. The deep-package advantage of the two reflected oracle games against the forwarding adversary equals the shallow Advantage of the two game bodies — the one-time-secrecy advantage that a bijection coupling bounds.