Documentation

CslibFrontier.Crypto.Computational.MerkleDamgard.LengthStrengthened

Length-strengthened Merkle–Damgård hash and Theorem 8.3 #

For a compression function h, lengthStrengthenedMD h k msg hashes msg by iterating merkleDamgardChain over the padded blocks mdLengthBlocks k.length msg starting from the all-zero k.length-bit initialization vector ([BS23], Section 8.4, pp. 295–298). Theorem 8.3 ([BS23], p. 297; proof ending on p. 298) states that H_MD is collision resistant when h is, with CRadv[A, H_MD] = CRadv[B, h] for a wrapper B around A. lengthStrengthenedWrapper is that B: it succeeds with adversary's exact probability whenever every valid message satisfies mdLengthBlockCount n m < 2 ^ (n / 2), the condition under which the padding is suffix-free. Since every uniform strict PPT adversary only produces messages of polynomially bounded length, every CompressionFamily h yields unrestricted CollisionResistant (lengthStrengthenedMD h) and HashFamily (lengthStrengthenedMD h).

Main definitions #

Main results #

Differences from Boneh–Shoup §8.4 #

References #

Length-strengthened Merkle–Damgård hash: iterates merkleDamgardChain over the padded blocks mdLengthBlocks k.length msg starting from the all-zero k.length-bit IV.

This instantiates [BS23], Section 8.4 (pp. 295–297) with block length k.length, fixed IV = List.replicate k.length false, and the (k.length / 2)-bit block-count encoding from mdLengthBlocks.

theorem Cslib.Crypto.length_lengthStrengthenedMD {h : List Bool → List Bool → List Bool} {k msg : List Bool} (hlen : ∀ (x : List Bool), x.length = 2 * k.length → (h k x).length = k.length) :

When h k maps 2 * k.length-bit inputs to k.length-bit digests, lengthStrengthenedMD h k msg outputs a k.length-bit digest.

noncomputable def Cslib.Crypto.lengthStrengthenedWrapper (h : List Bool → List Bool → List Bool) (valid : ℕ → List Bool → Bool) (adversary : CollisionFinder) :

Reduction adversary for [BS23], Theorem 8.3 (p. 297): runs adversary, checks whether the output pair (m₁, m₂) is a valid collision for lengthStrengthenedMD h under valid, and if so runs extractChainCollision on mdLengthBlocks k.length m₁ and mdLengthBlocks k.length m₂ to extract a 2n-bit collision for h, returning ([], []) when the check fails.

theorem Cslib.Crypto.succProbability_collisionGame_lengthStrengthenedMD_eq (h : List Bool → List Bool → List Bool) (valid : ℕ → List Bool → Bool) (adversary : CollisionFinder) (n : ℕ) (hlen : ∀ (k x : List Bool), k.length = n → x.length = 2 * n → (h k x).length = n) (hbound : ∀ (m : List Bool), valid n m = true → mdLengthBlockCount n m < 2 ^ (n / 2)) :

Boneh–Shoup Theorem 8.3 (concrete equality): when h preserves n-bit output lengths and every valid n-accepted message satisfies mdLengthBlockCount n m < 2 ^ (n / 2), adversary succeeds against lengthStrengthenedMD h on valid with the exact same probability that lengthStrengthenedWrapper h valid adversary succeeds against h on validCompressionInput.

Boneh–Shoup Theorem 8.3 (asymptotic): any 2n → n collision-resistant compression family h yields an unrestricted collision-resistant hash lengthStrengthenedMD h on all bit strings.

Every 2n → n collision-resistant compression family h induces a collision-resistant hash family HashFamily (lengthStrengthenedMD h) on arbitrary bit strings.