Documentation

CslibFrontier.Crypto.Computational.PseudorandomFunction.Coins

Pseudorandom coins from a pseudorandom function #

A pseudorandom function with N-bit keys, inputs and outputs supplies up to N pseudorandom coins for every short request word: pad the request prefix-freely to N bits (padRequest), evaluate, and keep the requested number of bits (prfCoins). Distinct requests of length below N pad to distinct inputs, so in the ideal world they receive independent uniform coins, and a repeated request receives the same coins. This is the coin source of stateless tree signatures ([BS23], Section 14.6.2, "Generating internal keys using a PRF"), where N is a polynomial in the signature scheme's parameter chosen above every coin budget.

The coin games coinRealGame and coinIdealGame let an adversary request (x, L) and answer with prfCoins family k x L under a uniform key, or with the first L bits of a uniform random function at padRequest N x. The reduction coinDistinguisher forwards each request padded and truncates the reply, so both games are exactly the PRF games of the forwarded adversary (eval_coinRealGame, eval_coinIdealGame), and a pseudorandom function makes the coin games indistinguishable (PseudorandomFunction.coinIndistinguishable).

Main definitions #

Main results #

References #

Padding and coins #

Pad a request to exactly w bits: the request, a true, then falses, cut at w bits. Requests shorter than w pad injectively.

A request shorter than the width pads to the request, a true and falses.

Strip the padding: drop the trailing falses and the true before them.

theorem Cslib.Crypto.padRequest_injective {w : ℕ} {x y : List Bool} (hx : x.length < w) (hy : y.length < w) (h : padRequest w x = padRequest w y) :
x = y

Distinct requests shorter than the width pad to distinct words.

def Cslib.Crypto.prfCoins (family : List Bool → List Bool → List Bool) (k x : List Bool) (L : ℕ) :

L coins for the request x from the key k: the family at the request padded to the key's length, cut to L bits.

theorem Cslib.Crypto.length_prfCoins {family : List Bool → List Bool → List Bool} (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) (k x : List Bool) {L : ℕ} (hL : L ≤ k.length) :
(prfCoins family k x L).length = L

The coins have the requested length when it is at most the key length.

The coin games #

A coin request word encPair encBits encUnary (x, L): the request x and the number L of coins; requestDecoder-style, every word decodes to some pair.

def Cslib.Crypto.coinOracle (family : List Bool → List Bool → List Bool) (k request : List Bool) :

The real coin oracle: prfCoins under the key, on the decoded request.

def Cslib.Crypto.randomCoinOracle (N : ℕ) (table : BitString N → BitString N) (request : List Bool) :

The ideal coin oracle: the random function at the padded request, cut to the count.

noncomputable def Cslib.Crypto.coinRealGame (family : List Bool → List Bool → List Bool) (adversary : OracleDistinguisher) (N : ℕ) :

The real coin game: a uniform N-bit key answers every request with prfCoins.

noncomputable def Cslib.Crypto.coinIdealGame (adversary : OracleDistinguisher) (N : ℕ) :

The ideal coin game: a uniform random function on N bits answers every request at its padding, cut to the requested count.

The reduction to the PRF games #

Forward a coin request to the function oracle at its padding, keeping the requested bits.

The PRF distinguisher built from a coin adversary: run it, answering through coinQuery.

theorem Cslib.Crypto.eval_coinRealGame (family : List Bool → List Bool → List Bool) (adversary : OracleDistinguisher) (N : ℕ) :
(coinRealGame family adversary N).eval = (prfRealGame id family (coinDistinguisher adversary) N).eval

The real coin game is the real PRF game of the forwarded adversary.

The ideal coin game is the ideal PRF game of the forwarded adversary.

The forwarded adversary is uniformly strict oracle PPT whenever the coin adversary is.

A pseudorandom function gives pseudorandom coins: the real and ideal coin games are indistinguishable for every oracle-PPT adversary, with the same advantage as the forwarded adversary's in the PRF games.