Documentation

CslibFrontier.Crypto.Computational.InaccessibleEntropy.EntropyReduction

Accessible-entropy reduction and 1-bit shrinking output hashing #

Following [HHRVW2020], Sections 5.1.2–5.1.3 (Lemmas 5.4 and 5.5, pp. 27–29), this module transforms a function $F_1 : \{0, 1\}^{n_1} \to \{0, 1\}^{m_1}$ whose real sample entropy exceeds $K_{\min}$ except on a small bad set, and whose accessible set $L_1(z)$ has $\log_2 |L_1(z)| < A_{\max}$ except on a small bad set, into a strictly $1$-bit shrinking function $F_3^{(j)} : \{0, 1\}^{N_3} \to \{0, 1\}^{N_3 - 1}$ ($1 \le n_1$) that is collision-resistant on random inputs whenever $A_{\max} \ll j \ll K_{\min}$:

  1. Input-hash entropy reduction $F_2^{(j)}$ (inputHashFin, inputHashEvalWord, Lemma 5.4, pp. 27–28): using a fixed-width $n_1 \times n_1$ Boolean matrix inRows so that the input width inputHashInLen n₁ = n₁ + n₁ * n₁ and output width inputHashOutLen n₁ m₁ = m₁ + n₁ * n₁ + n₁ are independent of the truncation parameter $j$, define $$F_2^{(j)}(z, \mathrm{inRows}) = \bigl(F_1(z),\; \mathrm{inRows},\; \mathrm{zeroPadPrefix}\;n_1\;j\;(\mathrm{hash}\;\mathrm{inRows}\;z)\bigr).$$ By LinearHash.isTwoUniversal_prefix and IsTwoUniversal.collision_with_set_le, any input $z$ has probability at most $|L_1(z)| / 2^{\min(j, n_1)}$ over inRows of colliding under $F_2^{(j)}$ with a distinct $z' \in L_1(z)$ (inputHashFin_accessible_collision_le). Meanwhile, partitioning inputs around {z | realSampleEntropy f₁ z ≤ K_min} bounds the total image size $|F_2^{(j)}(\{0, 1\}^{n_2})|$ directly (card_image_inputHashFin_le, Equation (5.6), p. 29).
  2. Output-hash s-bit shrinkage $F_3^{(j)}$ (shrunkHashFin, shrunkHashEvalWord, Lemma 5.5, Equations (5.6)–(5.7), p. 29): hashing $F_2^{(j)}(w)$ to outHashLen n₁ s = inputHashInLen n₁ - s bits via a public Boolean matrix outRows yields shrunkHashInLen n₁ m₁ s = shrunkHashOutLen n₁ m₁ s + s whenever s ≤ inputHashInLen n₁ (shrunkHashOutLen_add_shrink), while LinearHash.isTwoUniversal bounds false-positive output-hash collisions (shrunkHashFin_false_positive_le, Equation (5.7), p. 29).
  3. Random-input collision-to-escape reduction (randomCollisionGame, shrunkHashEscapeInverter, isPPT_shrunkHashEscapeInverter, shrunkHash_randomCollision_le): padding a challenge $z$ with uniform (inRows, outRows) — via a uniform strict-PPT reduction independent of $j$ — reduces random-input collisions of $F_3^{(j)}$ to escaping $L_1$ plus the two concentration tails and two universal-hash error terms (with output-hash factor $2^{s(n)}$).

Main definitions #

Main results #

References #

Bit-width schedule and structured views for $F_2^{(j)}$ and $F_3^{(j)}$ #

Input bit width $n_2 = n_1 + n_1^2$ of $F_2^{(j)}$, independent of $j$.

Output bit width $m_2 = m_1 + n_1^2 + n_1$ of $F_2^{(j)}$, independent of $j$.

Digest bit width $n_2 - s$ of the output hash in $F_3^{(j)}$.

def Cslib.Crypto.shrunkHashInLen (n₁ m₁ s : ℕ) :

Input bit width $N_3 = n_2 + (n_2 - s) m_2$ of $F_3^{(j)}$.

Output bit width $M_3 = (n_2 - s) m_2 + (n_2 - s)$ of $F_3^{(j)}$.

theorem Cslib.Crypto.shrunkHashOutLen_add_shrink {n₁ s : ℕ} (hs : s ≤ inputHashInLen n₁) (m₁ : ℕ) :
shrunkHashOutLen n₁ m₁ s + s = shrunkHashInLen n₁ m₁ s

When s ≤ inputHashInLen n₁, $F_3^{(j)}$ shrinks its input by s bits.

Structured input (base, inRows) to $F_2^{(j)}$ ([HHRVW2020], Section 5.1.2, Lemma 5.4, pp. 27–28).

  • base : BitString n₁

    Base $n_1$-bit input $z$ to $F_1$.

  • inRows : Fin n₁ → BitString n₁

    Public $n_1 \times n_1$ Boolean matrix rows of the two-universal input hash.

Instances For

    Pack an InputHashedInput n₁ into a word of length inputHashInLen n₁.

    Exact bit-string equivalence between InputHashedInput n₁ and BitString (inputHashInLen n₁).

    @[instance_reducible]
    structure Cslib.Crypto.InputHashedOutput (n₁ m₁ : ℕ) :

    Structured output (baseOut, inRows, inDigest) of $F_2^{(j)}$ ([HHRVW2020], Section 5.1.2, Lemma 5.4, pp. 27–28).

    • baseOut : BitString m₁

      Base output $F_1(z) \in \{0, 1\}^{m_1}$.

    • inRows : Fin n₁ → BitString n₁

      Public $n_1 \times n_1$ Boolean matrix rows of the input hash.

    • inDigest : BitString n₁

      Zero-padded $\min(j, n_1)$-bit prefix of $\mathrm{hash}\;\mathrm{inRows}\;z$.

    Pack an InputHashedOutput n₁ m₁ into a word of length inputHashOutLen n₁ m₁.

    Unpack a word into an InputHashedOutput n₁ m₁.

    @[simp]
    theorem Cslib.Crypto.InputHashedOutput.packWord_unpackWord {n₁ m₁ : ℕ} {u : List Bool} (hu : u.length = inputHashOutLen n₁ m₁) :
    (unpackWord n₁ m₁ u).packWord = u

    Exact bit-string equivalence between InputHashedOutput n₁ m₁ and BitString (inputHashOutLen n₁ m₁).

    structure Cslib.Crypto.ShrunkHashInput (n₁ m₁ s : ℕ) :

    Structured input (inner, outRows) to $F_3^{(j)}$ ([HHRVW2020], Section 5.1.3, Lemma 5.5, p. 29).

    Instances For
      def Cslib.Crypto.ShrunkHashInput.packWord {n₁ m₁ s : ℕ} (v : ShrunkHashInput n₁ m₁ s) :

      Pack a ShrunkHashInput n₁ m₁ s into a word of length shrunkHashInLen n₁ m₁ s.

      @[simp]
      theorem Cslib.Crypto.ShrunkHashInput.length_packWord {n₁ m₁ s : ℕ} (v : ShrunkHashInput n₁ m₁ s) :
      def Cslib.Crypto.ShrunkHashInput.unpackWord (n₁ m₁ s : ℕ) (raw : List Bool) :
      ShrunkHashInput n₁ m₁ s

      Unpack a word into a ShrunkHashInput n₁ m₁ s.

      @[simp]
      theorem Cslib.Crypto.ShrunkHashInput.unpackWord_packWord {n₁ m₁ s : ℕ} (v : ShrunkHashInput n₁ m₁ s) :
      unpackWord n₁ m₁ s v.packWord = v
      theorem Cslib.Crypto.ShrunkHashInput.packWord_unpackWord {n₁ m₁ s : ℕ} {raw : List Bool} (hraw : raw.length = shrunkHashInLen n₁ m₁ s) :
      (unpackWord n₁ m₁ s raw).packWord = raw
      structure Cslib.Crypto.ShrunkHashOutput (n₁ m₁ s : ℕ) :

      Structured output (outRows, outDigest) of $F_3^{(j)}$ ([HHRVW2020], Section 5.1.3, Lemma 5.5, p. 29).

      Pack a ShrunkHashOutput n₁ m₁ s into a word of length shrunkHashOutLen n₁ m₁ s.

      @[simp]

      Unpack a word into a ShrunkHashOutput n₁ m₁ s.

      @[simp]
      theorem Cslib.Crypto.ShrunkHashOutput.unpackWord_packWord {n₁ m₁ s : ℕ} (y : ShrunkHashOutput n₁ m₁ s) :
      unpackWord n₁ m₁ s y.packWord = y

      Step 2: Input-hash entropy reduction $F_2^{(j)}$ (Lemma 5.4 and Equation (5.6)) #

      def Cslib.Crypto.inputHashFin {n₁ m₁ : ℕ} (f₁ : BitString n₁ → BitString m₁) (j : ℕ) (w : InputHashedInput n₁) :

      Finite evaluator $F_2^{(j)}(z, \mathrm{inRows}) = (F_1(z), \mathrm{inRows}, \mathrm{zeroPadPrefix}\;n_1\;j\;(\mathrm{hash}\;\mathrm{inRows}\;z))$ ([HHRVW2020], Section 5.1.2, Lemma 5.4, pp. 27–28).

      theorem Cslib.Crypto.inputHashFin_accessible_collision_le {n₁ m₁ : ℕ} (f₁ : BitString n₁ → BitString m₁) (j : ℕ) (L : Finset (BitString n₁)) (z : BitString n₁) :
      (∑ rows : Fin n₁ → BitString n₁, if ∃ z' ∈ L, z' ≠ z ∧ inputHashFin f₁ j { base := z', inRows := rows } = inputHashFin f₁ j { base := z, inRows := rows } then ((Probability.PMF.uniformOfFintype (Fin n₁ → BitString n₁)) rows).toReal else 0) ≤ ↑L.card / 2 ^ min j n₁

      [HHRVW2020], Section 5.1.2, Lemma 5.4(ii) (p. 28): by two-universality of matrix prefixes (LinearHash.isTwoUniversal_prefix), the probability over inRows that some distinct $z' \in L$ collides with $z$ under inputHashFin f₁ j is at most $|L| / 2^{\min(j, n_1)}$.

      theorem Cslib.Crypto.card_image_inputHashFin_le {n₁ m₁ : ℕ} (f₁ : BitString n₁ → BitString m₁) (j : ℕ) (K : ℝ) :

      [HHRVW2020], Section 5.1.3, Lemma 5.5, Equation (5.6) (p. 29): partitioning inputs around {z | realSampleEntropy f₁ z ≤ K} bounds the image cardinality of inputHashFin f₁ j by $(\Pr[H_z \le K] + 2^{\min(j, n_1) - K}) \cdot 2^{n_2}$.

      Step 3: Output-hash s-bit shrinkage $F_3^{(j)}$ (Lemma 5.5 and Equation (5.7)) #

      def Cslib.Crypto.shrunkHashFin {n₁ m₁ : ℕ} (f₁ : BitString n₁ → BitString m₁) (j s : ℕ) (v : ShrunkHashInput n₁ m₁ s) :
      ShrunkHashOutput n₁ m₁ s

      Finite evaluator $F_3^{(j)}(w, \mathrm{outRows}) = (\mathrm{outRows}, \mathrm{hash}\;\mathrm{outRows}\;(\mathrm{enc}(F_2^{(j)}(w))))$ with s-bit shrinkage (outHashLen n₁ s = inputHashInLen n₁ - s; [HHRVW2020], Section 5.1.3, Lemma 5.5, p. 29).

      theorem Cslib.Crypto.shrunkHashFin_false_positive_le {n₁ m₁ : ℕ} (f₁ : BitString n₁ → BitString m₁) (j s : ℕ) (w : InputHashedInput n₁) :
      (∑ outRows : Fin (outHashLen n₁ s) → BitString (inputHashOutLen n₁ m₁), if ∃ (w' : InputHashedInput n₁), inputHashFin f₁ j w' ≠ inputHashFin f₁ j w ∧ shrunkHashFin f₁ j s { inner := w', outRows := outRows } = shrunkHashFin f₁ j s { inner := w, outRows := outRows } then ((Probability.PMF.uniformOfFintype (Fin (outHashLen n₁ s) → BitString (inputHashOutLen n₁ m₁))) outRows).toReal else 0) ≤ ↑(Finset.image (inputHashFin f₁ j) Finset.univ).card / 2 ^ outHashLen n₁ s

      [HHRVW2020], Section 5.1.3, Lemma 5.5, Equation (5.7) (p. 29): for every fixed input $w$, the probability over outRows that some $w'$ with $F_2^{(j)}(w') \ne F_2^{(j)}(w)$ collides with $w$ under shrunkHashFin f₁ j s is at most $|F_2^{(j)}(\{0, 1\}^{n_2})| / 2^{\mathrm{outHashLen}\;n_1\;s}$.

      Word-level evaluators and polynomial-time certificates #

      def Cslib.Crypto.inputHashEvalWord (n₁ m₁ : ℕ) (evalWord₁ : List Bool → List Bool) (j : ℕ) (u : List Bool) :

      Word-level evaluator of $F_2^{(j)}$ ([HHRVW2020], Section 5.1.2, Lemma 5.4, pp. 27–28).

      def Cslib.Crypto.shrunkHashEvalWord (n₁ m₁ : ℕ) (evalWord₁ : List Bool → List Bool) (j s : ℕ) (raw : List Bool) :

      Word-level evaluator of $F_3^{(j)}$ with s-bit shrinkage ([HHRVW2020], Section 5.1.3, Lemma 5.5, p. 29).

      @[simp]
      theorem Cslib.Crypto.length_inputHashEvalWord (n₁ m₁ : ℕ) (evalWord₁ : List Bool → List Bool) (j : ℕ) (u : List Bool) :
      (inputHashEvalWord n₁ m₁ evalWord₁ j u).length = inputHashOutLen n₁ m₁
      @[simp]
      theorem Cslib.Crypto.length_shrunkHashEvalWord (n₁ m₁ : ℕ) (evalWord₁ : List Bool → List Bool) (j s : ℕ) (raw : List Bool) :
      (shrunkHashEvalWord n₁ m₁ evalWord₁ j s raw).length = shrunkHashOutLen n₁ m₁ s
      theorem Cslib.Crypto.inputHashEvalWord_packWord {n₁ m₁ : ℕ} (evalWord₁ : List Bool → List Bool) (j : ℕ) (w : InputHashedInput n₁) :
      inputHashEvalWord n₁ m₁ evalWord₁ j w.packWord = (inputHashFin (wordToFinMap n₁ m₁ evalWord₁) j w).packWord
      theorem Cslib.Crypto.shrunkHashEvalWord_packWord {n₁ m₁ s : ℕ} (evalWord₁ : List Bool → List Bool) (j : ℕ) (v : ShrunkHashInput n₁ m₁ s) :
      shrunkHashEvalWord n₁ m₁ evalWord₁ j s v.packWord = (shrunkHashFin (wordToFinMap n₁ m₁ evalWord₁) j s v).packWord

      Random-input collision game and combined reduction to $L_1$-escape #

      noncomputable def Cslib.Crypto.randomCollisionGame (evalWord : ℕ → List Bool → List Bool) (inLen : ℕ → ℕ) (A : ℕ → List Bool → ProbComp (List Bool)) (n : ℕ) :

      Security experiment for collision resistance on random inputs ([HHRVW2020], Section 3.1, p. 13, and Section 5.1.3, Lemma 5.5, p. 29): draw a uniform (inLen n)-bit input xWord, run A, and accept when A returns a distinct (inLen n)-bit input with the same evalWord n image.

      noncomputable def Cslib.Crypto.shrunkHashEscapeInverter (n₁ m₁ s : ℕ → ℕ) (A : ℕ → List Bool → ProbComp (List Bool)) (n : ℕ) (zWord : List Bool) :

      Uniform strict-PPT reduction from random-input collisions of $F_3^{(j)}$ to $F_1$ accessible escape ([HHRVW2020], Lemmas 5.4(ii) and 5.5, pp. 28–29). Note that the reduction does not depend on the grid truncation length $j$: it pads the $n_1$-bit challenge zWord with uniform (inSeed, outSeed), runs A, and extracts the $n_1$-bit prefix.

      theorem Cslib.Crypto.shrunkHash_randomCollision_le (n₁ m₁ j s : ℕ → ℕ) (evalWord₁ : ℕ → List Bool → List Bool) (L₁ : (n : ℕ) → BitString (n₁ n) → Finset (BitString (n₁ n))) (A : ℕ → List Bool → ProbComp (List Bool)) (n : ℕ) (hs : s n ≤ inputHashInLen (n₁ n)) (hlen₁ : ∀ (u : List Bool), u.length = n₁ n → (evalWord₁ n u).length = m₁ n) (A_max K_min : ℝ) :
      have f₁ := wordToFinMap (n₁ n) (m₁ n) (evalWord₁ n); ↑(Game.succProbability (randomCollisionGame (fun (k : ℕ) => shrunkHashEvalWord (n₁ k) (m₁ k) (evalWord₁ k) (j k) (s k)) (fun (k : ℕ) => shrunkHashInLen (n₁ k) (m₁ k) (s k)) A n).eval) ≤ ↑(Game.succProbability (accessibleEscapeGame evalWord₁ n₁ L₁ (shrunkHashEscapeInverter n₁ m₁ s A) n).eval) + ((Probability.PMF.uniformOfFintype (BitString (n₁ n))).toOuterMeasure {z : BitString (n₁ n) | A_max ≤ Real.logb 2 ↑(L₁ n z).card}).toReal + 2 ^ (A_max - min ↑(j n) ↑(n₁ n)) + 2 ^ s n * (((Probability.PMF.uniformOfFintype (BitString (n₁ n))).toOuterMeasure {z : BitString (n₁ n) | realSampleEntropy f₁ z ≤ K_min}).toReal + 2 ^ (min ↑(j n) ↑(n₁ n) - K_min))

      Combined concrete bound for [HHRVW2020], Sections 5.1.2–5.1.3, Lemmas 5.4 and 5.5 (pp. 27–29): when s n ≤ inputHashInLen (n₁ n), random-input collision success on shrunkHashEvalWord at truncation parameter j n and shrinkage s n is bounded by the $L_1$-escape probability of shrunkHashEscapeInverter plus the two concentration tails (A_max ≤ log₂ |L₁(z)| and realSampleEntropy f₁ z ≤ K_min) and the two universal-hash error terms 2 ^ (A_max - min (j n) (n₁ n)) and 2 ^ (s n) * 2 ^ (min (j n) (n₁ n) - K_min).