Documentation

CslibFrontier.Crypto.Computational.KeyDerivation

Key-derivation security game #

[BS23], Section 11.5.2 (Attack Game 11.3, p. 448, and Definition 11.5, p. 449) defines key-derivation security for a function F : X × Y → Z by comparing (x, F(x, y)) against (x, z) for independent uniform x, y, and z. Section 8.10.1 (pp. 325–326) states the general form: for a secret s drawn from a distribution P, public side information I(s), and derived key H(s), the pairs (I(s), H(s)) and (I(s), t) with an independent key t are computationally indistinguishable.

This module formalizes the game in the generality of Section 8.10.1, with the following choices relative to the printed definitions:

  1. One game in the Section 8.10.1 form (sample, info, derive). Attack Game 11.3 as printed is the instance where sample n draws independent uniform (x, y) ∈ X × Y, info = Prod.fst, and derive = F. The group-specialized notion PrimeOrderGroupFamily.SecureKDF (where the group description is sampled first and the key law depends on the security parameter) is an instance via PrimeOrderGroupFamily.secureKDF_iff_keyDerivation.
  2. Arbitrary secret and ideal key laws sample : ℕ → PMF S and key : ℕ → PMF Z in place of efficient samplers or fixed uniform finite-type distributions, and arbitrary info and derive with no computability or finiteness hypotheses, so Z needs no Fintype instance and both BitString.uniformList (msgLen n) and PMF.uniformOfFintype Z are instances.
  3. One-parameter outputs parameterized by the distinguisher's output law X → Z → PMF Bool (realOutput, idealOutput, advantage), so both program distinguishers (ProbComp.eval) and oracle distinguishers interpreted against a fixed table are instances.
  4. Equivalence of typed and word-ensemble presentations: Secure is Game.Indistinguishable against typed uniform strict PPT distinguishers (Distinguisher.IsPPT encX encZ), and secure_iff_computationallyIndistinguishable proves it equivalent to ComputationallyIndistinguishable (Definition 3.4) of the encoded word ensembles realEnsemble and idealEnsemble.

Main definitions #

Main results #

References #

One parameter #

noncomputable def Cslib.Crypto.KeyDerivation.realOutput {S X Z : Type} (sample : PMF S) (info : S → X) (derive : S → Z) (D : X → Z → PMF Bool) :

Experiment 0 of Attack Game 11.3 ([BS23], Section 11.5.2, p. 448) at one parameter, in the form of Section 8.10.1 (p. 326): the law of the bit a distinguisher outputs on the side information info s and the derived key derive s, for s drawn from sample. The distinguisher is given by its output law, so that programs (ProbComp.eval) and oracle programs run against a fixed table are both instances.

noncomputable def Cslib.Crypto.KeyDerivation.idealOutput {S X Z : Type} (sample : PMF S) (info : S → X) (key : PMF Z) (D : X → Z → PMF Bool) :

Experiment 1 of Attack Game 11.3 ([BS23], Section 11.5.2, p. 448) at one parameter, in the form of Section 8.10.1 (p. 326): the distinguisher sees info s and an independent key drawn from key.

noncomputable def Cslib.Crypto.KeyDerivation.advantage {S X Z : Type} (sample : PMF S) (info : S → X) (derive : S → Z) (key : PMF Z) (D : X → Z → PMF Bool) :

KDFadv[A, F] of Attack Game 11.3 ([BS23], Section 11.5.2, pp. 448–449), which is Distadv[A, P, I, H] of Section 8.10.1 (p. 326) with P = sample, I = info, H = derive.

Families #

@[reducible, inline]

A key-derivation distinguisher: the security parameter, the public information and a candidate key.

One uniform strict PPT machine reads (1ⁿ, x, z).

noncomputable def Cslib.Crypto.KeyDerivation.realGame {S X Z : Type} (sample : ℕ → PMF S) (info : S → X) (derive : S → Z) (D : Distinguisher X Z) (n : ℕ) :

Experiment 0 at each security parameter.

noncomputable def Cslib.Crypto.KeyDerivation.idealGame {S X Z : Type} (sample : ℕ → PMF S) (info : S → X) (key : ℕ → PMF Z) (D : Distinguisher X Z) (n : ℕ) :

Experiment 1 at each security parameter.

def Cslib.Crypto.KeyDerivation.Secure {S X Z : Type} (encX : X ↪ List Bool) (encZ : Z ↪ List Bool) (sample : ℕ → PMF S) (info : S → X) (derive : S → Z) (key : ℕ → PMF Z) :

Secure key derivation ([BS23], Section 11.5.2, Attack Game 11.3, p. 448, and Definition 11.5, p. 449; Section 8.10.1, p. 326): every uniform strict PPT distinguisher (Distinguisher.IsPPT encX encZ) has negligible advantage between realGame and idealGame.

Phrased in the form of Section 8.10.1 (secret s with law sample n, side information info s, derived key derive s) with an arbitrary ideal key law key : ℕ → PMF Z in place of the uniform distribution on a finite key space; Attack Game 11.3 as printed is the instance where sample n is uniform on X × Y, info = Prod.fst, derive = F, and key n is uniform on Z. Neither efficient computability of info and derive nor finiteness of the secret and key spaces is part of the notion; it is the source's notion only when key n is uniform on a finite key space.

noncomputable def Cslib.Crypto.KeyDerivation.realEnsemble {S X Z : Type} (encX : X ↪ List Bool) (encZ : Z ↪ List Bool) (sample : ℕ → PMF S) (info : S → X) (derive : S → Z) (n : ℕ) :

The word ensemble (I(s), H(s)) of [BS23], Section 8.10.1 (p. 326).

noncomputable def Cslib.Crypto.KeyDerivation.idealEnsemble {S X Z : Type} (encX : X ↪ List Bool) (encZ : Z ↪ List Bool) (sample : ℕ → PMF S) (info : S → X) (key : ℕ → PMF Z) (n : ℕ) :

The word ensemble (I(s), t) of [BS23], Section 8.10.1 (p. 326).

theorem Cslib.Crypto.KeyDerivation.distinguishingGame_realEnsemble {S X Z : Type} (encX : X ↪ List Bool) (encZ : Z ↪ List Bool) (sample : ℕ → PMF S) (info : S → X) (derive : S → Z) (W : Crypto.Distinguisher) (n : ℕ) :
distinguishingGame (realEnsemble encX encZ sample info derive n) (W n) = realGame sample info derive (fun (n : ℕ) (x : X) (z : Z) => W n ((Turing.MultiTapeTM.encPair encX encZ) (x, z))) n

A word distinguisher run on the encoded pair plays the typed real game.

theorem Cslib.Crypto.KeyDerivation.distinguishingGame_idealEnsemble {S X Z : Type} (encX : X ↪ List Bool) (encZ : Z ↪ List Bool) (sample : ℕ → PMF S) (info : S → X) (key : ℕ → PMF Z) (W : Crypto.Distinguisher) (n : ℕ) :
distinguishingGame (idealEnsemble encX encZ sample info key n) (W n) = idealGame sample info key (fun (n : ℕ) (x : X) (z : Z) => W n ((Turing.MultiTapeTM.encPair encX encZ) (x, z))) n

A word distinguisher run on the encoded pair plays the typed ideal game.

theorem Cslib.Crypto.KeyDerivation.secure_iff_computationallyIndistinguishable {S X Z : Type} (encX : X ↪ List Bool) (encZ : Z ↪ List Bool) (sample : ℕ → PMF S) (info : S → X) (derive : S → Z) (key : ℕ → PMF Z) :
Secure encX encZ sample info derive key ↔ ComputationallyIndistinguishable (realEnsemble encX encZ sample info derive) (idealEnsemble encX encZ sample info key)

The two presentations agree ([BS23], Section 8.10.1, p. 326, and Section 11.5.2, Attack Game 11.3, p. 448): Secure is computational indistinguishability (Definition 3.4) of (I(s), H(s)) and (I(s), t).

theorem Cslib.Crypto.KeyDerivation.Secure.negligible {S X Z : Type} {encX : X ↪ List Bool} {encZ : Z ↪ List Bool} {sample : ℕ → PMF S} {info : S → X} {derive : S → Z} {key : ℕ → PMF Z} (h : Secure encX encZ sample info derive key) {D : Distinguisher X Z} (hD : Distinguisher.IsPPT encX encZ D) :
Negligible fun (n : ℕ) => advantage (sample n) info derive (key n) fun (x : X) (z : Z) => (D n x z).eval

Applying the assumption to one certified distinguisher.

theorem Cslib.Crypto.KeyDerivation.Secure.comp_info {S X Z X' : Type} {encX : X ↪ List Bool} {encX' : X' ↪ List Bool} {encZ : Z ↪ List Bool} {sample : ℕ → PMF S} {info : S → X} {derive : S → Z} {key : ℕ → PMF Z} (h : Secure encX encZ sample info derive key) {f : X → X'} (hf : Turing.MultiTapeTM.ComputableInPolyTime f encX encX') :
Secure encX' encZ sample (f ∘ info) derive key

Efficient preprocessing of the public information: a KDF secure given info is secure given any polynomial-time function of it (less side information).