Deterministic Prefix-Free Encodings #
Prefix-free encodings ([BS23], Sections 6.6–6.6.1, pp. 235–236): functions into
nonempty lists of blocks whose range is a prefix-free set (InformationTheory.IsPrefixFree).
Main definitions #
Cslib.Crypto.PRF.IsPrefixFreeEncoding: predicate for an injective encoding into nonempty lists whose range is prefix-free.Cslib.Crypto.PRF.stopBitEncode: Method 2 stop-bit encoding (§6.6.1, p. 236), appendingfalseto every block except the last andtrueto the last block.Cslib.Crypto.PRF.separatingBlock: a common extension block for two queries.Cslib.Crypto.PRF.findFreshBlock: bounded search in an indexed block alphabet.Cslib.Crypto.PRF.freshBatchBlock: a block absent from a batch of queries.
Main results #
Cslib.Crypto.PRF.IsPrefixFreeEncoding.iff_forall_prefix: characterization in terms of nonemptiness and prefix-implicationpf m₁ <+: pf m₂ → m₁ = m₂.Cslib.Crypto.PRF.IsPrefixFreeEncoding.comp_injective: precomposing with an injective map preservesIsPrefixFreeEncoding.Cslib.Crypto.PRF.length_stopBitEncode:stopBitEncodepreserves the number of blocks.Cslib.Crypto.PRF.isPrefixFreeEncoding_stopBitEncode:stopBitEncodeis a prefix-free encoding on nonempty lists ofn-bit blocks.Cslib.Crypto.PRF.separatingBlock_prefix_incomparable: the common extension makes two distinct queries prefix-incomparable.Cslib.Crypto.PRF.isPrefixFree_append_of_notMem_flatten: appending an absent block makes a batch of block lists prefix-free.Cslib.Crypto.PRF.isPrefixFree_append_of_freshBatchBlock_eq_some: every block returned by the search makes the extended batch prefix-free.Cslib.Crypto.PRF.isPrefixFree_append_freshBatchBlock: the bounded search succeeds when there are more possible blocks than block occurrences, and its extension is prefix-free.
Differences from the book #
- The codomain is
List Xwith nonemptiness bundled and length bounds≤ ℓproved separately (length_stopBitEncode) rather than encoded in a bounded-list typeX^{≤ℓ}. stopBitEncodemapsn-bit payload blocks to(n + 1)-bit output blocks (n : ℕ), which corresponds to the book's(n - 1)-bit payload blocks andn-bit output blocks withn ≥ 1.- Empty messages are explicitly excluded by the subtype
{m : List (BitString n) // m ≠ []}, matchingX_{>0}^{≤ℓ}. - Method 1 (
isPrefixFreeEncoding_prependLength, §6.6.1, p. 235) lives inCslibFrontier.Crypto.Primitives.BlockCipher.LengthPrependedCBCMAC. Theorem 6.8 and randomized prefix-free encodings (§6.7, §6.10) are not included here.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Sections 6.6–6.6.1, pp. 235–236, and 7.2.2, pp. 258–260.
A function pf : M → List X is a prefix-free encoding ([BS23], Section 6.6,
p. 235) if every output is nonempty, pf is injective, and Set.range pf is a prefix-free set.
- injective : Function.Injective pf
- isPrefixFree_range : InformationTheory.IsPrefixFree (Set.range pf)
A function is a prefix-free encoding iff every output is nonempty and pf m₁ <+: pf m₂
implies m₁ = m₂.
Precomposing a prefix-free encoding with an injective map yields a prefix-free encoding.
stopBitEncode preserves the number of blocks.
Method 2 (stop bits) ([BS23], Section 6.6.1, p. 236): stopBitEncode is a
prefix-free encoding on nonempty lists of n-bit blocks.
Choose a common block to append to two queries. At the end of the shorter query, the chosen block differs from the block at that position in the longer query. The two candidate blocks are supplied by the caller. This is a preparation step for [BS23], v0.6, Theorem 7.3 (printed pp. 258–259), using one extra block even for incomparable queries.
Search the first min (2 ^ n) (b + 1) bit strings for a block absent from messages, where
b counts all block occurrences. This is the block-selection step of [BS23], v0.6,
Theorem 7.4 (printed pp. 259–260). It returns none when the batch uses the whole alphabet.
An absent block delimits each message, so appending it to the batch makes a prefix-free set.
Appending a block returned by the batch search makes the extended messages prefix-free.
The batch search supplies a fresh delimiter whenever the total block count is below the alphabet size. Appending it to every message gives a prefix-free set, including when an original message is empty or is a prefix of another. This is the query preparation step for (7.9).