Documentation

CslibFrontier.Crypto.Computational.PseudorandomFunction.HashThenPRF

Computational security of hash-then-PRF on words #

The reduction samples a private hash key and forwards the digest of each valid word to its PRF challenger. Malformed words receive an empty reply without a call. A reply is read only up to the declared output width, even if the challenger returns a longer word.

This is the real-game step of [BS23], v0.6, §7.3, printed p. 264, toward (7.21). The real law uses two independent uniform keys and the composition PRF.hashThenPRF from (7.18). The hash is given on words with a polynomial-time domain test. Repeated queries are allowed.

The query collector for Game 2 runs the same adversary against a fresh lazy random function and outputs the distinct valid queries in its cache. It is strict PPT and its output length is bounded by the adversary's query budget. Equation (7.22) is the ideal-game comparison: hashing before the random function changes the adversary's success probability by at most the probability that Game 2's collected queries contain a hash collision.

The resulting uniform strict oracle-PPT security theorem is the word form of Theorem 7.7. The PRF key has n bits and the independently sampled hash key has keyLen n bits. The ideal random function is sampled lazily on the valid message domain regardless of its size. The two concrete bounds use the certified multi-query collector and the bounded fair-bit collision-pair reduction.

Main definitions #

Main results #

noncomputable def Cslib.Crypto.PRF.hashThenPRFWordReduction (keyLen outLen : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (H : ℕ → List Bool → List Bool → List Bool) (A : OracleDistinguisher) :

Sample a keyLen n-bit hash key and run the adversary. Each valid query is hashed and forwarded, and the reply prefix of length at most outLen n is returned to the adversary.

theorem Cslib.Crypto.PRF.isQueryBounded_hashThenPRFWordReduction (keyLen outLen : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (H : ℕ → List Bool → List Bool → List Bool) {A : OracleDistinguisher} {n Q : ℕ} {aux : List Bool} (hQ : ProbOracleComp.IsQueryBounded (A n aux) Q) :

The reduction's query budget is at most that of the original adversary.

noncomputable def Cslib.Crypto.PRF.hashThenPRFWordRealGame (keyLen : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (H : ℕ → List Bool → List Bool → List Bool) (F : List Bool → List Bool → List Bool) (A : OracleDistinguisher) (n : ℕ) :

The word real game for (7.18) in [BS23], v0.6, §7.3, printed pp. 262–264. Sample independent uniform hash and PRF keys, giving empty replies to invalid requests.

theorem Cslib.Crypto.PRF.eval_prfRealGame_hashThenPRFWordReduction {keyLen inLen outLen : ℕ → ℕ} (valid : ℕ → List Bool → Bool) (H : ℕ → List Bool → List Bool → List Bool) (F : List Bool → List Bool → List Bool) (hH : ∀ (n : ℕ) (key msg : List Bool), key.length = keyLen n → valid n msg = true → (H n key msg).length = inLen n) (hF : ∀ (key query : List Bool), query.length = inLen key.length → (F key query).length = outLen key.length) (A : OracleDistinguisher) (n : ℕ) :
(prfRealGame inLen F (hashThenPRFWordReduction keyLen outLen valid H A) n).eval = (hashThenPRFWordRealGame keyLen valid H F A n).eval

Real-game step of [BS23], v0.6, §7.3, printed p. 264. The reduction run against the real PRF implements hashThenPRF under independent uniform keys. The input and output width hypotheses ensure that the PRF's malformed-request check and reply cap preserve valid answers. Invalid messages receive the empty word in both experiments.

noncomputable def Cslib.Crypto.PRF.hashThenPRFWordIdealRun (outLen : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (A : OracleDistinguisher) :

Game 2 run for [BS23], v0.6, §7.3, printed p. 264. Return the adversary's decision and the final cache of a lazy random function on valid words. Malformed words receive [].

noncomputable def Cslib.Crypto.PRF.hashThenPRFWordIdealQueries (outLen : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (A : OracleDistinguisher) :

The query-collecting step of Game 2 in [BS23], v0.6, §7.3, printed p. 264. Return the cache keys from the run against a fresh random function on the valid words.

theorem Cslib.Crypto.PRF.nodup_valid_of_mem_support_hashThenPRFWordIdealQueries {outLen : ℕ → ℕ} {valid : ℕ → List Bool → Bool} {A : OracleDistinguisher} {n : ℕ} {aux : List Bool} {ms : List (List Bool)} (hms : ms ∈ (hashThenPRFWordIdealQueries outLen valid A (n, aux)).eval.support) :
ms.Nodup ∧ ∀ msg ∈ ms, valid n msg = true

A supported output contains no repeated or invalid words.

theorem Cslib.Crypto.PRF.length_le_of_mem_support_hashThenPRFWordIdealQueries {outLen : ℕ → ℕ} {valid : ℕ → List Bool → Bool} {A : OracleDistinguisher} {n Q : ℕ} {aux : List Bool} (hQ : ProbOracleComp.IsQueryBounded (A n aux) Q) {ms : List (List Bool)} (hms : ms ∈ (hashThenPRFWordIdealQueries outLen valid A (n, aux)).eval.support) :
ms.length ≤ Q

A supported list contains at most as many entries as the adversary can query.

The ideal-game comparison #

def Cslib.Crypto.PRF.hashThenPRFWordHash (keyLen inLen : ℕ → ℕ) (H : ℕ → List Bool → List Bool → List Bool) (n d : ℕ) (key : BitString (keyLen d)) (msg : List Bool) :
BitString (inLen d)

Interpret the word hash's fixed-width keys and digests for the computational UHF games. The public setup supplies the key and digest widths.

theorem Cslib.Crypto.PRF.advantage_prfIdealGame_hashThenPRFWordReduction_le {keyLen inLen outLen : ℕ → ℕ} (valid : ℕ → List Bool → Bool) (H : ℕ → List Bool → List Bool → List Bool) (hH : ∀ (n : ℕ) (key msg : List Bool), key.length = keyLen n → valid n msg = true → (H n key msg).length = inLen n) (A : OracleDistinguisher) (n : ℕ) :
↑(Game.advantage (prfIdealGame inLen outLen (hashThenPRFWordReduction keyLen outLen valid H A) n).eval (PMF.map Prod.fst (hashThenPRFWordIdealRun outLen valid A (n, [])).eval)) ≤ (UHF.multiQueryGame (fun (k : ℕ) => pure k) (fun (k x : ℕ) => valid k) (hashThenPRFWordHash keyLen inLen H) (fun (p : ℕ × ℕ) => hashThenPRFWordIdealQueries outLen valid A (p.1, [])) n) true

The word-model ideal-game step (7.22) of [BS23], v0.6, §7.3, printed p. 264. The advantage between a random function called on hashed valid words and a random function called on the valid words themselves is bounded by the certified collector's success in Attack Game 7.2. Digests have the PRF's input width. Both games reject invalid words and answer repetitions consistently.

Concrete and asymptotic security #

theorem Cslib.Crypto.PRF.advantage_hashThenPRFWord_le_add_multiQuery {keyLen inLen outLen : ℕ → ℕ} (valid : ℕ → List Bool → Bool) (H : ℕ → List Bool → List Bool → List Bool) (F : List Bool → List Bool → List Bool) (hH : ∀ (n : ℕ) (key msg : List Bool), key.length = keyLen n → valid n msg = true → (H n key msg).length = inLen n) (hF : ∀ (key query : List Bool), query.length = inLen key.length → (F key query).length = outLen key.length) (A : OracleDistinguisher) (n : ℕ) :
have B := hashThenPRFWordReduction keyLen outLen valid H A; Game.advantage (hashThenPRFWordRealGame keyLen valid H F A n).eval (PMF.map Prod.fst (hashThenPRFWordIdealRun outLen valid A (n, [])).eval) ≤ Game.advantage (prfRealGame inLen F B n).eval (prfIdealGame inLen outLen B n).eval + (UHF.multiQueryGame (fun (k : ℕ) => pure k) (fun (k x : ℕ) => valid k) (hashThenPRFWordHash keyLen inLen H) (fun (p : ℕ × ℕ) => hashThenPRFWordIdealQueries outLen valid A (p.1, [])) n).succProbability

Equation (7.20) of [BS23], v0.6, §7.3, printed p. 263, in the product-key word model. The advantage of the hash-then-PRF test is bounded by the PRF wrapper's advantage plus the certified collector's multi-query collision success.

theorem Cslib.Crypto.PRF.advantage_hashThenPRFWord_le_add_collision {keyLen inLen outLen : ℕ → ℕ} (valid : ℕ → List Bool → Bool) (H : ℕ → List Bool → List Bool → List Bool) (F : List Bool → List Bool → List Bool) (hH : ∀ (n : ℕ) (key msg : List Bool), key.length = keyLen n → valid n msg = true → (H n key msg).length = inLen n) (hF : ∀ (key query : List Bool), query.length = inLen key.length → (F key query).length = outLen key.length) (A : OracleDistinguisher) (n Q : ℕ) (hQ : ProbOracleComp.IsQueryBounded (A n []) Q) :
have B := hashThenPRFWordReduction keyLen outLen valid H A; Game.advantage (hashThenPRFWordRealGame keyLen valid H F A n).eval (PMF.map Prod.fst (hashThenPRFWordIdealRun outLen valid A (n, [])).eval) ≤ Game.advantage (prfRealGame inLen F B n).eval (prfIdealGame inLen outLen B n).eval + ↑Q ^ 2 / 2 * (UHF.collisionGame (fun (k : ℕ) => pure k) (fun (k x : ℕ) => valid k) (hashThenPRFWordHash keyLen inLen H) (fun (p : ℕ × ℕ) => UHF.collisionPairReduction [] (hashThenPRFWordIdealQueries outLen valid A (p.1, []))) n).succProbability

Equation (7.19) of [BS23], v0.6, §7.3, printed p. 262, in the product-key word model. The single-pair wrapper uses the strict fair-bit sampler of Lemma 7.1.

Theorem 7.7 of [BS23], v0.6, §7.3, printed pp. 262–265, for product keys and uniform strict oracle-PPT tests. The components provide efficient hash evaluation, domain recognition, unary key and digest width schedules, computational UHF security, and PRF security. The real game uses the composed evaluator with fresh independent keys. Its ideal game uses one lazy random function on the same valid words. Invalid queries receive [] in both games and repeated queries are allowed. The composition's evaluator is certified by computableInPolyTime_hashThenPRFWord.