Documentation

CslibFrontier.Foundations.Data.BitString.Pad10Star

Padding with a one and zeros #

BitString.pad10star r msg appends to a bit list a 1 and then the fewest zeros that make its length a multiple of r: the padding m ↦ m ‖ 1 ‖ 0^* of the sponge construction ([KL20], Construction 7.6), called pad10* in the Keccak literature. Padding and then cutting into blocks of r bits (BitString.toBlocks) is injective (BitString.toBlocks_pad10star_injective), so a bit list of any length can be recovered from its padded blocks.

Main definitions #

Main results #

References #

The padding of [KL20], Construction 7.6: append a 1 and then the fewest zeros making the length a multiple of r.

Padding is injective: distinct messages have distinct padded strings.

theorem Cslib.BitString.length_pad10star {r : ℕ} (hr : 0 < r) (msg : List Bool) :
(pad10star r msg).length = (msg.length / r + 1) * r

The padded length: one block more than the whole blocks of the message.

theorem Cslib.BitString.dvd_length_pad10star {r : ℕ} (hr : 0 < r) (msg : List Bool) :
r ∣ (pad10star r msg).length
theorem Cslib.BitString.length_pad10star_div {r : ℕ} (hr : 0 < r) (msg : List Bool) :
(pad10star r msg).length / r = msg.length / r + 1

The padded length in blocks: one more than the whole blocks of the message.

theorem Cslib.BitString.length_pad10star_le {r : ℕ} (hr : 0 < r) (msg : List Bool) :
(pad10star r msg).length ≤ msg.length + r

Padding adds at most one block: a 1 and fewer than r zeros.

theorem Cslib.BitString.pad10star_of_dvd {r : ℕ} (hr : 0 < r) {msg : List Bool} (h : r ∣ msg.length) :

On a message whose length is a multiple of r, padding appends one full block 1 ‖ 0^(r - 1).

theorem Cslib.BitString.getD_pad10star (r : ℕ) (msg : List Bool) (i : ℕ) :
(pad10star r msg).getD i false = (msg ++ [true]).getD i false

Reading the padded list with default false is reading msg ++ [true] with default false: the zeros of the padding are the default.

Distinct messages have distinct padded block sequences.

The padded blocks of a full-block list u followed by one more block m are the blocks of u, then m, then the padding block.