Documentation

CslibFrontier.Crypto.Computational.OneTimeSignature.DominationFree

Domination-free encodings and the Winternitz encoding #

This module formalizes domination-free encodings and the Winternitz checksum encoding from Boneh–Shoup, Section 14.3 (Definition 14.4, Section 14.3.1, and Lemma 14.5, pp. 591–593).

A function P : M → Fin n → Fin (d + 1) is domination-free (DominationFree) when no pair of distinct messages m ≠ m' satisfies P m ≤ P m' coordinatewise. The Winternitz encoding (winternitzDigits d n0 n1 m) decomposes m < (d + 1) ^ n0 into n0 base-(d + 1) message digits radixDigits d n0 m, computes the complement checksum ∑ i : Fin n0, (d - (radixDigits d n0 m i).val), and appends its n1 base-(d + 1) digits. When d * n0 < (d + 1) ^ n1 and f : M → ℕ injects M into {x | x < (d + 1) ^ n0}, the resulting encoding is domination-free (winternitzDigits_dominationFree).

We also provide an executable list form winternitzDigitList together with its List.ofFn characterization (winternitzDigitList_eq_ofFn), length and entry agreements (winternitzDigitList_length, getElem_winternitzDigitList), and a polynomial-time certificate winternitzDigitList_polyTime in binary d, m and unary n0, n1.

Main definitions #

Main results #

References #

def Cslib.Crypto.OneTimeSignature.DominationFree {M : Type u_1} {n d : ℕ} (P : M → Fin n → Fin (d + 1)) :

A function P : M → Fin n → Fin (d + 1) is domination-free ([BS23], Definition 14.4, p. 591) if no distinct messages m ≠ m' satisfy P m ≤ P m' coordinatewise.

theorem Cslib.Crypto.OneTimeSignature.dominationFree_of_append_checksum {M : Type u_1} {n0 n1 d : ℕ} {P0 : M → Fin n0 → Fin (d + 1)} {P1 : M → Fin n1 → Fin (d + 1)} {checksum : M → ℕ} {C : ℕ} (h0 : Function.Injective P0) (hsum : ∀ (m : M), ∑ i : Fin n0, ↑(P0 m i) + checksum m = C) (hmono : ∀ ⦃m m' : M⦄, P1 m ≤ P1 m' → checksum m ≤ checksum m') :
DominationFree fun (m : M) => Fin.append (P0 m) (P1 m)

Append-checksum criterion, the argument of the proof of Lemma 14.5 in [BS23] (p. 593): if P0 is injective, ∑ i, (P0 m i).val + checksum m is the same number C for every m, and P1 m ≤ P1 m' implies checksum m ≤ checksum m', then fun m => Fin.append (P0 m) (P1 m) is domination-free.

def Cslib.Crypto.OneTimeSignature.radixDigits (d width x : ℕ) :
Fin width → Fin (d + 1)

Little-endian base-(d + 1) digit representation of x in width digits, taking digit i to (x / (d + 1) ^ i) % (d + 1).

theorem Cslib.Crypto.OneTimeSignature.sum_radixDigits_mul_pow {d width x : ℕ} (hx : x < (d + 1) ^ width) :
∑ i : Fin width, ↑(radixDigits d width x i) * (d + 1) ^ ↑i = x

Positional reconstruction of x < (d + 1) ^ width from radixDigits d width x.

theorem Cslib.Crypto.OneTimeSignature.radixDigits_injOn (d width : ℕ) :
Set.InjOn (radixDigits d width) {x : ℕ | x < (d + 1) ^ width}

radixDigits d width is injective on {x | x < (d + 1) ^ width}.

theorem Cslib.Crypto.OneTimeSignature.le_of_radixDigits_le {d width x y : ℕ} (hx : x < (d + 1) ^ width) (hy : y < (d + 1) ^ width) (hle : radixDigits d width x ≤ radixDigits d width y) :
x ≤ y

Coordinatewise order on radixDigits implies numeric order below (d + 1) ^ width.

def Cslib.Crypto.OneTimeSignature.winternitzDigits (d n0 n1 m : ℕ) :
Fin (n0 + n1) → Fin (d + 1)

The function P of [BS23], Section 14.3.1 (pp. 592–593), on a message m : ℕ: the n0 base-(d + 1) digits of m, then the n1 base-(d + 1) digits of the checksum ∑ i : Fin n0, (d - (radixDigits d n0 m i).val), which equals the printed d * n0 - (s_1 + ... + s_n0). Both blocks are least significant first, a choice made here: domination-freeness does not depend on the order within a block.

theorem Cslib.Crypto.OneTimeSignature.winternitzDigits_dominationFree {M : Type u_1} {d n0 n1 : ℕ} {f : M → ℕ} (hf_inj : Function.Injective f) (hf_bound : ∀ (m : M), f m < (d + 1) ^ n0) (hn1 : d * n0 < (d + 1) ^ n1) :
DominationFree fun (m : M) => winternitzDigits d n0 n1 (f m)

Lemma 14.5 of [BS23] (p. 593): fun m => winternitzDigits d n0 n1 (f m) is domination-free when f : M → ℕ is injective with values below (d + 1) ^ n0 and d * n0 < (d + 1) ^ n1.

The book states it for the messages {0,1}^v read as the integers below 2 ^ v, with n0 the least integer such that 2 ^ v ≤ (d + 1) ^ n0 and n1 = ⌈log_(d+1) (d * n0)⌉ + 1: the instance f = Fin.val on Fin (2 ^ v) with n1 = Nat.clog (d + 1) (d * n0) + 1. Minimality of n0 is not used. The table on p. 592 takes the least n1 with d * n0 < (d + 1) ^ n1, one less than the printed formula for d = 3, 15, 1023.

Executable list of n0 + n1 Winternitz message-and-checksum digits for m.

theorem Cslib.Crypto.OneTimeSignature.getElem_winternitzDigitList (d n0 n1 m i : ℕ) (hi : i < (winternitzDigitList d n0 n1 m).length) :
(winternitzDigitList d n0 n1 m)[i] = ↑(winternitzDigits d n0 n1 m ⟨i, ⋯⟩)

Every entry of winternitzDigitList d n0 n1 m equals the corresponding coordinate of winternitzDigits d n0 n1 m.

theorem Cslib.Crypto.OneTimeSignature.winternitzDigitList_eq_ofFn (d n0 n1 m : ℕ) :
winternitzDigitList d n0 n1 m = List.ofFn fun (i : Fin (n0 + n1)) => ↑(winternitzDigits d n0 n1 m i)

winternitzDigitList d n0 n1 m as List.ofFn of winternitzDigits d n0 n1 m.

For d = 1, winternitzDigits 1 v w on the little-endian integer value of m is 1 at coordinate k if and only if k ∈ optSet v w m ([BS23], Section 14.3.1, p. 593).