Documentation

CslibFrontier.Crypto.Computational.MerkleDamgard.LengthPadding

Length-strengthened Merkle–Damgård padding #

This module defines the length-strengthened padding block and n-bit block partition of [BS23], §8.4, Fig. 8.5 (pp. 296–297), proves that the padded message is block-aligned and that the partition is suffix-free when the block count fits in the length field, and certifies that the partition is computable in polynomial time. The hash built from it and Theorem 8.3 (p. 297) for it are not in this module.

Differences from Boneh–Shoup §8.4 #

Main definitions #

Main results #

References #

Number of n-bit blocks produced by length-strengthened padding at block size n with an (n / 2)-bit length field.

Length-strengthened Merkle–Damgård padded message M ‖ PB, where PB = 1 ‖ 0^k ‖ ⟨s⟩: 1, the minimal number k < n of zeros making the total length a multiple of n when ⟨s⟩ fits in n / 2 bits, and the (n / 2)-bit big-endian encoding of s = mdLengthBlockCount n msg.

The first s = mdLengthBlockCount n msg consecutive n-bit blocks of mdLengthPad n msg. When s < 2 ^ (n / 2) they are all of it (flatten_mdLengthBlocks).

theorem Cslib.Crypto.length_of_mem_mdLengthBlocks {n : ℕ} {msg b : List Bool} (hb : b ∈ mdLengthBlocks n msg) :
b.length = n

Every block produced by mdLengthBlocks n msg has length n.

theorem Cslib.Crypto.length_mdLengthPad {n : ℕ} {msg : List Bool} (hs : mdLengthBlockCount n msg < 2 ^ (n / 2)) :

Block alignment: when the block count fits in the length field, the padded message consists of exactly mdLengthBlockCount n msg blocks of n bits.

theorem Cslib.Crypto.flatten_mdLengthBlocks {n : ℕ} {msg : List Bool} (hs : mdLengthBlockCount n msg < 2 ^ (n / 2)) :

When the block count fits in the length field, the blocks of mdLengthBlocks n msg concatenate to mdLengthPad n msg: no bit is dropped.

theorem Cslib.Crypto.mdLengthBlocks_suffix_iff {n : ℕ} {m₁ m₂ : List Bool} (hs₂ : mdLengthBlockCount n m₂ < 2 ^ (n / 2)) :
mdLengthBlocks n m₁ <:+ mdLengthBlocks n m₂ ↔ m₁ = m₂

The length-strengthened blocks are suffix-free: when the longer message's padded block count is less than 2 ^ (n / 2), mdLengthBlocks n m₁ is a suffix of mdLengthBlocks n m₂ if and only if m₁ = m₂. The proof of [BS23], Theorem 8.3 (p. 297) uses this property of the padding when it deduces u = v from equal last blocks; the book does not state it separately.

The length-strengthened block partition mdLengthBlocks n msg is computable in polynomial time from (n, msg) with n in unary and msg as a raw bit list.