Documentation

CslibFrontier.Crypto.Computational.Pseudoentropy.HashPair

The hashed parity pair #

Reveal a function image, a random hash length, a public matrix, the corresponding hash prefix, and an independent parity query. The hidden bit is the input's inner product with the query.

joint gives the finite joint distribution and sample is its word implementation. The entropy bound and the strict PPT certificate are proved here. pair packages the sampler and its exact finite law. HashReduction proves the finite prediction-to-inversion bound, WordReduction implements that reduction, and OneWay derives the computational prediction gap.

Main definitions #

Main results #

References #

Adapted from Crypto/Computational/Pseudoentropy/HashPair.lean on the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8, using the shared bit-string and tidy machine APIs.

The number of possible hash lengths. Six extra lengths leave room for the truncation threshold in the inversion proof; rounding up makes sampling exact with fair bits.

Instances For

    Every fiber's logarithmic size plus six lies inside the sampled hash range.

    The enlarged hash range is still linear in the input length.

    Sampling among the enlarged hash lengths requires only a polynomial range.

    Compute the sampling range from an efficiently available unary parameter.

    @[reducible, inline]

    A flat matrix seed and an independent parity query, both retained in the public output.

    structure Cslib.Crypto.Pseudoentropy.HashPair.Observation (n count : ℕ) (Image : Type u_1) :
    Type u_1

    The information revealed by the hashed parity experiment. The digest contains exactly the number of bits selected by the public index.

    • image : Image

      The image of the hidden input under the function being inverted.

    • index : Fin count

      The sampled index; the number of revealed hash bits is index.val + 1.

    • matrix : BitString (count * n)

      The complete public matrix, flattened row by row.

    • digest : BitString (↑self.index + 1)

      The hash of the hidden input under the selected initial rows.

    • query : BitString n

      The independent query whose inner product with the input is hidden.

    Instances For
      instance Cslib.Crypto.Pseudoentropy.HashPair.instFiniteObservation {n count : ℕ} {Image : Type u_1} [Finite Image] :
      Finite (Observation n count Image)
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_image_inO {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Turing.MultiTapeTM.ComputableInO (fun (a : Observation n count Image) => encodeImage a.image) (encObservation encodeImage) Turing.MultiTapeTM.encBits (fun (a : Observation n count Image) => ((encObservation encodeImage) a).length) fun (a : Observation n count Image) => ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_query_inO {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Turing.MultiTapeTM.ComputableInO (fun (a : Observation n count Image) => a.query) (encObservation encodeImage) (Turing.MultiTapeTM.encBitString n) (fun (a : Observation n count Image) => ((encObservation encodeImage) a).length) fun (a : Observation n count Image) => ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_index_inO {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Turing.MultiTapeTM.ComputableInO (fun (a : Observation n count Image) => a.index) (encObservation encodeImage) (Fin.valEmbedding.trans Turing.MultiTapeTM.encUnary) (fun (a : Observation n count Image) => ((encObservation encodeImage) a).length) fun (a : Observation n count Image) => ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_digest_inO {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Turing.MultiTapeTM.ComputableInO (fun (a : Observation n count Image) => List.ofFn a.digest) (encObservation encodeImage) Turing.MultiTapeTM.encBits (fun (a : Observation n count Image) => ((encObservation encodeImage) a).length) fun (a : Observation n count Image) => ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_matrix_budget {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Observation n count Image} :
      Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encObservation encodeImage) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).matrix) encIn✝ (Turing.MultiTapeTM.encBitString (count * n)) S✝
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_digest_polyTime {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Observation n count Image} :
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_query_budget {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Observation n count Image} :
      Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encObservation encodeImage) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).query) encIn✝ (Turing.MultiTapeTM.encBitString n) S✝
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_matrix_inO {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Turing.MultiTapeTM.ComputableInO (fun (a : Observation n count Image) => a.matrix) (encObservation encodeImage) (Turing.MultiTapeTM.encBitString (count * n)) (fun (a : Observation n count Image) => ((encObservation encodeImage) a).length) fun (a : Observation n count Image) => ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_image_budget {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Observation n count Image} :
      Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encObservation encodeImage) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => encodeImage (g✝ c).image) encIn✝ Turing.MultiTapeTM.encBits S✝
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_image_length_le {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) (a : Observation n count Image) :
      (Turing.MultiTapeTM.encBits ((fun (a : Observation n count Image) => encodeImage a.image) a)).length ≤ ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_mk_budget {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Image} {x1 : γ → Fin count} {x2 : γ → BitString (count * n)} {x3 : (c : γ) → Fin (↑(x1 c) + 1) → Bool} {x4 : γ → BitString n} (h0 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => encodeImage (x0 c)) encIn Turing.MultiTapeTM.encBits budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn (Fin.valEmbedding.trans Turing.MultiTapeTM.encUnary) budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn (Turing.MultiTapeTM.encBitString (count * n)) budget) (h3 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => List.ofFn (x3 c)) encIn Turing.MultiTapeTM.encBits budget) (h4 : Turing.MultiTapeTM.ComputableInSpace x4 encIn (Turing.MultiTapeTM.encBitString n) budget) :
      Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { image := x0 x, index := x1 x, matrix := x2 x, digest := x3 x, query := x4 x }) encIn (encObservation encodeImage) budget
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_matrix_length_le {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) (a : Observation n count Image) :
      ((Turing.MultiTapeTM.encBitString (count * n)) ((fun (a : Observation n count Image) => a.matrix) a)).length ≤ ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_mk_inO {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Image} {T0 S0 : γ → ℕ} {x1 : γ → Fin count} {T1 S1 : γ → ℕ} {x2 : γ → BitString (count * n)} {T2 S2 : γ → ℕ} {x3 : (c : γ) → Fin (↑(x1 c) + 1) → Bool} {T3 S3 : γ → ℕ} {x4 : γ → BitString n} {T4 S4 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => encodeImage (x0 c)) encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Fin.valEmbedding.trans Turing.MultiTapeTM.encUnary) T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn (Turing.MultiTapeTM.encBitString (count * n)) T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => List.ofFn (x3 c)) encIn Turing.MultiTapeTM.encBits T3 S3) (h4 : Turing.MultiTapeTM.ComputableInO x4 encIn (Turing.MultiTapeTM.encBitString n) T4 S4) :
      Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { image := x0 x, index := x1 x, matrix := x2 x, digest := x3 x, query := x4 x }) encIn (encObservation encodeImage) (fun (x : γ) => T0 x + (T1 x + (T2 x + (T3 x + T4 x)))) fun (x : γ) => S0 x + (S1 x + (S2 x + (S3 x + S4 x)))
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_fields_deg {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Turing.MultiTapeTM.ComputableInDegree (fun (a : Observation n count Image) => (encodeImage a.image, a.index, a.matrix, List.ofFn a.digest, a.query)) (encObservation encodeImage) (encObservationFields encodeImage) 1 1
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_digest_budget {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Observation n count Image} :
      Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encObservation encodeImage) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => List.ofFn (g✝ c).digest) encIn✝ Turing.MultiTapeTM.encBits S✝
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_matrix_deg {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_index_polyTime {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Observation n count Image} :
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_mk_polyTime {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Image} {x1 : γ → Fin count} {x2 : γ → BitString (count * n)} {x3 : (c : γ) → Fin (↑(x1 c) + 1) → Bool} {x4 : γ → BitString n} (h0 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => encodeImage (x0 c)) encIn Turing.MultiTapeTM.encBits) (h1 : Turing.MultiTapeTM.ComputableInPolyTime x1 encIn (Fin.valEmbedding.trans Turing.MultiTapeTM.encUnary)) (h2 : Turing.MultiTapeTM.ComputableInPolyTime x2 encIn (Turing.MultiTapeTM.encBitString (count * n))) (h3 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => List.ofFn (x3 c)) encIn Turing.MultiTapeTM.encBits) (h4 : Turing.MultiTapeTM.ComputableInPolyTime x4 encIn (Turing.MultiTapeTM.encBitString n)) :
      Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { image := x0 x, index := x1 x, matrix := x2 x, digest := x3 x, query := x4 x }) encIn (encObservation encodeImage)
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_image_deg {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Turing.MultiTapeTM.ComputableInDegree (fun (a : Observation n count Image) => encodeImage a.image) (encObservation encodeImage) Turing.MultiTapeTM.encBits 1 1
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_index_budget {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Observation n count Image} :
      @[simp]
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_apply {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) (a : Observation n count Image) :
      (encObservation encodeImage) a = (encObservationFields encodeImage) (encodeImage a.image, a.index, a.matrix, List.ofFn a.digest, a.query)
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_query_length_le {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) (a : Observation n count Image) :
      ((Turing.MultiTapeTM.encBitString n) ((fun (a : Observation n count Image) => a.query) a)).length ≤ ((encObservation encodeImage) a).length
      def Cslib.Crypto.Pseudoentropy.HashPair.encObservation {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :
      Observation n count Image ↪ List Bool

      Encode the image, unary index, matrix bits, digest bits and query bits in that order. Every field except the final query is self-delimited.

      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_query_polyTime {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Observation n count Image} :
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_image_polyTime {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Observation n count Image} :
      Turing.MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encObservation encodeImage) → Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => encodeImage (g✝ c).image) encIn✝ Turing.MultiTapeTM.encBits
      @[reducible, inline]
      abbrev Cslib.Crypto.Pseudoentropy.HashPair.encObservationFields {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) :

      The tuple of the fields of encObservation.

      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_matrix_polyTime {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Observation n count Image} :
      Turing.MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encObservation encodeImage) → Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).matrix) encIn✝ (Turing.MultiTapeTM.encBitString (count * n))
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_index_length_le {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) (a : Observation n count Image) :
      ((Fin.valEmbedding.trans Turing.MultiTapeTM.encUnary) ((fun (a : Observation n count Image) => a.index) a)).length ≤ ((encObservation encodeImage) a).length
      theorem Cslib.Crypto.Pseudoentropy.HashPair.encObservation_digest_length_le {n count : ℕ} {Image : Type u_1} (encodeImage : Image ↪ List Bool) (a : Observation n count Image) :
      (Turing.MultiTapeTM.encBits ((fun (a : Observation n count Image) => List.ofFn a.digest) a)).length ≤ ((encObservation encodeImage) a).length
      def Cslib.Crypto.Pseudoentropy.HashPair.prefixHash {n count : ℕ} (i : Fin count) (seed : Seed n count) (x : BitString n) :
      BitString (↑i + 1)

      Hash with the requested initial rows of the public matrix.

      The query can be included in the public seed without changing hash universality.

      noncomputable def Cslib.Crypto.Pseudoentropy.HashPair.joint {n count : ℕ} [NeZero count] {Image : Type u_1} (f : BitString n → Image) :
      PMF (Observation n count Image × Bool)

      The public observation and hidden parity bit under independent uniform inputs.

      theorem Cslib.Crypto.Pseudoentropy.HashPair.conditionalEntropy_joint_le {n count : ℕ} [NeZero count] {Image : Type u_1} [Finite Image] (f : BitString n → Image) :
      Probability.PMF.conditionalEntropy (joint f) ≤ ((∑ x : BitString n, Real.logb 2 ↑(Nat.card { y : BitString n // f y = f x })) / 2 ^ n + 2) / ↑count

      Holenstein's entropy bound for the complete hashed parity experiment. No regularity, injectivity, or computational hardness of the function is assumed.

      def Cslib.Crypto.Pseudoentropy.HashPair.wordObservation (image : List Bool) (index : ℕ) (matrix digest query : List Bool) :

      Self-delimiting encoding of the five public fields.

      Assemble the public fields using the ordinary tuple encoding.

      def Cslib.Crypto.Pseudoentropy.HashPair.encodeObservation {n count : ℕ} {Image : Type u_1} (encodeImage : Image → List Bool) (observation : Observation n count Image) :

      Write a finite observation using any image map, without assuming that map is injective. For an injective image encoding this is exactly encObservation.

      Sample the hashed parity pair using only fair bits and ordinary word operations.

      theorem Cslib.Crypto.Pseudoentropy.HashPair.eval_sample {n : ℕ} {Image : Type u_1} (f : List Bool → List Bool) (finiteFunction : BitString n → Image) (encodeImage : Image → List Bool) (hf : ∀ (x : Fin n → Bool), f (List.ofFn x) = encodeImage (finiteFunction x)) :
      (sample f n).eval = PMF.map (fun (pair : Observation n (hashCount n) Image × Bool) => (encodeObservation encodeImage pair.1, pair.2)) (joint finiteFunction)

      The executable observation and hidden bit have exactly the finite joint distribution.

      noncomputable def Cslib.Crypto.Pseudoentropy.HashPair.pair {Image : ℕ → Type} [∀ (n : ℕ), Finite (Image n)] (f : List Bool → List Bool) (hf : Turing.MultiTapeTM.ComputableInPolyTime f Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (finiteFunction : (n : ℕ) → BitString n → Image n) (encodeImage : (n : ℕ) → Image n ↪ List Bool) (hencode : ∀ (n : ℕ) (x : Fin n → Bool), f (List.ofFn x) = (encodeImage n) (finiteFunction n x)) :

      Package the efficient sampler with its finite observation type and exact joint law. The image representation is needed for entropy bookkeeping, not as an extra algorithmic oracle.