Adaptive PRF and PRP games and the PRP/PRF switching lemma #
The adversary is an OracleAdv D R Bool asking adaptive queries in D and
receiving answers in R. The real game samples a key k once and answers with
F k. The ideal PRF game answers with a lazily sampled random function and the
ideal PRP game with a lazily sampled random injection (sampling without
replacement, a random permutation when D = R); both keep the table of answered
queries as oracle state. Each game is an SPComp Bool that leaves the heap
unchanged, and the advantages are Advantage on these games.
Main definitions #
rfOracle,rpOracle— lazily sampled random function and random injectionrealGame F A,rfGame A,rpGame A— the real, PRF-ideal and PRP-ideal gamesPRF_q_Advantage F A,PRP_q_Advantage P A,RF_RP_Advantage A— the adaptive PRF, PRP and random-function/random-injection advantages
Main results #
RF_RP_Advantage_le— for an adversary with query boundq,RF_RP_Advantage A ≤ q(q-1)/2 / |R|PRF_q_Advantage_le— for an adversary with query boundq,PRF_q_Advantage P A ≤ PRP_q_Advantage P A + q(q-1)/2 / |R|PRF_q_Advantage_of_isQueryBound_zero,PRP_q_Advantage_of_isQueryBound_zero,RF_RP_Advantage_of_isQueryBound_zero— all advantages vanish without queriesswitching_bound_le_one— the bound is at most one whenq(q-1) ≤ 2|R|
Proof #
The random injection is written in resampling form (rpFlagOracle): a fresh
query samples a uniform answer and, when the answer repeats a recorded one,
resamples from the unused answers (uniform_bind_resample). Both oracles carry
a flag set on such a repetition. The flagged oracles agree on every transition
that leaves the flag cleared, so their runs agree on every outcome with the flag
cleared (OracleAdv.run_apply_flag_false_eq). The flag is set with probability
at most q(q-1)/2 / |R| (run_rfFlagOracle_flag_le). The flagged games write
the final flag to the heap location flagLoc, which is the form consumed by
SwitchingLemma.switching_from_birthday.
The answers recorded in a lazy-sampling table.
Equations
Instances For
Uniform distribution on the complement of u, and on all of R when the
complement is empty.
Equations
- CatCrypt.Crypto.PRPPRF.freshDist u = if h : uᶜ.Nonempty then PMF.uniformOfFinset uᶜ h else PMF.uniformOfFintype R
Instances For
Sampling uniformly from R and resampling from the complement of u when
the sample lies in u is sampling from freshDist u.
Lazily sampled oracles #
Lazily sampled random function with the table as state: a recorded query returns its recorded answer; a fresh query samples a uniform answer and records it.
Equations
Instances For
Lazily sampled random injection (a random permutation when D = R) with
the table as state: a recorded query returns its recorded answer; a fresh query
samples uniformly without replacement from the answers not yet recorded, and
records it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
rfOracle with a flag, set when a fresh answer repeats a recorded answer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
rpOracle in resampling form with a flag: a fresh query samples a uniform
answer; when it repeats a recorded answer the flag is set and the answer is
resampled from freshDist.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The collision probability #
Birthday bound for the flagged random function: from a table with m
entries and the flag cleared, an adversary asking at most n queries sets the
flag with probability at most (∑ i < n, (m + i)) / |R|.
Games #
The heap-independent game returning a sample of p and leaving the heap
unchanged.
Instances For
Ideal PRF game: run A against the lazily sampled random function.
Equations
Instances For
Ideal PRP game: run A against the lazily sampled random injection
(sampling without replacement).
Equations
Instances For
Adaptive PRF advantage of A against the keyed function F.
Equations
Instances For
Adaptive PRP advantage of A against the keyed function P.
Equations
Instances For
Advantage of A in distinguishing the lazy random function from the lazy
random injection.
Equations
Instances For
Flagged games #
The heap location recording the collision flag at the end of a flagged game.
Equations
- CatCrypt.Crypto.PRPPRF.flagLoc = { id := 0, ty := Bool, fintype := Bool.fintype, inhabited := instInhabitedBool }
Instances For
Summing a pushforward along some ∘ f over the outcomes satisfying P is
the probability of the preimage.
The switching lemma #
PRP/PRF switching lemma. An adversary asking at most q adaptive
queries distinguishes the lazy random function from the lazy random injection
with advantage at most q(q-1)/2 / |R|.
PRF advantage from PRP advantage. For every adversary asking at most
q adaptive queries, the PRF advantage of a keyed function is at most its PRP
advantage plus q(q-1)/2 / |R|.
Sanity facts #
Without queries, the real game and any ideal game over a table oracle have the same output distribution.
With no queries, the PRF advantage is zero.
With no queries, the PRP advantage is zero.
With no queries, the random function and the random injection are indistinguishable.
The two-query adversary that queries d₁ and d₂ and outputs whether the
answers coincide asks at most two queries.