Documentation

CslibFrontier.Crypto.Protocols.PerfectSecrecy.Characterization

Characterizations of perfect security (Boneh–Shoup §2.1.2) #

The equivalent forms of perfect security that [BS23], v0.6, §2.1.2 (printed pp. 8–12) states for Shannon ciphers, on the information-theoretic encryption schemes EncScheme.

A Shannon cipher (E, D) over (K, M, C) with its uniformly random key is EncScheme.ofPure (uniformOfFintype K) enc dec h, where h is the book's correctness property D(k, E(k, m)) = m. Its CiphertextIndist (equal ciphertext laws for any two messages) is the book's Definition 2.1 (perfect security, p. 8): two laws on C are equal exactly when they give every ciphertext the same mass. The library's PerfectlySecret is instead the posterior form of [KL20], Definition 2.3; perfectlySecret_iff_ciphertextIndist converts between the two, so every result below also characterizes PerfectlySecret.

The ciphertext law of a deterministic scheme is the image of its key law (ciphertextDist_ofPure), and under a uniform key the mass of c given m is the number of keys taking m to c over |K| (ciphertextDist_ofPure_uniformOfFintype_apply): the identity P_c = N_c / |K| in the proof of Theorem 2.1 (p. 9).

All of this is information-theoretic: there is no adversary and no resource bound.

Main results #

Deviations from [BS23] #

References #

@[simp]
theorem Cslib.Crypto.Protocols.PerfectSecrecy.EncScheme.ciphertextDist_ofPure {M K C : Type u} (gen : PMF K) (enc : K → M → C) (dec : K → C → M) (h : ∀ (k : K), Function.LeftInverse (dec k) (enc k)) (m : M) :
(ofPure gen enc dec h).ciphertextDist m = PMF.map (fun (x : K) => enc x m) gen

The ciphertext law of a deterministic scheme is the image of its key law under E(·, m).

theorem Cslib.Crypto.Protocols.PerfectSecrecy.EncScheme.ciphertextDist_ofPure_uniformOfFintype_apply {M K C : Type u} [Fintype K] [Nonempty K] (enc : K → M → C) (dec : K → C → M) (h : ∀ (k : K), Function.LeftInverse (dec k) (enc k)) (m : M) (c : C) :
((ofPure (Probability.PMF.uniformOfFintype K) enc dec h).ciphertextDist m) c = ↑(Nat.card { k : K // enc k m = c }) / ↑(Fintype.card K)

Under a uniformly random key, a deterministic scheme sends m to c with probability the number of keys k with E(k, m) = c, divided by |K|. This is the identity P_c = N_c / |K| in the proof of [BS23], Theorem 2.1 (p. 9).

theorem Cslib.Crypto.Protocols.PerfectSecrecy.EncScheme.ciphertextIndist_ofPure_uniformOfFintype_iff {M K C : Type u} [Fintype K] [Nonempty K] (enc : K → M → C) (dec : K → C → M) (h : ∀ (k : K), Function.LeftInverse (dec k) (enc k)) :
(ofPure (Probability.PMF.uniformOfFintype K) enc dec h).CiphertextIndist ↔ ∀ (c : C), ∃ (N : ℕ), ∀ (m : M), Nat.card { k : K // enc k m = c } = N

Counting criterion for perfect security: [BS23], Theorem 2.1, (i) ⇔ (ii) (pp. 8–9). A Shannon cipher with a uniform key is perfectly secure (Definition 2.1) if and only if, for every ciphertext c, the number of keys k with E(k, m) = c is the same for all messages m.

The book takes K, M, C finite and N_c an integer; here only K is finite (and nonempty) and N_c is a natural number. Condition (iii) of the theorem, that the laws of E(k, m) agree for all m, is CiphertextIndist itself. perfectlySecret_iff_ciphertextIndist converts the left side to the library's PerfectlySecret.

theorem Cslib.Crypto.Protocols.PerfectSecrecy.EncScheme.ciphertextIndist_ofPure_uniformOfFintype_of_existsUnique {M K C : Type u} [Fintype K] [Nonempty K] (enc : K → M → C) (dec : K → C → M) (h : ∀ (k : K), Function.LeftInverse (dec k) (enc k)) (huniq : ∀ (m : M) (c : C), ∃! k : K, enc k m = c) :

One key per message and ciphertext: a Shannon cipher with a uniform key in which, for every message m and ciphertext c, exactly one key encrypts m to c is perfectly secure (Definition 2.1). This is the case N_c = 1 of Theorem 2.1 (ii), by which [BS23] proves the one-time pad perfectly secure (Theorem 2.2, p. 9) and the additive one-time pad (Example 2.7, p. 10).

Perfect security as equal event probabilities: [BS23], Theorem 2.3 (pp. 10–11), generalized from Shannon ciphers with a uniform key to every scheme, with randomized encryption and any key law. A scheme has equal ciphertext laws for any two messages if and only if every event S on ciphertexts has the same probability under any two messages.

The book's predicates φ on C are the events S = {c | φ c}; its statement is the case scheme = ofPure (uniformOfFintype K) enc dec h, where CiphertextIndist is Definition 2.1. The theorem is Mathlib's PMF.toOuterMeasure_inj read for the ciphertext laws: what it adds is the book's formulation, not a new argument. As in the book's proof, the converse needs only singleton events.

theorem Cslib.Crypto.Protocols.PerfectSecrecy.EncScheme.ciphertextIndist_iff_jointDist_eq_mul {M K C : Type u} (scheme : EncScheme M K C) (msgDist : PMF M) (hfull : ∀ (m : M), msgDist m ≠ 0) :
scheme.CiphertextIndist ↔ ∀ (m : M) (c : C), (scheme.jointDist msgDist) (m, c) = msgDist m * (scheme.marginalCiphertextDist msgDist) c

Perfect security as independence of message and ciphertext: [BS23], Theorem 2.4 (pp. 11–12), for every scheme and one message law msgDist that gives every message nonzero probability. The message is drawn from msgDist and, independently, the key from the scheme's key law; the scheme has equal ciphertext laws for any two messages if and only if message and ciphertext are independent, written as Pr[m = m ∧ c = c] = Pr[m = m] · Pr[c = c], the form the book's proof uses.

The book states the theorem for Shannon ciphers with a uniform key, the case scheme = ofPure (uniformOfFintype K) enc dec h. Its first half, that perfect security gives independence, holds for every message law and is indep_of_ciphertextIndist; full support is used only for the converse, which is the book's second half. The converse is false without it: the identity cipher on Bool with a point-mass message law satisfies the factorization and is not CiphertextIndist.