Documentation

CslibFrontier.Crypto.Primitives.Garbling.CircularCorrelationRobust

Circular correlation robustness #

A tweakable hash H : L → T → M is circular correlation robust when, for a secret offset drawn from a key, the oracle that answers a query (x, t, b) with H (x + Δ) t, plus the output offset Δ' when b is set, looks like a uniform random function. Choi, Katz, Kumaresan and Zhou [CKKZ12] introduced circular correlation robustness to prove the Free-XOR technique of Kolesnikov and Schneider [KS08] secure; Guo, Katz, Wang and Yu [GKWY20] gave the tweakable form, and Zahur, Rosulek and Evans [ZRE15] and Heath, Kolesnikov and Ng [HKN24], Definition 1, use it for half gates and one-hot garbling.

CCR.oracle H Δ Δ' q is that oracle, with the input offset Δ : L and the output offset Δ' : M given separately, and CCR.advantage H δ δ' A is the advantage of A in telling CCR.oracle H (δ k) (δ' k) under a uniform key k from a uniform random function, in the finite PRF game Cslib.Crypto.PRF.advantage. Three Boolean garbling schemes of this library rest on it (the point-and-permute scheme of Cslib.Crypto.Garbling.Privacy rests on PRF security instead):

The input and output offsets live in different groups only for Free-XOR, whose hash ignores the colour bit. Reading that hash on whole labels instead would make the assumption false: the distinct queries ((x, false), t, b) and ((x, true), t, b) would get equal answers, which a uniform random function rarely gives.

[Hea24] Definition 1 assumes Boolean circular correlation robustness (as in [ZRE15]). CCR.Arithmetic is an arithmetic variant novel to this library—used by the per-instance switch-system reduction in Cslib.Crypto.Garbling.Switch—where labels lie in an R-module, the shift is a scalar s : R, and the ideal oracle answers every query with a fresh uniform label. No implication in either direction between CCR.Arithmetic and Boolean CCR.advantage is proved or cited, and CCR.Arithmetic currently defines only a finite NNReal-valued advantage (not a Prop-valued asymptotic assumption). The mixed-modulus assumption of Ball, Malkin and Rosulek [BMR16], Definition 1, has its own dependent query type and lives in Cslib.Crypto.Garbling.MixedModulus.

Main definitions #

Main results #

Implementation notes #

The definition of [GKWY20] only allows adversaries that never ask both (x, t, false) and (x, t, true), whose answers reveal the offset (CCR.oracle_true_sub_oracle_false). Here advantage is defined for every adversary, and the restriction IsTweakUnique is stated as a property of the adversary at hand: the Free-XOR (FreeXOR.isTweakUnique_reduction), half-gates (HalfGates.isTweakUnique_reduction) and one-hot (BinaryToOneHot.isTweakUnique_reduction) reductions ask every tweak at most once. The same holds for the arithmetic variant, whose restriction Arithmetic.IsTweakUnique is likewise formalized.

References #

theorem Cslib.ProbOracleComp.runWith_memoize_map_fst_eq_eval_run {D T R α : Type} [DecidableEq D] [DecidableEq T] (tweak : D → T) (O : D → ProbComp R) {A : ProbOracleComp (fun (x : D) => R) α} (h : ∀ (t : T), OracleComp.IsCostBounded (Sum.elim (fun (x : ℕ) => 0) fun (q : D) => if tweak q = t then 1 else 0) A 1) :
PMF.map Prod.fst (runWith (memoize fun (q : D) => (O q).eval) A []) = (A.run O).eval

If an oracle computation queries each tweak tweak q at most once on every path, lazily memoizing fun q => ProbComp.eval (O q) produces the same output distribution as running A against fresh calls to O.

A query to the circular oracle: a label, a tweak and a bit.

  • label : L

    The label, shifted by the input offset before hashing.

  • tweak : T

    The tweak passed to the hash.

  • bit : Bool

    Whether the answer also gets the output offset.

Instances For
    @[instance_reducible]
    def Cslib.Crypto.Garbling.CCR.instDecidableEqQuery.decEq {L✝ T✝ : Type} [DecidableEq L✝] [DecidableEq T✝] (x✝ x✝¹ : Query L✝ T✝) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]
    instance Cslib.Crypto.Garbling.CCR.instFintypeQuery {L✝ T✝ : Type} [Fintype L✝] [Fintype T✝] :
    Fintype (Query L✝ T✝)
    @[reducible, inline]

    Adversaries against circular correlation robustness: oracle algorithms with private coins that ask queries of a label, a tweak and a bit, get answers in M, and output a guess.

    The global offset Δ = (R, true) of the half-gates instance, of colour true: the colour plays the role of the least significant bit, which [ZRE15] fixes to 1 (R ∈ {0, 1}^(k - 1) 1 in Definition 1).

    def Cslib.Crypto.Garbling.CCR.oracle {L T M : Type} [AddCommGroup L] [AddCommGroup M] (H : L → T → M) (Δ : L) (Δ' : M) (q : Query L T) :
    M

    The circular oracle under the input offset Δ and the output offset Δ': the query (x, t, b) gets H (x + Δ) t, plus Δ' when b is set.

    @[simp]
    theorem Cslib.Crypto.Garbling.CCR.oracle_apply {L T M : Type} [AddCommGroup L] [AddCommGroup M] (H : L → T → M) (Δ : L) (Δ' : M) (x : L) (t : T) (b : Bool) :
    oracle H Δ Δ' { label := x, tweak := t, bit := b } = H (x + Δ) t + bitOffset Δ' b
    theorem Cslib.Crypto.Garbling.CCR.oracle_true_sub_oracle_false {L T M : Type} [AddCommGroup L] [AddCommGroup M] (H : L → T → M) (Δ : L) (Δ' : M) (x : L) (t : T) :
    oracle H Δ Δ' { label := x, tweak := t, bit := true } - oracle H Δ Δ' { label := x, tweak := t, bit := false } = Δ'

    The answers to (x, t, true) and (x, t, false) differ by the output offset, so an adversary that asks both learns it.

    def Cslib.Crypto.Garbling.CCR.keyed {L T M Key : Type} [AddCommGroup L] [AddCommGroup M] (H : L → T → M) (δ : Key → L) (δ' : Key → M) (k : Key) :
    Query L T → M

    The keyed circular oracle: the key k selects the input offset δ k and the output offset δ' k.

    noncomputable def Cslib.Crypto.Garbling.CCR.advantage {L T M Key : Type} [AddCommGroup L] [AddCommGroup M] [Fintype Key] [Nonempty Key] [Fintype L] [DecidableEq L] [Fintype T] [DecidableEq T] [Fintype M] [Nonempty M] (H : L → T → M) (δ : Key → L) (δ' : Key → M) (A : Adversary L T M) :

    The circular correlation robustness advantage of A against H with offsets δ and δ': its advantage in telling the keyed circular oracle under a uniform key from a uniform random function.

    The adversary never repeats a tweak: on every path it makes at most one query with each tweak t. In particular, it never queries both (x, t, false) and (x, t, true).

    theorem Cslib.Crypto.Garbling.CCR.IsTweakUnique.transcript_tweak_le_one {L T M : Type} [DecidableEq T] {A : Adversary L T M} (h : IsTweakUnique A) {State : Type} (oracle : Query L T → StateT State PMF M) {s s' : State} {result : Bool} {transcript : OracleComp.Transcript fun (x : Query L T) => M} (hmem : (result, s', transcript) ∈ (ProbOracleComp.runWith (OracleComp.withTranscript oracle) A (s, [])).support) (t : T) :
    (List.map (fun (entry : (q : Query L T) × (fun (x : Query L T) => M) q) => if entry.fst.tweak = t then 1 else 0) transcript).sum ≤ 1

    Against every stateful oracle, a tweak-unique adversary records at most one query with each tweak t on every supported execution.

    noncomputable def Cslib.Crypto.Garbling.CCR.idealFreshGame {L T M : Type} [Fintype M] [Nonempty M] (A : Adversary L T M) :

    The fresh-uniform ideal experiment: answer every query with an independent uniform draw from M.

    For a tweak-unique adversary, answering every query with a fresh uniform draw from M (idealFreshGame) has the same output law as a uniform random function (PRF.idealExperiment).

    Library construction (no cited definition): embedding of key-only queries into full-label queries via colour bit true.

    def Cslib.Crypto.Garbling.CCR.keyOnlyHandler {L T M : Type} (q : Query L T) :
    ProbOracleComp (fun (x : Query (L × Bool) T) => M) M

    Library construction (no cited definition): lift a key-only CCR query to a full-label CCR query via keyOnlyEmbed, so that adding the offset (R, true) cancels the colour bit to false.

    theorem Cslib.Crypto.Garbling.CCR.advantage_keyOnly {L T M Key : Type} [AddCommGroup L] [AddCommGroup M] [Fintype Key] [Nonempty Key] [Fintype L] [DecidableEq L] [Fintype T] [DecidableEq T] [Fintype M] [Nonempty M] (H : L × Bool → T → M) (δ : Key → L) (δ' : Key → M) (A : Adversary L T M) :
    advantage (fun (x : L) (t : T) => H (x, false) t) δ δ' A = advantage H (fun (r : Key) => (δ r, true)) δ' (ProbOracleComp.simulate keyOnlyHandler A)

    Library infrastructure (no cited result): Key-only CCR advantage transfer. For any key-only adversary A against fun x t => H (x, false) t with input offset δ and output offset δ', lifting its queries via keyOnlyHandler preserves its CCR advantage against H with input offset fun r => (δ r, true) and output offset δ'.

    The arithmetic variant #

    A query to the arithmetic circular oracle: a label, a tweak and a scalar shift.

    • label : L

      The label, shifted by minus the offset before hashing.

    • tweak : ℕ

      The tweak passed to the hash.

    • shift : R

      The multiple of the offset added to the answer.

    @[instance_reducible]
    def Cslib.Crypto.Garbling.CCR.Arithmetic.instDecidableEqQuery.decEq {L✝ R✝ : Type} [DecidableEq L✝] [DecidableEq R✝] (x✝ x✝¹ : Query L✝ R✝) :
    Decidable (x✝ = x✝¹)
    def Cslib.Crypto.Garbling.CCR.Arithmetic.oracle {L : Type} [AddCommGroup L] {R : Type} [CommRing R] [Module R L] (H : L → ℕ → L) (Δ : L) (q : Query L R) :
    L

    The oracle keyed by the offset Δ: the query (k, t, s) gets H (k - Δ) t + s • Δ.

    @[simp]
    theorem Cslib.Crypto.Garbling.CCR.Arithmetic.oracle_apply {L : Type} [AddCommGroup L] {R : Type} [CommRing R] [Module R L] (H : L → ℕ → L) (Δ k : L) (t : ℕ) (s : R) :
    oracle H Δ { label := k, tweak := t, shift := s } = H (k - Δ) t + s • Δ
    @[reducible, inline]

    An arithmetic CCR adversary: a test with private coins and oracle access to queries (k, t, s).

    noncomputable def Cslib.Crypto.Garbling.CCR.Arithmetic.realGame {L : Type} [AddCommGroup L] {R : Type} [CommRing R] [Module R L] (H : L → ℕ → L) (col : L →+ ZMod 2) [Fintype L] [Nonempty { Δ : L // col Δ = 1 }] (adversary : Adversary R L) :

    The keyed experiment: the law of the PRF real experiment keyed by a uniform offset of colour 1, answering with oracle.

    noncomputable def Cslib.Crypto.Garbling.CCR.Arithmetic.idealGame {L : Type} [AddCommGroup L] {R : Type} [Fintype L] (adversary : Adversary R L) :

    The ideal experiment: answer every query with a fresh uniform label.

    @[reducible, inline]
    noncomputable abbrev Cslib.Crypto.Garbling.CCR.Arithmetic.advantage {L : Type} [AddCommGroup L] {R : Type} [CommRing R] [Module R L] (H : L → ℕ → L) (col : L →+ ZMod 2) [Fintype L] [Nonempty { Δ : L // col Δ = 1 }] (adversary : Adversary R L) :

    The arithmetic CCR advantage of adversary against H. The assumption that it is small is meant only for adversaries that never repeat a tweak (IsTweakUnique): repeating a query distinguishes the fresh oracle from the keyed one.

    The adversary never repeats a tweak: on every path it makes at most one query with each tweak t.

    For a tweak-unique adversary, answering every query with a fresh uniform label (idealGame) has the same output law as lazily memoizing a uniform random function on Query L R.