Randomized prefix-free encodings #
Boneh and Shoup turn a PRF that is secure only on prefix-free query sets into a fully secure one by encoding its inputs with a keyed encoding that is prefix-free with high probability ([BS23], §6.7, pp. 236–237, and §6.10, p. 242). This file defines the notion and proves the collision bounds of the book's two examples. Theorem 6.9, the PRF built from such an encoding, is not proved here.
Main definitions #
PrefixCompatible x yis Definition 6.5,x ∼ y: one of the lists is a prefix of the other.IsRandPrefixFreeEncoding seed rpf εis Definition 6.6:rpf k mis never empty, and for distinct messagesm₀ ≠ m₁the probability overk ← seedthatrpf k m₀ ∼ rpf k m₁is at mostε. The encodings need not be injective for a fixed key, as the book remarks.cmacRpf n (k₁, k₂)is CMAC's encoding of a bit string (§6.10): a message whose length is a positive multiple ofnis cut inton-bit blocks andk₁is added to the last; any other message is padded with1 ‖ 0^*(Cslib.BitString.pad10star) andk₂is added to the last block.
Main results #
isRandPrefixFreeEncoding_modifyLast_add: adding a uniform key to the last block of a non-empty message,rpf(k, (a₁, …, aᵥ)) = (a₁, …, aᵥ₋₁, aᵥ ⊕ k), is a randomized1/|X|-prefix-free encoding (§6.7, "A simple rpf").isRandPrefixFreeEncoding_cmacRpf: for0 < nand two independent uniform keys, CMAC's encoding is randomized2⁻ⁿ-prefix-free.length_cmacRpf_le: for0 < nand1 ≤ ℓ, CMAC's encoding of a message of at mostnℓbits has at mostℓblocks, the book's codomain.
Differences from the book #
Encodings take values in List X and Definition 6.6's bound ≤ ℓ on the number of blocks is a
separate length lemma; non-emptiness is part of the definition. Definition 6.6 is stated for any
key law seed : PMF K and any ε : ℝ≥0∞; the book draws k uniformly and takes 0 ≤ ε ≤ 1.
The simple encoding is proved for every finite additive group X (for Cslib.BitString n, + is
XOR) on the non-empty lists; on all lists it fails, since [] is a prefix of everything. The CMAC
encoding needs 0 < n, is defined on every bit string, and its length bound needs 1 ≤ ℓ; with a
single key k₁ = k₂ the empty message and 1 ‖ 0^(n-1) collide for every key. Counterexamples
for these hypotheses are in CslibFrontierTests.Crypto.RandPrefixFreeEncoding.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, version 0.6, Definitions 6.5 and 6.6 and §6.7 (pp. 236–237), and §6.10 (p. 242).
Definitions 6.5 and 6.6 #
A randomized ε-prefix-free encoding ([BS23], Definition 6.6): every encoding is
non-empty, and for distinct messages the probability over k ← seed that their encodings are
prefix-compatible is at most ε. The bound on the number of blocks is not part of the definition;
the book also draws k uniformly and takes ε ≤ 1.
- prob_le ⦃m₀ m₁ : M⦄ : m₀ ≠ m₁ → seed.toOuterMeasure {k : K | PrefixCompatible (rpf k m₀) (rpf k m₁)} ≤ ε
Restricting a randomized prefix-free encoding along an injection of messages, for instance to the messages of bounded length, keeps its bound.
For a uniform key on a finite type, it suffices to count: if at most c keys make the
encodings of any two distinct messages prefix-compatible, the encoding is c / |K|-prefix-free.
Adding a key to the last block #
Adding a uniform key to the last block is a randomized 1/|X|-prefix-free encoding of the
non-empty lists ([BS23], §6.7, "A simple rpf", pp. 236–237), for every finite additive
group X; the book's is X = {0,1}ⁿ under XOR.
CMAC's encoding #
The unkeyed part of CMAC's encoding ([BS23], §6.10, p. 242): (true, blocks) when
|m| is a positive multiple of n, with m cut into n-bit blocks, and otherwise
(false, blocks of m ‖ 1 ‖ 0^*). The flag selects the key added to the last block.
CMAC's randomized prefix-free encoding ([BS23], §6.10, p. 242). Cut m into n-bit
blocks; if |m| is a positive multiple of n, add k₁ to the last block, and otherwise pad m
with 1 ‖ 0^* to a positive multiple of n and add k₂ to the last block.
CMAC's encoding with two independent uniform keys is a randomized 2⁻ⁿ-prefix-free encoding
of all bit strings, for 0 < n ([BS23], §6.10, p. 242).