Documentation

CslibFrontier.Crypto.Computational.HashAndSign

The Hash-and-Sign Paradigm from Collision-Resistant Hashing #

This module formalizes the single-public-key hash-and-sign paradigm ([KL20], Section 13.3, Construction 13.3 and Theorem 13.4, pp. 467–468), which upgrades a fixed-length SignatureScheme signing n-bit digests at security parameter n to an unrestricted WordSignatureScheme signing arbitrary bit strings msg : List Bool using a collision-resistant hash family H.

At security parameter n:

Unlike the target collision-resistant construction TCRSignature.wordScheme ([BS23], Section 13.2.1), which must sample a fresh hash key per signature and attach it to every signature because a universal one-way hash family cannot expose its key before the target message is chosen, full collision resistance allows a single hash key s to be fixed once in the public key so that signatures carry no hash-key overhead (sign returns a raw S-signature). Following CollisionResistant and HashFamily, hash keys and digests both have length n with uniform key sampling, specializing Construction 13.3 to digest length ℓ(n) = n and uniform Gen.

For the security reduction ([KL20], Theorem 13.4, p. 468), any execution of an EUFCMA forger producing a fresh valid forgery (m*, σ*) against HashAndSign.scheme splits pointwise into two cases:

  1. If some queried message m ∈ queried satisfies H s m = H s m*, then m ≠ m* (since m* ∉ queried), so HashAndSign.collisionFinder extracts a hash collision (m*, m) under the challenge key s.
  2. Otherwise H s m* ∉ queried.map (H s) and (H s m*).length = n, so HashAndSign.baseForger forwards (H s m*, σ*) as a fresh valid n-bit forgery in S.eufCmaGame.

This yields the tight pointwise bound succProbability_eufCmaGame_le with loss factor 1 on both terms, and hence SignatureScheme.EUFCMA.wordEUFCMA_hashAndSign, SignatureScheme.EUFCMA.wordEUFCMA_of_hashFamily, and SignatureScheme.EUFCMA.wordEUFCMA_merkleDamgard.

In the negative direction, HashAndSign.not_eufCMA_scheme_of_collision shows that key-independent collisions break the scheme: if two distinct messages m₀ ≠ m₁ collide under every hash key s, a one-query forger queries m₀ and outputs its signature on m₁, winning eufCmaGame with probability 1 at every security parameter n regardless of the underlying SignatureScheme S.

Main definitions #

Main results #

References #

Construction 13.3: Single-Key Hash-and-Sign Scheme #

Key generation for Construction 13.3 ([KL20], p. 468): sample (pk₀, sk₀) ← S.keyGen n and a single n-bit hash key s ← {0, 1}^n, returning ⟨pk₀, s⟩ and ⟨sk₀, s⟩.

Signing for Construction 13.3 ([KL20], p. 468): decode (sk₀, s) from sk and sign the digest H s msg under sk₀.

Verification for Construction 13.3 ([KL20], p. 468): decode (pk₀, s) from pk and verify sig on the digest H s msg under pk₀.

Support characterization for HashAndSign.keyGen: every generated key pair packs a valid base key pair keys₀ ∈ (ProbComp.eval (S.keyGen n)).support with an n-bit hash key s.

theorem Cslib.Crypto.HashAndSign.verify_sign (S : SignatureScheme) (H : List Bool → List Bool → List Bool) (hlen : ∀ (s msg : List Bool), (H s msg).length = s.length) (n : ℕ) (pk sk : List Bool) (hkeys : (pk, sk) ∈ (keyGen S n).eval.support) (msg sig : List Bool) (hsig : sig ∈ (sign S H sk msg).eval.support) :
verify S H pk msg sig = true

Correctness of Construction 13.3: for any length-preserving hash family (|H s msg| = |s|), every signature produced by HashAndSign.sign under a honestly generated key pair verifies for any arbitrary-length message msg : List Bool.

Construction 13.3 ([KL20], Section 13.3, p. 468): the single-public-key hash-and-sign WordSignatureScheme built from a fixed-length SignatureScheme S and a length-preserving hash family H.

Theorem 13.4: Reductions to Collision Finding and Fixed-Length Forgery #

Extract a colliding message pair (m*, m) from the output ((m*, σ*), queried) of a signing-oracle execution by selecting the first queried message m ∈ queried with H s m = H s m*.

theorem Cslib.Crypto.HashAndSign.isCollision_collisionOf_of_isSome (H : List Bool → List Bool → List Bool) {n : ℕ} {s mStar sig : List Bool} {queried : List (List Bool)} (hfresh : (!decide (queried.contains mStar = true)) = true) (hfind : (List.find? (fun (m : List Bool) => H s m == H s mStar) queried).isSome = true) :
isCollision H (fun (x : ℕ) (x_1 : List Bool) => true) n s (collisionOf H s ((mStar, sig), queried)).1 (collisionOf H s ((mStar, sig), queried)).2 = true

Whenever m* ∉ queried and queried.find? (fun m => H s m == H s m*) succeeds, collisionOf produces a genuine collision for H under key s.

Collision-finding reduction ([KL20], Theorem 13.4, Case 1): given challenge parameter n and hash key s, generate (pk₀, sk₀) ← S.keyGen n, simulate the HashAndSign signing oracle directly using sk₀ and s, and extract a colliding message pair via collisionOf.

Stateless oracle handler that answers a WordSignatureScheme signing query ((), msg) by querying the external fixed-length signing oracle on ((), H s msg) and truncating the response to bound bits.

noncomputable def Cslib.Crypto.HashAndSign.baseForger (H : List Bool → List Bool → List Bool) (bound : ℕ → ℕ) (adversary : Forger) :

Underlying signature reduction ([KL20], Theorem 13.4, Case 2): given n and base public key pk₀, sample a uniform n-bit hash key s, run adversary n ⟨pk₀, s⟩ by forwarding hashed signing queries H s msg through hashSigningHandler, and output the hashed forgery (H s m*, σ*).

When bound upper-bounds the bit-length of every signature in the support of S.sign sk₀ (H s msg) and |H s msg| = n, interpreting hashSigningHandler against S.signingOracle n sk₀ matches running (scheme S H hH hlen).signingOracle ⟨sk₀, s⟩ while mapping the recorded query log queried to queried.map (H s).

theorem Cslib.Crypto.HashAndSign.succProbability_eufCmaGame_le (S : SignatureScheme) (H : List Bool → List Bool → List Bool) (hH : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : List Bool × List Bool) => H p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (s msg : List Bool), (H s msg).length = s.length) {bound : ℕ → ℕ} (hbound : ∀ (n : ℕ), ∀ keys ∈ (S.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = n → ∀ sig ∈ (S.sign keys.2 msg).eval.support, sig.length ≤ bound n) (adversary : Forger) (n : ℕ) :
Game.succProbability ((scheme S H hH hlen).eufCmaGame adversary n).eval ≤ Game.succProbability (S.eufCmaGame (baseForger H bound adversary) n).eval + Game.succProbability (collisionGame H (fun (x : ℕ) (x_1 : List Bool) => true) (collisionFinder S H hH hlen adversary) n).eval

Pointwise reduction inequality for Theorem 13.4 ([KL20], p. 468): whenever bound n upper-bounds the bit-length of valid S-signatures at parameter n, the EUFCMA forging probability of adversary against HashAndSign.scheme S H hH hlen is at most the sum of the EUFCMA forging probability of baseForger H bound adversary against S and the collision- finding probability of collisionFinder S H hH hlen adversary against H.

Key-Independent Collisions Break the Scheme #

One-query forger that queries m₀, truncates the reply to bound n bits, and outputs it as a forgery on m₁. Whenever m₀ ≠ m₁ and H s m₀ = H s m₁, this attacker breaks HashAndSign.scheme with probability 1.

theorem Cslib.Crypto.HashAndSign.succProbability_eufCmaGame_fixedCollisionForger (S : SignatureScheme) (H : List Bool → List Bool → List Bool) (hH : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : List Bool × List Bool) => H p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (s msg : List Bool), (H s msg).length = s.length) {bound : ℕ → ℕ} (hbound : ∀ (n : ℕ), ∀ keys ∈ (S.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = n → ∀ sig ∈ (S.sign keys.2 msg).eval.support, sig.length ≤ bound n) {m₀ m₁ : List Bool} (hne : m₁ ≠ m₀) (hcoll : ∀ (s : List Bool), H s m₀ = H s m₁) (n : ℕ) :
Game.succProbability ((scheme S H hH hlen).eufCmaGame (fixedCollisionForger bound m₀ m₁) n).eval = 1

If m₀ ≠ m₁ collide under every hash key (∀ s, H s m₀ = H s m₁) and bound n upper-bounds the length of valid S-signatures, fixedCollisionForger bound m₀ m₁ wins (scheme S H hH hlen).eufCmaGame with probability 1 at every security parameter n.

theorem Cslib.Crypto.HashAndSign.not_eufCMA_scheme_of_collision (S : SignatureScheme) (H : List Bool → List Bool → List Bool) (hH : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : List Bool × List Bool) => H p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (s msg : List Bool), (H s msg).length = s.length) {m₀ m₁ : List Bool} (hne : m₁ ≠ m₀) (hcoll : ∀ (s : List Bool), H s m₀ = H s m₁) :
¬(scheme S H hH hlen).EUFCMA

Key-independent collisions break Construction 13.3: if two distinct messages m₀ ≠ m₁ collide under every hash key s, then (scheme S H hH hlen) is not EUFCMA secure for any underlying SignatureScheme S.

Main EUF-CMA Theorems ([KL20], Theorem 13.4) #

Theorem 13.4 ([KL20], Section 13.3, p. 468): if S is an EUFCMA-secure fixed-length SignatureScheme and H is a polynomial-time length-preserving collision-resistant hash family, then the single-public-key hash-and-sign scheme HashAndSign.scheme S H hH hlen is an EUFCMA-secure WordSignatureScheme on arbitrary-length bit strings.

Theorem 13.4 specialized to a bundled HashFamily ([KL20], Section 13.3, p. 468).

Merkle–Damgård + Hash-and-Sign ([KL20], Sections 6.2 and 13.3): an EUFCMA-secure fixed-length SignatureScheme together with a collision-resistant 2 n → n CompressionFamily yields an EUFCMA-secure WordSignatureScheme on arbitrary-length messages via merkleDamgard and HashAndSign.scheme. merkleDamgard puts one message bit in each block; it is not textbook length-strengthened Merkle–Damgård.