Documentation

CslibFrontier.Crypto.Computational.NaorYungUOWHF

Naor–Yung universal one-way hash functions from one-way permutations #

Naor and Yung ([NY89], Section 3; §§2.1–2.3 in the March 13, 1995 manuscript revision; see also [Gol04], Section 6.4.3.2, June 2003 chapter draft Construction 6.4.20 and Proposition 6.4.21) construct a universal one-way (target collision-resistant) hash family from any one-way permutation f without collision-free trapdoors. This module is about that hash construction only. It is not the Naor–Yung public-key encryption scheme secure against non-adaptive chosen-ciphertext attacks (CCA1), which comes from a different paper and which the library does not formalize. Rather than pairing f with an (m - 1) × m affine/Toeplitz universal hash, this module uses a direct {0, δ}-coset pivot-deletion quotient on m-bit shift keys δ so that the single-step reduction has exact loss 1 and zero additive error:

  1. One-bit quotient (m → m - 1): given a shift δ ∈ {0, 1}^m whose first true coordinate is p < m (0 when δ = 0^m), quotient {0, 1}^m by {0, δ} by XORing with δ whenever bit p is true (naorYungCanon) and deleting bit p (naorYungShrink). When δ ≠ 0^m, every nontrivial collision y₀ ≠ y₁ under naorYungShrink m δ forces y₁ = y₀ ⊕ δ.
  2. Single-step (n + 2) → (n + 1) UOWHF (naorYungStep f): composing f on (n + 2)-bit inputs with naorYungShrink (n + 2) δ yields a 1-bit shrinking target collision-resistant family. Given a random challenge y = f x* in inversionGame f _ (n + 2) and the adversary's committed target w₀, planting δ := f w₀ ⊕ y produces an exact uniform (n + 2)-bit key, and any valid target collision w₁ ≠ w₀ satisfies either f w₀ = y (δ = 0^{n+2}) or f w₁ = f w₀ ⊕ δ = y (δ ≠ 0^{n+2}), inverting y with security loss 1.
  3. Iterated 2(n + 1) → (n + 1) compression (naorYungCompression) and arbitrary-length hashing (naorYungHash): cascading n + 1 steps with independent (n + 2)-bit subkeys compresses 2(n + 1) bits to n + 1 bits (KeyedCompressionFamily), and composing with KeyedCompressionFamily.treeHash yields an unrestricted target collision-resistant KeyedHashFamily on all List Bool (within treeHash's < 2 ^ n finite-parameter tree capacity, which covers all strict-PPT adversaries asymptotically).

Main definitions #

Main results #

References #

One-bit coset quotient m → m - 1 #

First coordinate < m at which δ is true, defaulting to 0 when the m-bit prefix of δ is all false.

theorem Cslib.Crypto.naorYungPivot_lt {m : ℕ} (hm : 1 ≤ m) (δ : List Bool) :
theorem Cslib.Crypto.getD_naorYungPivot_of_exists {m : ℕ} {δ : List Bool} (h : ∃ i < m, δ.getD i false = true) :

Computing naorYungPivot is plain polynomial-time on unary m and raw bit string δ.

Canonical {0, δ}-coset representative of y at width m: normalize y to width m and XOR with δ when coordinate naorYungPivot m δ is true.

@[simp]

Naor–Yung 1-bit quotient m → m - 1: canonicalize bit p := naorYungPivot m δ via naorYungCanon m δ y and delete coordinate p.

@[simp]
theorem Cslib.Crypto.naorYungShrink_collision_eq_listXor {m : ℕ} {δ y₀ y₁ : List Bool} (hδ : ∃ i < m, δ.getD i false = true) (hy₀ : y₀.length = m) (hy₁ : y₁.length = m) (hne : y₀ ≠ y₁) (hcol : naorYungShrink m δ y₀ = naorYungShrink m δ y₁) :
y₁ = BitString.listXor m [y₀, δ]

Collision characterization for naorYungShrink: if δ has a true coordinate below m, any two distinct m-bit strings y₀ ≠ y₁ colliding under naorYungShrink m δ differ by δ, i.e., y₁ = BitString.listXor m [y₀, δ].

Single-step (n + 2) → (n + 1) UOWHF from a one-way permutation #

Single-step Naor–Yung (n + 2) → (n + 1) hash from f: normalize w to n + 2 bits, evaluate f, and apply naorYungShrink (n + 2) δ.

@[simp]
theorem Cslib.Crypto.length_naorYungStep (f : List Bool → List Bool) (n : ℕ) (δ w : List Bool) :
(naorYungStep f n δ w).length = n + 1

Zero-loss preimage reduction from naorYungStep f to inversionGame f (adapting [NY89], Section 3; [Gol04], Section 6.4.3.2, June 2003 draft Proposition 6.4.21): at challenge length m ≥ 2, set n := m - 2, run adversary.choose n to obtain a target w₀ (normalized to n + 2 bits), plant δ := f w₀ ⊕ y, run adversary.find n state δ to obtain w₁, and output whichever of w₁ or w₀ maps to y under f.

naorYungStepInverter is uniformly strict PPT whenever f is plain polynomial-time and adversary is strict PPT.

theorem Cslib.Crypto.succProbability_targetCollisionGame_naorYungStep_le {f : List Bool → List Bool} (hf_len : ∀ (w : List Bool), (f w).length = w.length) (hf_bij : Function.Bijective f) (adversary : TargetCollisionFinder) (n : ℕ) :
Game.succProbability (targetCollisionGame (fun (m : ℕ) => m + 2) (naorYungStep f) (fun (m : ℕ) (w : List Bool) => w.length == m + 2) adversary n).eval ≤ Game.succProbability (inversionGame f (naorYungStepInverter f adversary) (n + 2)).eval

Single-step Naor–Yung security bound: for any length-preserving bijection f, the target-collision success probability of adversary against naorYungStep f at parameter n is at most the preimage-finding success probability of naorYungStepInverter f adversary against f at challenge length n + 2 (with factor 1 and zero additive error).

Single-step Naor–Yung UOWHF theorem (adapting [NY89], Section 3; [Gol04], Section 6.4.3.2, June 2003 draft Construction 6.4.20 and Proposition 6.4.21): if f is a OneWayPermutation, naorYungStep f is target collision-resistant on (n + 2)-bit inputs under (n + 2)-bit keys.

(n + 1)-step cascade 2(n + 1) → (n + 1) (naorYungCompression) #

One step of the Naor–Yung compression cascade: absorb the next bit acc.2.headD false into the (n + 1)-bit state acc.1 via naorYungStep f n δ and advance acc.2 by one bit.

def Cslib.Crypto.naorYungCascade (f : List Bool → List Bool) (n : ℕ) (subkeys : List (List Bool)) (state rest : List Bool) :

Fold naorYungCascadeStep f n across subkeys starting from (state, rest) and return the final (n + 1)-bit state.

theorem Cslib.Crypto.length_naorYungCascade (f : List Bool → List Bool) (n : ℕ) (subkeys : List (List Bool)) {state : List Bool} (hstate : state.length = n + 1) (rest : List Bool) :
(naorYungCascade f n subkeys state rest).length = n + 1
theorem Cslib.Crypto.naorYungCascade_append_singleton (f : List Bool → List Bool) (n : ℕ) (ks : List (List Bool)) (δ state rest : List Bool) :
naorYungCascade f n (ks ++ [δ]) state rest = naorYungStep f n δ (naorYungCascade f n ks state rest ++ [rest.getD ks.length false])

Naor–Yung 2(n + 1) → (n + 1) compression evaluator ([NY89], Section 3; [Gol04], Section 6.4.3.2): split x into two (n + 1)-bit halves and absorb the second half one bit at a time across n + 1 independent (n + 2)-bit subkeys from K.

Step-i (n + 2)-bit input fed to subkey i during naorYungCompressionEval f n, computed using only the prefix front containing subkeys < i.

@[simp]
theorem Cslib.Crypto.length_naorYungCascadeInput (f : List Bool → List Bool) (n i : ℕ) (front x : List Bool) :
(naorYungCascadeInput f n i front x).length = n + 2
theorem Cslib.Crypto.exists_naorYungCascadeInput_collision {f : List Bool → List Bool} {n : ℕ} {K x₀ x₁ : List Bool} (hx₀ : x₀.length = 2 * (n + 1)) (hx₁ : x₁.length = 2 * (n + 1)) (hne : x₀ ≠ x₁) (hcol : naorYungCompressionEval f n K x₀ = naorYungCompressionEval f n K x₁) :
∃ i < n + 1, naorYungCascadeInput f n i K x₀ ≠ naorYungCascadeInput f n i K x₁ ∧ naorYungStep f n (BitString.listRow (n + 2) i K) (naorYungCascadeInput f n i K x₀) = naorYungStep f n (BitString.listRow (n + 2) i K) (naorYungCascadeInput f n i K x₁)

Deterministic step-collision extraction for naorYungCompressionEval: if two distinct 2(n + 1)-bit inputs x₀ ≠ x₁ collide under naorYungCompressionEval f n K, there exists a step i < n + 1 where their (n + 2)-bit step inputs naorYungCascadeInput f n i K are distinct yet collide under naorYungStep f n (BitString.listRow (n + 2) i K).

Planted-subkey reduction from naorYungCompressionEval f to naorYungStep f: guess a dyadic slot slot < n + 1, sample slot prefix (n + 2)-bit subkeys front before seeing the challenge subkey δStar, commit to the step-slot target input naorYungCascadeInput f n slot front x₀, and complete K := front ++ δStar ++ back in Stage 2.

naorYungCascadeAdversary is a uniform strict PPT TargetCollisionFinder whenever f is plain polynomial-time and adversary is strict PPT.

theorem Cslib.Crypto.succProbability_targetCollisionGame_naorYungCompressionEval_le {f : List Bool → List Bool} (adversary : TargetCollisionFinder) (n : ℕ) :
Game.succProbability (targetCollisionGame (fun (m : ℕ) => (m + 1) * (m + 2)) (naorYungCompressionEval f) (fun (m : ℕ) (x : List Bool) => x.length == 2 * (m + 1)) adversary n).eval ≤ ↑(Probability.dyadicSize (n + 1)) * Game.succProbability (targetCollisionGame (fun (m : ℕ) => m + 2) (naorYungStep f) (fun (m : ℕ) (w : List Bool) => w.length == m + 2) (naorYungCascadeAdversary f adversary) n).eval

Concrete security bound for naorYungCompressionEval: the target-collision success probability of adversary against naorYungCompressionEval f at security parameter n is at most dyadicSize (n + 1) times that of naorYungCascadeAdversary f adversary against naorYungStep f.

Naor–Yung KeyedCompressionFamily ([NY89], Section 3; [Gol04], Section 6.4.3.2): compresses 2(n + 1)-bit blocks to (n + 1)-bit blocks under ((n + 1) * (n + 2))-bit keys using any plain polynomial-time function f.

Naor–Yung compression theorem ([NY89], Section 3; [Gol04], Section 6.4.3.2): if f is a OneWayPermutation, naorYungCompression hf.oneWay.polyTime is a target collision-resistant KeyedCompressionFamily.

Naor–Yung unrestricted KeyedHashFamily ([NY89], 1995 revision, Sections 2.3 and 3): hashes arbitrary-length bit strings List Bool to (n + 1)-bit digests under (n + 1)^2 * (n + 2)-bit keys via (naorYungCompression hf).treeHash (inheriting treeHash's < 2 ^ n finite-parameter tree capacity).

Naor–Yung UOWHF theorem ([NY89], 1995 revision, Sections 2.3 and 3; [Gol04], Section 6.4.3.2): if f is a OneWayPermutation, naorYungHash hf.oneWay.polyTime is unrestrictedly target collision-resistant on all List Bool.

Every OneWayPermutation yields an unrestricted target collision-resistant KeyedHashFamily on List Bool.