Documentation

CslibFrontier.Crypto.Computational.WeakPRF

Weak pseudorandom functions #

A weak pseudorandom function is a keyed family that looks random to an adversary who sees only evaluations at uniformly random points. Each oracle call returns a fresh uniform n-bit point followed by the family's answer at that point; the adversary never chooses the inputs.

Main definitions #

Main results #

Implementation notes #

Both separations use zeroPatch, which agrees with the original family except on the all-zero query. A weak adversary meets that query only when a uniform point is all-zero, so weak security survives with an extra Q / 2ⁿ; an adaptive adversary or a MAC forger asks for it directly. This is the construction of Exercise 4.9. Another answer to Exercise 3.28(b) evaluates the function after rounding odd inputs to even ones; the zero patch is a simpler family that separates the same two notions.

References #

The weak experiments #

noncomputable def Cslib.Crypto.weakSample (n : ℕ) (oracle : List Bool → List Bool) :

One weak-PRF sample: a uniform n-bit point followed by the oracle's answer on it.

noncomputable def Cslib.Crypto.weakPrfRealGame (family : List Bool → List Bool → List Bool) (adversary : OracleDistinguisher) (n : ℕ) :

Sample one key; every call returns a fresh uniform point and the keyed answer on it. The adversary's request payload is ignored.

noncomputable def Cslib.Crypto.weakPrfIdealGame (adversary : OracleDistinguisher) (n : ℕ) :

Sample one whole random function; every call returns a fresh uniform point and the table's answer on it.

A keyed family evaluated in plain polynomial time whose answers at uniformly random points are indistinguishable from those of a random function ([KL20]): a weakly secure PRF, [BS23], Definition 4.3 (p. 133), with n-bit keys, inputs and outputs, against uniform strict oracle-PPT adversaries. Each call returns a uniform point followed by the function's value there, as the source's challenger sends both.

Every pseudorandom function is weak #

Run a weak-PRF adversary against an adaptive PRF oracle, answering each of its calls with weakSampleQuery.

theorem Cslib.Crypto.eval_prfRealGame_weakToPrfDistinguisher (family : List Bool → List Bool → List Bool) (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) (adversary : OracleDistinguisher) (n : ℕ) :
(prfRealGame id family (weakToPrfDistinguisher adversary) n).eval = (weakPrfRealGame family adversary n).eval

The reduction turns the adaptive real game into the weak real game.

The reduction turns the adaptive ideal game into the weak ideal game.

Every pseudorandom function is weak ([KL20], Exercise 3.28(a)): an adversary that only sees random points can be simulated by one that chooses those points itself.

Zero patching #

def Cslib.Crypto.zeroPatch (family : List Bool → List Bool → List Bool) (key query : List Bool) :

Answer an all-zero query by the query itself, and every other query by the family.

theorem Cslib.Crypto.length_zeroPatch {family : List Bool → List Bool → List Bool} (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) (key query : List Bool) (hquery : query.length = key.length) :
(zeroPatch family key query).length = key.length

Zero patching preserves the answer width.

On the all-zero query the patched family returns the query itself.

The MAC from a zero-patched family is forgeable #

noncomputable def Cslib.Crypto.zeroForger :

Output the all-zero message with the all-zero tag, without any tagging query.

A forgeable MAC from a patched family ([KL20], Exercise 4.9): the fixed-length MAC built from a zero-patched family is never EUFCMA.

No zero-patched family is a pseudorandom function: its MAC would otherwise be EUFCMA.

Zero patching preserves weak security #

theorem Cslib.Crypto.advantage_weakPrfRealGame_zeroPatch_le (family : List Bool → List Bool → List Bool) (adversary : OracleDistinguisher) (n Q : ℕ) (hq : ProbOracleComp.IsQueryBounded (adversary n []) Q) :
↑(Game.advantage (weakPrfRealGame (zeroPatch family) adversary n).eval (weakPrfRealGame family adversary n).eval) ≤ ↑Q / 2 ^ n

Zero patching moves the weak real game by at most Q / 2ⁿ against an adversary making at most Q calls: the two games differ only when a uniform point is all-zero.

Zero patching preserves weak pseudorandomness: a weak adversary sees the all-zero point with probability 2⁻ⁿ per call, so the patched family stays weakly pseudorandom.

Separations #

A weak pseudorandom function that is not pseudorandom ([KL20], Exercise 3.28(b)): zero patching any pseudorandom function gives one.

A weak pseudorandom function with a forgeable MAC ([KL20], Exercise 4.9): zero patching any pseudorandom function gives a weak pseudorandom function whose fixed-length MAC is not EUFCMA.