Uniform computational pseudorandom functions #
A keyed family has n-bit keys, and its valid queries and answers have inLen n and outLen n
bits. An adversary receives the unary security parameter, independent private randomness and
adaptive access to one word channel. The real game samples one key; the ideal game samples one
whole function and reuses it across calls. Both games invoke the adversary with empty auxiliary
input and reject malformed queries with the empty word. The table is a semantic specification;
prfIdealGame_eq_lazy samples it lazily, and RandomOracle certifies a lazy realization of the
length-preserving game for oracle-PPT adversaries.
The keyed evaluator has a uniform deterministic TM certificate on the encoded key/query pair.
Admissible adversaries satisfy IsOraclePPT, charging ordinary computation and request writing,
with one machine and polynomial for all parameters and auxiliary inputs.
PseudorandomFunction is the length-preserving case inLen = outLen = id, in which keys, valid
queries and answers all have n bits.
Main definitions #
Cslib.Crypto.OracleDistinguisher: a parameterized randomized adaptive oracle test.Cslib.Crypto.prfRealGame,.prfIdealGame: the keyed and random-function experiments.Cslib.Crypto.PseudorandomFunctionOver: efficient evaluation, lengths and adaptive security.Cslib.Crypto.PseudorandomFunction: its length-preserving case.
Main results #
Cslib.Crypto.computableInPolyTime_prfOracle_comp: plain polynomial-time composition rule forprfOracle.Cslib.Crypto.wordOracle_bitStrings,Cslib.Crypto.wordOracle_bitStrings_answer: agreement ofOracleCodec.bitStringswithrandomFunctionOracleandlazyRandomFunctionOracle.Cslib.Crypto.randomFunctionOracle_keyed: the finite keyed table presents the same word oracle.Cslib.Crypto.prfIdealGame_eq_lazy: an exact lazy implementation of the ideal experiment.Cslib.Crypto.PseudorandomFunctionOver.outLen_polyTime: computing the unary output width from the unary input width schedule.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Chapter 4.
- O. Goldreich, S. Goldwasser, S. Micali, How to Construct Random Functions.
Adapted from Crypto/Computational/PseudorandomFunction.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, using the shared typed interpreter and word channel.
An adaptive test with a unary parameter, an auxiliary word and one external word channel.
Evaluating prfOracle family (n a) (key a) (query a) is computable in plain polynomial time
whenever family, the unary domain width n, key, and query are computable in plain
polynomial time.
The finite table of a keyed family presents the keyed word oracle when the family has the declared reply width on valid inputs. Both presentations reject malformed queries.
Adapt a valid word to the finite domain. Malformed words make no external call; this is
(OracleCodec.bitStrings n w).wordOracle ProbOracleComp.query on (), query.
OracleCodec.bitStrings n w presents randomFunctionOracle n table on the unit word channel:
an n-bit request is answered by the bits of table and any other request by [].
OracleCodec.bitStrings n w lifts RandomOracle.answer to lazyRandomFunctionOracle n w on
the unit word channel.
The real experiment of a keyed family with inLen n-bit inputs: sample one n-bit key and
answer every query of inLen n bits with the family under that key, and any other query with the
empty word.
The ideal experiment with inLen n-bit inputs and outLen n-bit outputs: sample one uniform
function between them, independently of the adversary's private samples, and answer every query
of inLen n bits with its value, and any other query with the empty word.
The ideal game admits consistent lazy answers to adaptive queries, with private randomness independent of the table and the same rejection convention for malformed inputs.
A keyed family with n-bit keys, inLen n-bit inputs and outLen n-bit outputs, evaluated in
plain polynomial time and secure against every uniform adaptive oracle test: [BS23],
Attack Game 4.2 and Definition 4.2, pp. 132–133, for a PRF defined over (K, X, Y), read
asymptotically with K, X and Y the words of n, inLen n and outLen n bits. A query of
another length is answered by the empty word in both games, and deterministic polynomial-time
evaluation is part of the notion. PseudorandomFunction is the case inLen = outLen = id.
The lengths are meant to be polynomially bounded in n, as in the book's asymptotic definition
(Definition 4.4, Section 4.4.5, pp. 139–141), whose X and Y are families of spaces with strings
of polynomially bounded length (Definition 2.9, Section 2.3.2, p. 30). The structure does not
require this, and without it the notion degenerates:
- if
inLen ngrows faster than every polynomial (for example2 ^ n), each admitted test eventually writes only queries shorter thaninLen n(IsOraclePPT.query_bounds), so both games answer all of them with the empty word andsecureholds for every family: every family meetingpolyTimeandlength_eqqualifies; - if
outLen nis not bounded by a polynomial inn + inLen n,polyTimeandlength_eqcannot both hold, because a polynomial-time machine writes polynomially many bits (ComputableInPolyTime.polyBounded_length), and no family qualifies.
The theorems that use the notion take the bound from their own hypotheses: a BlockCipher's
blockLen is computable in polynomial time from unary n (BlockCipher.blockLen_polyTime);
indistinguishable_prgFromPRF and PseudorandomFunctionOver.toPRG assume the query points
computable in polynomial time from unary n, and the former also outLen; and
MLKEM.indCPA_kpkePRF_of_decisionModuleLWEWith assumes parameters computable in polynomial time,
with n, k, η₁ and η₂ encoded in unary.
- 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 = inLen key.length → (family key query).length = outLen key.length
Valid queries receive answers of the declared width.
- secure : Game.Indistinguishable (fun (adversary : OracleDistinguisher) (n : ℕ) => (prfRealGame inLen family adversary n).eval) (fun (adversary : OracleDistinguisher) (n : ℕ) => (prfIdealGame inLen outLen adversary n).eval) (Probability.IsOraclePPT Turing.MultiTapeTM.encBool)
The real and ideal experiments use the common game-security calculus.
Evaluate the family at the all-zero key and a valid all-zero query to compute the output width in unary.
A length-preserving pseudorandom function: PseudorandomFunctionOver id id, whose keys, valid
queries and answers all have n bits ([BS23], Attack Game 4.2 and Definition 4.2,
pp. 132–133, with K, X and Y all the words of n bits). Its fields are those of
PseudorandomFunctionOver.