Pseudorandom functions in the random-oracle model #
Attack Game 8.4 of [BS23], Section 8.10.2 (printed p. 329), for finite types. The
adversary is one adaptive program with private coins and two interfaces (ROSpec): the query
Sum.inl x asks for the keyed function F at x : X and returns a value in Y, and the query
Sum.inr m asks for the random oracle at m : M and returns a value in T. Both experiments first
sample the whole oracle table O : M → T uniformly and answer every oracle query m with O m.
Experiment 0 (roRealExperiment F A) then samples one uniform key and answers every F-query x
with F O key x; Experiment 1 (roIdealExperiment A) samples one uniform function f : X → Y and
answers with f x. The advantage roAdvantage F A is their distinguishing advantage. A keyed
function F : (M → T) → Key → X → Y of the oracle table is the book's F^O. When F ignores the
table and the adversary never queries the oracle, this is Attack Game 4.2
(roAdvantage_const_simulate).
Theorem 8.9 is about the key-prepending function F_pre(k, x) = H (k ‖ x), here
prependKey encode O key x = O (encode key x) for a pairing encode : Key → X → M. If encode
is injective in the pair of its arguments, an adversary that makes at most Q random-oracle
queries on every path has advantage at most Q / |Key| (roAdvantage_prependKey_le). Nothing is
assumed about its F-queries, its private coins or its running time, as in the book's remark that
the theorem is unconditional. keyAppend κ L is the book's k ‖ x for a κ-bit key and a word
of length at most L, with bound Q / 2 ^ κ (roAdvantage_prependKey_keyAppend_le). Over a
security parameter, if 1 / |Key n| is negligible (for bit strings: keys of at least n bits),
every family of adversaries with polynomially many random-oracle queries has negligible advantage
(negligible_roAdvantage_prependKey, negligible_roAdvantage_prependKey_keyAppend).
The proof is not the book's, which uses lazily sampled "faithful" and "forgetful gnome" games
(p. 330) and assumes that the adversary never repeats an F-query. For a fixed key the
oracle O has the law of Function.extend (encode key) f O for an independent uniform table
f : X → T (Cslib.Probability.PMF.uniformOfFintype_bind_bind_extend), and this oracle composed
with encode key is f. Experiment 0 therefore has the law of a game that answers F-queries with
f and oracle queries with Function.extend (encode key) f O, while Experiment 1 answers oracle
queries with O. For fixed f and O the two challengers differ only at an oracle query
encode key x, so they are identical until the set of keys that the oracle queries name contains
the key (ProbOracleComp.IdenticalUntilBad). In Experiment 1 that set does not depend on the key
and has at most Q members on every path, so a uniform key lies in it with probability at most
Q / |Key|.
Differences from the book:
- All of
Key,X,Y,MandTare finite types, and the oracle is one uniform table. - A pairing
encodethat is injective in the pair (Function.Injective2 encode) replacesk ‖ x; both halves of injectivity are needed. In the bit-string instanceMis exactly the words of length at mostκ + L, where the book'sMonly includes them. - In Theorem 8.9 the output type of
F_preis the oracle's,Y = T, as in the book. Qbounds the random-oracle queries on every path, whatever the coins and the replies; repeated queries are allowed and counted.- The asymptotic statements index everything by
n : ℕand bound the number of random-oracle queries by a polynomial; they do not mention running time. Definition 8.5 is not a named predicate. - Not stated: that the same construction is insecure for a Merkle–Damgård hash function (the book's "But wait!", p. 329), and Section 8.10.3.
ROSpec, ROAdversary, roRealExperiment, roIdealExperiment, roAdvantage, prependKey and
keyAppend are this library's names. Cslib.Crypto.Protocols.FujisakiOkamoto has its own ROSpec
and ROAdversary.
Main definitions #
Cslib.Crypto.PRF.ROSpec,Cslib.Crypto.PRF.ROAdversary: the two interfaces and the adversary.Cslib.Crypto.PRF.ROAdversary.IsOracleQueryBounded: at mostQrandom-oracle queries on every path;F-queries and private samples are free.Cslib.Crypto.PRF.roRealExperiment,Cslib.Crypto.PRF.roIdealExperiment,Cslib.Crypto.PRF.roAdvantage: Attack Game 8.4 and its advantage.Cslib.Crypto.PRF.prependKey: the key-prepending functionF_pre.Cslib.Crypto.PRF.keyAppend: aκ-bit key followed by a word of length at mostL.
Main results #
Cslib.Crypto.PRF.ROAdversary.IsOracleQueryBounded.of_isQueryBounded: a budget on all queries bounds the random-oracle queries.Cslib.Crypto.PRF.eval_roRealExperiment,Cslib.Crypto.PRF.eval_roIdealExperiment: the laws of the two experiments at thePMFlevel.Cslib.Crypto.PRF.roAdvantage_const_simulate: the game restricts to Attack Game 4.2.Cslib.Crypto.PRF.roAdvantage_prependKey_le: Theorem 8.9, the boundQ / |Key|.Cslib.Crypto.PRF.negligible_roAdvantage_prependKey: Theorem 8.9 over a security parameter.Cslib.Crypto.PRF.keyAppend_injective2,Cslib.Crypto.PRF.roAdvantage_prependKey_keyAppend_le,Cslib.Crypto.PRF.negligible_roAdvantage_prependKey_keyAppend: the book's bit strings.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 8.10.2, Attack Game 8.4, Definition 8.5 and Theorem 8.9 (printed p. 329), and the proof of Theorem 8.9 (printed p. 330).
Attack Game 8.4 #
The calls of a PRF adversary in the random-oracle model: an F-query names a point of X and
returns a value in Y; an O-query names a point of M and returns a value in T.
An adaptive test with private coins and oracle access to a function X → Y and to the random
oracle M → T.
The adversary makes at most Q random-oracle queries on every path, whatever its private
samples and the replies. Its F-queries and its private samples are free.
Experiment 0 of Attack Game 8.4: sample the random oracle O and one uniform key, answer every
F-query x with F O key x and every O-query m with O m.
Experiment 1 of Attack Game 8.4: sample the random oracle O and one uniform function
f : X → Y, answer every F-query x with f x and every O-query m with O m.
The PRF distinguishing advantage of A against F in the random-oracle model
([BS23], Attack Game 8.4).
A budget on all queries is a budget on the random-oracle queries.
The key-prepending function F_pre(k, x) = H (k ‖ x) of a hash function H
([BS23], Section 8.10.2), for a pairing encode of keys and inputs into hash inputs.
prependKey encode H evaluates H at the pairing of the key and the input.
The challengers of the proof #
Theorem 8.9 #
The law of roRealExperiment: a uniform oracle table and a uniform key, then the adversary
interpreted at the PMF level.
The law of roIdealExperiment: a uniform oracle table and a uniform function, then the
adversary interpreted at the PMF level.
A keyed function that ignores the oracle, against an adversary that does not query it: Attack Game 8.4 is then Attack Game 4.2 ([BS23]).
Theorem 8.9, concrete bound ([BS23], Section 8.10.2, p. 329). If encode is
injective in the pair of its arguments, an adversary that makes at most Q random-oracle queries
distinguishes F_pre(k, x) = O (encode k x) from a random function with advantage at most
Q / |Key|. Nothing is assumed about its F-queries, its private coins or its running time.
Theorem 8.9 ([BS23], Section 8.10.2, p. 329). If 1 / |Key n| is negligible,
the key-prepending function is a secure PRF in the random-oracle model in the following sense:
every family of adversaries whose number of random-oracle queries is polynomially bounded has
negligible advantage. The family need not be efficient; Definition 8.5 asks this only of efficient
adversaries.
The book's bit strings #
The book's k ‖ x ([BS23], Section 8.10.2): a κ-bit key followed by a word of
length at most L.
The word keyAppend κ L k x is the bits of k followed by the word x.
A key of fixed length followed by a word determines both.
Theorem 8.9 ([BS23], Section 8.10.2, p. 329) for K = {0,1}^κ,
X = {0,1}^{≤L} and M = {0,1}^{≤κ+L}: an adversary that makes at most Q random-oracle queries
has advantage at most Q / 2 ^ κ.
Theorem 8.9 ([BS23], Section 8.10.2, p. 329) for bit strings over a security
parameter: with keys of at least n bits at security parameter n, every family of adversaries
whose number of random-oracle queries is polynomially bounded has negligible advantage.