Documentation

CslibFrontier.Crypto.Primitives.UHF.PrefixFreePRF

Computational universal hashing from an extendable prefix-free PRF #

The two-query wrapper proves [BS23], v0.6, Theorem 7.3 (printed pp. 258–259), in the word model. It runs the collision guesser on the public unary parameter, extends each accepted word by the same full block, and checks equality of the two oracle replies. The wrapper always extends an accepted pair. Its reply reads are capped at the declared width.

The certificate uses the library's domain-relative prefix condition. Definition 4.5 (printed p. 152) also requires every query to be nonempty and in the PRF input domain. Applying the wrapper to that game requires showing that the extended messages fit the oracle domain. Theorem 7.3 provides this room by giving the PRF domain one extra block of capacity.

For the direct multi-query reduction in Theorem 7.4, a bounded batch uses one block absent from all its messages. The wrapper queries each retained distinct message once after extension.

Main definitions #

Main results #

Reject invalid and repeated guesses. On an accepted pair, append the same separating block to both words and compare the two oracle replies, capped at the value of cap on the parameter and first extended query.

The prefix-free collision wrapper with both replies capped at the declared output width.

theorem Cslib.Crypto.UHF.isQueryBounded_prefixFreeCollisionReduction (width outLen : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (guessPair : ℕ × ℕ → ProbComp (CollisionGuess (List Bool))) (n : ℕ) (aux : List Bool) :
ProbOracleComp.IsQueryBounded (prefixFreeCollisionReduction width outLen valid guessPair n aux) 2

The wrapper makes at most two external queries, regardless of the guess or the replies.

If valid input words are aligned at a positive width, the wrapper for a strict PPT collision guesser is a strict oracle-PPT distinguisher with prefix-incomparable queries. The prefix condition is relative to oracleValid. Applying the certificate to the source game also requires showing that the extended queries are nonempty and satisfy oracleValid, as they do for the domain with one extra block in [BS23], Theorem 7.3.

theorem Cslib.Crypto.UHF.succProbability_collisionGame_le_real_prefixFreeCollisionReduction {width outLen : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} (family : List Bool → List Bool → List Bool) (guessPair : ℕ × ℕ → ProbComp (CollisionGuess (List Bool))) (n : ℕ) (hDomain : ∀ {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) (hExtend : ∀ {key left right block : List Bool}, key.length = n → valid n left = true → valid n right = true → block.length = width n → family key left = family key right → family key (left ++ block) = family key (right ++ block)) :
(collisionGame pure (fun (x d : ℕ) => valid d) (fun (x d : ℕ) (key : BitString d) => family (List.ofFn key)) guessPair n).succProbability ≤ Game.succProbability (prfRealGameOn oracleValid family (prefixFreeCollisionReduction width outLen valid guessPair) n).eval

The real-game step (7.7) in [BS23], v0.6, Theorem 7.3 (printed p. 259). Valid words remain valid for the PRF after a one-block extension. If that extension preserves collisions, each winning collision guess also makes the real wrapper accept.

theorem Cslib.Crypto.UHF.eval_prfIdealGameOn_prefixFreeCollisionReduction_le {width outLen : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} (guessPair : ℕ × ℕ → ProbComp (CollisionGuess (List Bool))) (n : ℕ) (hDomain : ∀ {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) :
(prfIdealGameOn oracleValid outLen (prefixFreeCollisionReduction width outLen valid guessPair) n).eval true ≤ (2 ^ outLen n)⁻¹

The ideal-game step of [BS23], v0.6, Theorem 7.3, printed p. 259, (7.8). Every accepted guess makes two distinct valid queries and their uniform replies are independent. The probability is bounded above because invalid or repeated guesses are rejected.

theorem Cslib.Crypto.UHF.succProbability_collisionGame_le_prefixFreeCollisionReduction {width outLen : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} (family : List Bool → List Bool → List Bool) (guessPair : ℕ × ℕ → ProbComp (CollisionGuess (List Bool))) (n : ℕ) (hDomain : ∀ {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) (hExtend : ∀ {key left right block : List Bool}, key.length = n → valid n left = true → valid n right = true → block.length = width n → family key left = family key right → family key (left ++ block) = family key (right ++ block)) :
(collisionGame pure (fun (x d : ℕ) => valid d) (fun (x d : ℕ) (key : BitString d) => family (List.ofFn key)) guessPair n).succProbability ≤ Game.advantage (prfRealGameOn oracleValid family (prefixFreeCollisionReduction width outLen valid guessPair) n).eval (prfIdealGameOn oracleValid outLen (prefixFreeCollisionReduction width outLen valid guessPair) n).eval + (2 ^ outLen n)⁻¹

The concrete bound (7.6) from [BS23], v0.6, Theorem 7.3 (printed pp. 258–259) for the word wrapper. Collision success is at most its PRF advantage plus the inverse size of the output space. One full block is appended to every accepted pair.

theorem Cslib.Crypto.UHF.isComputationalUHF_of_extendable_prefixFreePRF {width outLen : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} {family : List Bool → List Bool → List Bool} (hPRF : PrefixFreePseudorandomFunctionOn oracleValid outLen family) (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => valid p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) (haligned : ∀ (n : ℕ) (word : List Bool), valid n word = true → 0 < width n ∧ width n ∣ word.length) (hDomain : ∀ {n : ℕ} {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) (hExtend : ∀ {n : ℕ} {key left right block : List Bool}, key.length = n → valid n left = true → valid n right = true → block.length = width n → family key left = family key right → family key (left ++ block) = family key (right ++ block)) (hout : Negligible fun (n : ℕ) => (2 ^ outLen n)⁻¹) :
IsComputationalUHF Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits pure (fun (x d : ℕ) => valid d) fun (x d : ℕ) (key : BitString d) => family (List.ofFn key)

Boneh–Shoup v0.6, Theorem 7.3 (printed pp. 258–259), in the word model. An extendable prefix-free PRF with negligible reciprocal reply-space size is a computational UHF on the smaller domain. The uniform private key has n bits, and public setup is the unary parameter. Valid hash inputs are whole blocks of positive width, and appending any one block puts them in the PRF domain.

For positive-width bit blocks, the nonempty hash inputs of at most ℓ blocks lie in the oracle domain of one to ℓ + 1 blocks. The PRF's length clause therefore gives fixed-width digests on those inputs. The word theorem also permits the zero-block hash input, whose extension is a nonempty oracle query. If the oracle domain excludes the empty word, the family supplies the digest width on that input separately, as in length_cbcMacFamily. The conclusion uses raw List Bool digests, which at the declared width represent BitString (outLen n).

The reduction obtains the reply width by evaluating the PRF at a public zero key on a valid extended query.

def Cslib.Crypto.UHF.prefixFreeBatchQueries (width count : ℕ) (valid : List Bool → Bool) (guesses : List (List Bool)) :

Take at most count guesses, keep the first occurrence of each valid word, and extend each with the same fresh block. An exhausted block search produces no queries. This prepares the batch for the wrapper in [BS23], v0.6, Theorem 7.4 (printed pp. 259–260).

theorem Cslib.Crypto.UHF.nodup_prefixFreeBatchQueries (width count : ℕ) (valid : List Bool → Bool) (guesses : List (List Bool)) :
(prefixFreeBatchQueries width count valid guesses).Nodup

Each prepared word is distinct, including when the guesser repeats a message.

def Cslib.Crypto.UHF.prefixFreeBatchReduction (width outLen Q : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (guessBatch : ℕ × ℕ → ProbComp (List (List Bool))) :

Run the multi-query guesser on the public unary parameter, query the extended words, and accept if two capped replies coincide. The reply cap bounds the reading time for any oracle.

theorem Cslib.Crypto.UHF.isQueryBounded_prefixFreeBatchReduction (width outLen Q : ℕ → ℕ) (valid : ℕ → List Bool → Bool) (guessBatch : ℕ × ℕ → ProbComp (List (List Bool))) (n : ℕ) (aux : List Bool) :
ProbOracleComp.IsQueryBounded (prefixFreeBatchReduction width outLen Q valid guessBatch n aux) (Q n)

The batch wrapper makes at most Q n external queries for every oracle and guess list.

theorem Cslib.Crypto.UHF.isPrefixFreeOn_prefixFreeBatchReduction {width cap Q : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} (guessBatch : ℕ × ℕ → ProbComp (List (List Bool))) (n outLen : ℕ) (haligned : ∀ (word : List Bool), valid n word = true → 0 < width n ∧ width n ∣ word.length) :
IsPrefixFreeOn (oracleValid n) outLen (prefixFreeBatchReduction width cap Q valid guessBatch n [])

On complete positive-width blocks, the batch wrapper is prefix-free for every oracle reply width, independently of the cap it uses when reading replies.

The batch wrapper is a strict prefix-free oracle-PPT distinguisher when each valid message is a word of complete positive-width blocks. Prefix-freeness holds on every oracle domain. To apply the bound of Theorem 7.4, the extended words also have to lie in the chosen PRF domain, which in the book permits one extra block.

theorem Cslib.Crypto.UHF.succProbability_multiQueryGame_le_real_prefixFreeBatchReduction {width outLen Q : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} (family : List Bool → List Bool → List Bool) (guessBatch : ℕ × ℕ → ProbComp (List (List Bool))) (n maxBlocks : ℕ) (hBudget : ∀ guesses ∈ (guessBatch (n, n)).eval.support, guesses.length ≤ Q n) (hBlocks : ∀ (word : List Bool), valid n word = true → word.length / width n ≤ maxBlocks) (hAlphabet : maxBlocks * Q n < 2 ^ width n) (hDomain : ∀ {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) (hExtend : ∀ {key left right block : List Bool}, key.length = n → valid n left = true → valid n right = true → block.length = width n → family key left = family key right → family key (left ++ block) = family key (right ++ block)) :
(multiQueryGame pure (fun (x d : ℕ) => valid d) (fun (x d : ℕ) (key : BitString d) => family (List.ofFn key)) guessBatch n).succProbability ≤ Game.succProbability (prfRealGameOn oracleValid family (prefixFreeBatchReduction width outLen Q valid guessBatch) n).eval

The real-game step of [BS23], v0.6, Theorem 7.4 (printed pp. 259–260). If the alphabet has more than maxBlocks * Q n blocks, a fresh block exists for every retained batch. Every collision between distinct valid guesses is then preserved by extension and detected by the real prefix-free PRF wrapper.

theorem Cslib.Crypto.UHF.eval_prfIdealGameOn_prefixFreeBatchReduction_le {width outLen Q : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} (guessBatch : ℕ × ℕ → ProbComp (List (List Bool))) (n : ℕ) (hDomain : ∀ {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) :
(prfIdealGameOn oracleValid outLen (prefixFreeBatchReduction width outLen Q valid guessBatch) n).eval true ≤ ↑((Q n).choose 2) / 2 ^ outLen n

The ideal-game step of [BS23], v0.6, Theorem 7.4 (printed p. 260). The wrapper's prepared queries are distinct and valid, so their ideal replies have a collision with probability at most the number of possible pairs divided by the reply alphabet size.

theorem Cslib.Crypto.UHF.succProbability_multiQueryGame_le_prefixFreeBatchReduction {width outLen Q : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} (family : List Bool → List Bool → List Bool) (guessBatch : ℕ × ℕ → ProbComp (List (List Bool))) (n maxBlocks : ℕ) (hBudget : ∀ guesses ∈ (guessBatch (n, n)).eval.support, guesses.length ≤ Q n) (hBlocks : ∀ (word : List Bool), valid n word = true → word.length / width n ≤ maxBlocks) (hAlphabet : maxBlocks * Q n < 2 ^ width n) (hDomain : ∀ {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) (hExtend : ∀ {key left right block : List Bool}, key.length = n → valid n left = true → valid n right = true → block.length = width n → family key left = family key right → family key (left ++ block) = family key (right ++ block)) :
(multiQueryGame pure (fun (x d : ℕ) => valid d) (fun (x d : ℕ) (key : BitString d) => family (List.ofFn key)) guessBatch n).succProbability ≤ Game.advantage (prfRealGameOn oracleValid family (prefixFreeBatchReduction width outLen Q valid guessBatch) n).eval (prfIdealGameOn oracleValid outLen (prefixFreeBatchReduction width outLen Q valid guessBatch) n).eval + ↑((Q n).choose 2) / 2 ^ outLen n

The concrete comparison in [BS23], v0.6, Theorem 7.4 (printed pp. 259–260, equation (7.9)). Multi-query collision success is at most the prefix-free wrapper's PRF advantage plus the birthday term. The bound keeps (Q n).choose 2 from the ideal-game analysis, which is at most the book's Q ^ 2 / 2.

A strict PPT batch guesser on the duplicated unary parameter has a unary polynomial-time cap on the length of every supported list of guesses.

theorem Cslib.Crypto.UHF.isMultiQueryUHF_of_extendable_prefixFreePRF {width outLen maxBlocks : ℕ → ℕ} {valid oracleValid : ℕ → List Bool → Bool} {family : List Bool → List Bool → List Bool} (hPRF : PrefixFreePseudorandomFunctionOn oracleValid outLen family) (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => valid p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) (haligned : ∀ (n : ℕ) (word : List Bool), valid n word = true → 0 < width n ∧ width n ∣ word.length) (hBlocks : ∀ (n : ℕ) (word : List Bool), valid n word = true → word.length / width n ≤ maxBlocks n) (hMaxBlocks : PolynomiallyBounded maxBlocks) (hDomain : ∀ {n : ℕ} {word block : List Bool}, valid n word = true → block.length = width n → oracleValid n (word ++ block) = true) (hProbe : ∀ᶠ (n : ℕ) in Filter.atTop, oracleValid n (List.replicate (width n) false) = true) (hExtend : ∀ {n : ℕ} {key left right block : List Bool}, key.length = n → valid n left = true → valid n right = true → block.length = width n → family key left = family key right → family key (left ++ block) = family key (right ++ block)) (hAlphabet : Negligible fun (n : ℕ) => (2 ^ width n)⁻¹) (hOutput : Negligible fun (n : ℕ) => (2 ^ outLen n)⁻¹) :
IsMultiQueryUHF Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits pure (fun (x d : ℕ) => valid d) fun (x d : ℕ) (key : BitString d) => family (List.ofFn key)

Boneh–Shoup v0.6, Theorem 7.4 (printed pp. 259–260), in the word model. An extendable prefix-free PRF is a multi-query UHF on the smaller domain when the reciprocals of the block and reply alphabet sizes are negligible and the block-count cap is polynomially bounded.

The key has n uniform bits and the public input is the unary parameter. The word model uses polynomial-time unary block width and polynomial-time recognition of the smaller domain. Its words are whole positive-width blocks. One-block extensions lie in the PRF domain, which eventually contains the all-zero block, as it does in the source's domain of at most one extra block. Evaluation on that public block at a zero key recovers the reply width. The adversary's strict PPT certificate gives a polynomial query cap. The two games compare raw bit-list digests, representing the fixed-width replies on the source's domain.