Pseudorandom Functions

Work in progress. This note is still being written and incomplete.

A pseudorandom function (PRF) family is a set of efficiently computable functions {fk:{0,1}n→{0,1}n}k∈{0,1}n\{f_k : \{0,1\}^n \to \{0,1\}^n\}_{k \in \{0,1\}^n}, indexed by a key kk, that no efficient adversary can distinguish from a function chosen uniformly at random from all functions on {0,1}n\{0,1\}^n.

Security Game

A distinguisher DD is given oracle access to a function ff and must output a single bit guessing whether ff was drawn as fkf_k for a random key kk, or as a uniformly random function RR.

AdvPRF(D)=∣Pr⁡[Dfk=1]−Pr⁡[DR=1]∣\mathrm{Adv}_{\mathrm{PRF}}(D) = \left| \Pr[D^{f_k} = 1] - \Pr[D^{R} = 1] \right|

A family is a secure PRF iff AdvPRF(D)\mathrm{Adv}_{\mathrm{PRF}}(D) is negligible for every probabilistic polynomial-time (PPT) DD, over the random choice of kk or RR.

  • The number of oracle queries DD may make is polynomial in nn, since DD itself runs in polynomial time.
  • DD never sees kk, only input-output pairs of the oracle it queries.

Pseudorandom Permutations

A pseudorandom permutation (PRP) family restricts each fkf_k to a bijection on {0,1}n\{0,1\}^n, indistinguishable from a permutation chosen uniformly at random from all permutations on {0,1}n\{0,1\}^n, rather than from all functions.

Block ciphers are designed to be PRP families: eke_k plays the role of fkf_k, and dk=fk−1d_k = f_k^{-1} must also be efficiently computable, a requirement a general PRF has no need for.

Construction from a Pseudorandom Generator

A pseudorandom generator (PRG) G:{0,1}n→{0,1}2nG : \{0,1\}^n \to \{0,1\}^{2n} stretches a short seed into a longer pseudorandom string. Write G0(k)G_0(k) and G1(k)G_1(k) for the first and second nn-bit halves of G(k)G(k).

The Goldreich-Goldwasser-Micali (GGM) construction builds a PRF from GG. To evaluate fk(x)f_k(x) for an nn-bit input x=x1x2⋯xnx = x_1 x_2 \cdots x_n, walk a binary tree of depth nn rooted at kk, taking the left half G0G_0 at each 00 bit of xx and the right half G1G_1 at each 11 bit.

fk(x1x2⋯xn)=Gxn(⋯Gx2(Gx1(k))⋯ )f_k(x_1 x_2 \cdots x_n) = G_{x_n}(\cdots G_{x_2}(G_{x_1}(k)) \cdots)
  • Every leaf of the tree corresponds to a distinct input xx, reached by a distinct sequence of nn PRG calls.
  • A secure PRG makes each level indistinguishable from random, so the composed function is indistinguishable from random overall.

This shows a PRF exists whenever a PRG does, and a PRG exists whenever a one-way function does.

Uses

  • Message authentication
    A MAC over a fixed-length message mm under key kk can be computed directly as fk(m)f_k(m).
  • Counter mode encryption
    CTR mode, in block encryption schemes, uses fkf_k evaluated at a counter as the keystream. Only the PRF property is needed, not the PRP’s invertibility.
  • Key derivation
    A single master key kk produces many independent-looking sub-keys fk(1),fk(2),…f_k(1), f_k(2), \ldots
Written by September 29, 2026 3 min read
Was this helpful?