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 #
Cslib.Crypto.weakSample: one uniform point together with an oracle's answer on it.Cslib.Crypto.weakPrfRealGame,.weakPrfIdealGame: the keyed and random-function experiments.Cslib.Crypto.WeakPseudorandomFunction: efficient evaluation, length and weak security.Cslib.Crypto.weakToPrfDistinguisher: answers weak-PRF calls through an adaptive PRF oracle.Cslib.Crypto.zeroPatch: replaces every answer on an all-zero query by the query itself.
Main results #
Cslib.Crypto.PseudorandomFunction.weakPseudorandomFunction: every pseudorandom function is a weak pseudorandom function ([KL20], Exercise 3.28(a)).Cslib.Crypto.not_eufCma_prfMAC_zeroPatch: the standard fixed-length MAC built from a zero-patched family is forgeable with probability one, without any tagging query.Cslib.Crypto.not_pseudorandomFunction_zeroPatch: hence no zero-patched family is a pseudorandom function.Cslib.Crypto.advantage_weakPrfRealGame_zeroPatch_le: zero patching moves the weak real game by at mostQ / 2ⁿagainst an adversary making at mostQcalls.Cslib.Crypto.WeakPseudorandomFunction.zeroPatch: zero patching preserves weak security.Cslib.Crypto.PseudorandomFunction.exists_weak_not_pseudorandom: if pseudorandom functions exist, some weak pseudorandom function is not pseudorandom ([KL20], Exercise 3.28(b)).Cslib.Crypto.PseudorandomFunction.exists_weak_not_eufCma_prfMAC: if pseudorandom functions exist, some weak pseudorandom function gives a forgeable fixed-length MAC ([KL20], Exercise 4.9).
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 #
- J. Katz, Y. Lindell, Introduction to Modern Cryptography, Exercise 3.28 (printed p. 103) and Exercise 4.9 (printed p. 141).
The weak experiments #
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.
- polyTime : Turing.MultiTapeTM.ComputableInPolyTime (fun (pair : List Bool × List Bool) => family pair.1 pair.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits
One deterministic machine evaluates the family from the encoded key and query.
- length_eq (key query : List Bool) : query.length = key.length → (family key query).length = key.length
Valid queries receive answers of the declared width.
- secure : Game.Indistinguishable (fun (adversary : OracleDistinguisher) (n : ℕ) => (weakPrfRealGame family adversary n).eval) (fun (adversary : OracleDistinguisher) (n : ℕ) => (weakPrfIdealGame adversary n).eval) (Probability.IsOraclePPT Turing.MultiTapeTM.encBool)
The real and ideal weak experiments use the common game-security calculus.
Every pseudorandom function is weak #
Run a weak-PRF adversary against an adaptive PRF oracle, answering each of its calls with
weakSampleQuery.
weakToPrfDistinguisher preserves strict oracle-PPT admissibility.
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 #
Zero patching preserves plain polynomial-time evaluation.
The MAC from a zero-patched family is forgeable #
Output the all-zero message with the all-zero tag, without any tagging query.
zeroForger is uniformly strict oracle-PPT.
zeroForger always wins against the MAC built from a zero-patched family.
A forgeable MAC from a patched family ([KL20], Exercise 4.9): the fixed-length
MAC built from a zero-patched family is never EUFCMA.
Zero patching preserves weak security #
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.