Containment-free encodings #
This module formalizes containment-free subset encodings used for one-time signatures ([BS23], Sections 14.2 and 14.4). No cryptographic primitives or security experiments are defined here.
A map P : M → Finset α is containment free (ContainmentFree P) when no image P m is a
subset of another image P m' for distinct m ≠ m' (Definition 14.3). Equivalently, P is
injective and its range is an antichain under ⊆ (containmentFree_iff). Any injective map into
constant-size subsets is containment free (containmentFree_of_injective_of_card_eq). By the
finite-cardinality form of Sperner's theorem (card_le_choose_half_of_containmentFree, proved from
Mathlib's IsAntichain.sperner, underlying the n_min ≈ v + (log₂ v) / 2 estimate in Section
14.2.1, which is not formalized here), Fintype.card M ≤ Nat.choose n (n / 2) where
n = Fintype.card α; conversely, any finite message space satisfying that bound admits a
containment-free encoding via unrankCombination (exists_containmentFree_of_card_le, existence
only with no polynomial-time claim; not stated in the book).
Two explicit computable encodings are provided:
optWord/optSet(P_opt, Section 14.2.1, Lemma 14.3): appends thew-bit little-endian (lowBits, LSB-first) checksum(List.ofFn m).count false(v - weight m) tomand takes its support inFin (v + w). Unlike Figure 14.2 (p. 589), which prints the checksum MSB-first (5as0101),optWordappends checksum bits LSB-first. Wheneverv < 2 ^ w(for examplew = 1 + Nat.clog 2 v),optSet v wis containment free (optSet_containmentFree) andoptWordis computable in polynomial time inw(unary) andm(optWord_polyTime).horsWord/horsSet(Section 14.4): maps av-bit message via its big-endian binary value intounrankCombination n ℓ. Whenever2 ^ v ≤ n.choose ℓ,horsSet n ℓproducesℓ-element subsets (card_horsSet), is containment free (horsSet_containmentFree), andhorsWordis computable in polynomial time in(n, ℓ)(unary) andm(horsWord_polyTime). This uses the library'sunrankCombination(ordered withfalsefirst viaNat.choose m k), satisfying the §14.4 requirement of an efficient injective map into fixed-size subsets; the specific unranking loop of Exercise 14.3 is not formalized here.
Main definitions #
Cslib.Crypto.OneTimeSignature.ContainmentFree: containment-free property for subset maps.Cslib.Crypto.OneTimeSignature.optWord,Cslib.Crypto.OneTimeSignature.optSet: theP_optword and subset encodings.Cslib.Crypto.OneTimeSignature.horsWord,Cslib.Crypto.OneTimeSignature.horsSet: fixed-size subset encodings viaunrankCombination.
Main results #
Cslib.Crypto.OneTimeSignature.containmentFree_iff: characterization via injectivity and⊆-antichains.Cslib.Crypto.OneTimeSignature.containmentFree_of_injective_of_card_eq: constant-cardinality criterion.Cslib.Crypto.OneTimeSignature.card_le_choose_half_of_containmentFree: Sperner's upper bound.Cslib.Crypto.OneTimeSignature.exists_containmentFree_of_card_le: Sperner converse.Cslib.Crypto.OneTimeSignature.optSet_containmentFree: Lemma 14.3 forv < 2 ^ w.Cslib.Crypto.OneTimeSignature.optWord_polyTime: polynomial-time certificate foroptWord.Cslib.Crypto.OneTimeSignature.card_horsSet: constant output cardinalityℓunder2 ^ v ≤ n.choose ℓ.Cslib.Crypto.OneTimeSignature.horsSet_containmentFree: containment freeness when2 ^ v ≤ n.choose ℓ.Cslib.Crypto.OneTimeSignature.horsWord_polyTime: polynomial-time certificate forhorsWord.
References #
- [BS23]: Dan Boneh and Victor Shoup, A Graduate Course in Applied Cryptography
(v0.6), Section 14.2 (Definition 14.3, p. 587), Section 14.2.1 (Sperner's theorem, p. 588;
P_optand Lemma 14.3, pp. 588–589), and Section 14.4 (p. 593).
A subset encoding is containment free if and only if it is injective and its range is an antichain under subset inclusion.
Any injective map into subsets of a common cardinality ℓ is containment free.
Finite-cardinality form of Sperner's theorem, proved from Mathlib's IsAntichain.sperner:
any containment-free family into Finset α has message space cardinality at most
(Fintype.card α).choose (Fintype.card α / 2). ([BS23], Section 14.2.1, p. 588, invokes
Sperner's theorem only for the n_min ≈ v + (log₂ v) / 2 estimate, which is not formalized
here.)
The word construction underlying P_opt ([BS23], Section 14.2.1, pp. 588–589):
appends the w-bit little-endian (lowBits, LSB-first) binary encoding of m.count false
(v - weight m on v-bit messages) to m. Unlike Figure 14.2 (p. 589), which prints the
checksum MSB-first, checksum bits are appended LSB-first here.
Lemma 14.3 ([BS23], Section 14.2.1, pp. 588–589): P_opt is containment free
whenever v < 2 ^ w (in particular for the book's choice w = 1 + Nat.clog 2 v).
Efficiency certificate for P_opt: computing optWord w m runs in polynomial time in
w (unary) and m (bitstring).
A fixed-size subset word encoding ([BS23], Section 14.4, p. 593): maps a bitstring
message via its big-endian binary value into unrankCombination n ℓ. This uses the library's
unranking order (false before true) rather than the loop of Exercise 14.3.
The subset encoding on v-bit strings derived from horsWord; its image has constant
cardinality ℓ (card_horsSet) and is containment free (horsSet_containmentFree) whenever
2 ^ v ≤ n.choose ℓ.
Any bitstring message space with 2 ^ v ≤ n.choose ℓ admits a containment-free encoding
into ℓ-element subsets of Fin n via horsSet ([BS23], Section 14.4, p. 593).
Efficiency certificate for horsWord: computing horsWord n ℓ m runs in polynomial time
in (n, ℓ) (unary) and m (bitstring).
Converse to the finite-cardinality form of Sperner's theorem (not stated in
[BS23]): any finite message space with cardinality at most n.choose (n / 2) admits a
containment-free encoding into Finset (Fin n). This is a pure existence result and makes no
polynomial-time claim.