Classical Cryptography and Perfect Secrecy

Why ad hoc ciphers fail and what replaced them. The private-key setting and the (Gen, Enc, Dec) syntax with correctness; Kerckhoffs' principle and open design; the four attack models (ciphertext-only, known-plaintext, chosen-plaintext, chosen-ciphertext). Historical ciphers and their cryptanalysis: Caesar, the shift cipher and the sufficient key space principle, mono-alphabetic substitution and frequency analysis, the automated shift attack via Σ pᵢq_{i+j} ≈ 0.065, the Vigenère cipher, Kasiski's method and the index of coincidence. The three principles of modern cryptography: exact definitions (what counts as a break, what power the adversary has, the arbitrary-adversary principle, models versus reality), precise minimal assumptions, and rigorous reductionist proofs. Perfect secrecy: the a-posteriori definition, the equivalent conditions Pr[C=c|M=m] = Pr[C=c] and perfect indistinguishability, the adversarial experiment PrivK^eav with success exactly ½; the one-time pad and its drawbacks (long keys, single use, known-plaintext key recovery); the lower bound |K| ≥ |M|; and Shannon's characterisation (uniform keys, a unique key for each plaintext–ciphertext pair) when |M| = |K| = |C|. Exercises worked: key-space and attack-model questions for classical ciphers, nonzero-key OTP, when classical ciphers are perfectly secret, two-message secrecy, and almost-perfect secrecy.

· 24 min read · 4,777 words

Corresponds to Katz & Lindell, Introduction to Modern Cryptography, Chapters 1–2.

Motivation: from an art to a science

IntuitionWhat changed

Until late in the 20th century, cryptography meant secret communication, mostly for militaries, and good codes came from creativity rather than theory: there was no agreed notion of what a “good” code even was. Modern cryptography is the scientific study of securing digital information, transactions and distributed computations against internal or external attack. It covers authentication, signatures, key exchange, auctions, elections and digital cash, and it is used by everyone, usually without knowing it. The classical ciphers below are studied not as history but as cautionary examples that motivate definitions and proofs.

EraApproachTypical outcome
Classicalad hoc design, security by intuitionbroken, sometimes centuries later
Shannon (1949)definitions + proofs, no assumptionsperfect secrecy, but keys as long as messages
Modern (Goldwasser–Micali, 1980s)definitions + precise assumptions + proofspractical schemes with computational security

The private-key setting

DefinitionPrivate-key (symmetric) encryption scheme

Two parties share a secret key in advance and communicate over a public channel. A scheme consists of three algorithms and a message space M\mathcal M:

  • Gen (probabilistic) outputs a key kk from the key space K\mathcal K;
  • Enc takes kk and a plaintext mm, outputs a ciphertext c=Enck(m)c = \mathrm{Enc}_k(m);
  • Dec takes kk and cc, outputs a plaintext Deck(c)\mathrm{Dec}_k(c).

K\mathcal K and M\mathcal M determine the ciphertext space C\mathcal C. Correctness: Deck(Enck(m))=m\mathrm{Dec}_k(\mathrm{Enc}_k(m)) = m for every key output by Gen and every m∈Mm\in\mathcal M.

ComponentDetail
Symmetricthe same key encrypts and decrypts (contrast public-key, Chapter 9)
Hidden assumptionthe parties somehow shared the key secretly beforehand
Where it sufficesdisk encryption (one user, two points in time), and alongside public-key methods

ImportantKerckhoffs’ principle

A cipher must stay secure even if everything except the key falls into the enemy’s hands. Security rests on the key alone. Today this is read more strongly: algorithms should be published. Reasons:

  1. a short random key is far easier to keep secret than a program, which can leak or be reverse engineered;
  2. a compromised key is easy to replace; a compromised algorithm isn’t, and many pairs of users can share one algorithm with different keys;
  3. public scrutiny makes designs stronger, flaws are better found by ethical hackers than by attackers, and public designs enable standards.

Corollary: never use proprietary, secretly designed algorithms (“security by obscurity”). Kerckhoffs also asked that a system be practically, if not mathematically, indecipherable, which is exactly modern computational security.

DefinitionAttack models (increasing severity)

AttackAdversary canType
Ciphertext-onlyobserve ciphertextspassive
Known-plaintextalso see some plaintext–ciphertext pairs under the same keypassive
Chosen-plaintextobtain encryptions of plaintexts of its choiceactive
Chosen-ciphertextalso obtain decryptions of ciphertexts of its choice (other than the target)active

Known-plaintext attacks are very realistic: greetings, standard headers, or earnings figures that are later published all leak plaintext. The strongest model is not always required; a scheme secure against weaker attacks may be more efficient and enough for the application.


Historical ciphers and their cryptanalysis

NoteConventions for this section

Plaintext is lower case, ciphertext UPPER CASE, letters are identified with {0,…,25}\{0,\ldots,25\}, and [a mod N][a\bmod N] is the remainder. Every attack assumes Kerckhoffs: the scheme is known, the key is not.

Caesar and the shift cipher

ExampleCaesar’s cipher

Rotate every letter by 3 (a→Da\to D, wrapping x→Ax\to A). “begintheattacknow” becomes EHJLQWKHDWWDFNQRZ. There is no key: Gen does nothing, so knowing the method means decrypting everything. ROT-13 is the shift-13 variant used to hide spoilers, with no pretence of security.

DefinitionShift cipher

Gen picks kk uniformly from {0,…,25}\{0,\ldots,25\}; Enck(m)i=[(mi+k) mod 26]\mathrm{Enc}_k(m)_i = [(m_i + k)\bmod26] and Deck(c)i=[(ci−k) mod 26]\mathrm{Dec}_k(c)_i = [(c_i - k)\bmod26].

ExampleBreaking it by brute force

Only 26 keys: try them all. The book’s challenge ciphertext OVDTHUFWVZZPISLRLFZHYLAOLYL decrypts with k=7k = 7 to “how many possible keys are there”. (Worked here.)

ImportantSufficient key space principle

A secure scheme’s key space must resist exhaustive search (today at least about 2602^{60}–2702^{70} keys). This is necessary but not sufficient. It also only applies when the message space is larger than the key space: the one-time pad below is secure with ∣K∣=∣M∣\lvert\mathcal K\rvert = \lvert\mathcal M\rvert.

Mono-alphabetic substitution

DefinitionSubstitution cipher

The key is a permutation of the alphabet, applied letter by letter: 26!≈28826!\approx2^{88} keys, far beyond brute force.

WarningLarge key space, still trivially broken

Two facts kill it:

  1. the mapping is fixed, so each plaintext letter always becomes the same ciphertext letter;
  2. letter frequencies of a language are stable, even over a few dozen words.

Tabulate ciphertext letter frequencies, match them to English (most frequent → e, and so on), then fix mistakes with language knowledge (h between t and e; q followed by u). Newspaper cryptograms are this cipher.

AlgorithmAutomated attack on the shift cipher

Let pip_i be English letter frequencies, so ∑ipi2≈0.065\sum_ip_i^2\approx0.065 (1.1), and let qiq_i be the ciphertext frequencies. If the key is kk, then qi+k≈piq_{i+k}\approx p_i. Compute

Ij=∑i=025piqi+jfor j=0,…,25I_j = \sum_{i=0}^{25}p_iq_{i+j}\quad\text{for }j = 0,\ldots,25

and output the jj whose IjI_j is closest to 0.0650.065. This needs no judgement of whether a decryption “makes sense”, so it automates easily and works even for text that has English statistics without being English.

The Vigenère cipher

DefinitionVigenère (poly-alphabetic shift)

The key is a word k1⋯ktk_1\cdots k_t (the period tt). Plaintext position ii is shifted by key letter k((i−1) mod t)+1k_{((i-1)\bmod t)+1}, cycling through the key. Equivalently, tt interleaved shift ciphers. Example: “tellhimaboutme” with key “cafe” gives WFRQKJSFEPAYPF.

Why it seemed strong: the same plaintext letter maps to different ciphertext letters, which smooths the frequency distribution. It was invented in the 16th century and long considered unbreakable.

AlgorithmBreaking Vigenère once the period is known

Split the ciphertext into tt streams cj,cj+t,cj+2t,…c_j, c_{j+t}, c_{j+2t}, \ldots. Each is a shift cipher with key kjk_j. Break each stream with frequency matching or the IjI_j statistic. This needs tt frequency tables, not a search over 26t26^t keys.

AlgorithmFinding the period

Kasiski (mid-19th century): look for repeated 2–3 letter blocks in the ciphertext. Common words like “the” encrypt identically whenever they fall at the same offset modulo tt, so distances between repeats are (mostly) multiples of tt. Take the gcd. (Book example: with key “beads”, two occurrences of “the” both become MJJ, 40 positions apart, and t=5t = 5.)

Index of coincidence: for τ=1,2,…\tau = 1, 2, \ldots, compute Iτ=∑iqi2I_\tau = \sum_iq_i^2 over the stream c1,c1+τ,c1+2τ,…c_1, c_{1+\tau}, c_{1+2\tau}, \ldots. At τ=t\tau = t the stream is a shifted English distribution, so Iτ≈0.065I_\tau\approx0.065. Otherwise letters look roughly uniform and Iτ≈∑i(1/26)2≈0.038I_\tau\approx\sum_i(1/26)^2\approx0.038. This is easy to automate.

IntuitionLonger keys need longer ciphertexts

The shift cipher falls to a single word, substitution needs a paragraph, and Vigenère needs about tt times more (each of tt streams needs its own statistics, and Kasiski needs repeats). This is not a coincidence: it previews perfect secrecy, where a key as long as the message leaves no statistics to exploit.

TheoremAll three fall immediately to known- or chosen-plaintext attacks (Exercises 1.5–1.6)

CipherKnown plaintext neededChosen plaintext needed
Shift1 letter: k=c1−m1k = c_1 - m_1encrypt “a”
Substitutiontext covering 25 distinct letters (the 26th is forced)encrypt “abc…y” (25 letters)
Vigenèrett consecutive letters, ki=ci−mik_i = c_i - m_i (if tt unknown, read it off a long enough sample)encrypt “aaa…a”: the ciphertext is the key repeated, revealing tt and kk

(Worked here.) Chosen plaintext is no more powerful here but makes the attack trivial to plan, since the adversary designs the plaintext.

ExampleHardened variants (Exercises 1.3–1.4)

  • Vigenère with tt substitution alphabets: split into tt streams (period via index of coincidence, which is invariant under substitution), then break each stream with frequency analysis.
  • Block-dependent shifts ki+jk_i + j in block jj: decryption just subtracts ki+jk_i + j. Kasiski weakens: identical plaintext now repeats identically only when the block distance is a multiple of 26, so the effective period is 26t26t. Better attack: by Kerckhoffs the structure is known, so subtract jj from every letter of block jj (for a guessed tt) to recover ordinary Vigenère ciphertext, then attack as usual.

(Worked here.)

ImportantLessons from classical ciphers

  1. Sufficient key space is necessary, never sufficient.
  2. Complexity is not security. Vigenère, Enigma and others were complex and all broke. Designing ciphers is hard and should be left to experts with definitions and proofs.

The three principles of modern cryptography

DefinitionThe principles

  1. Exact definitions: formulate a rigorous definition of security before anything else.
  2. Precise assumptions: if security relies on an unproven assumption, state it precisely and keep it minimal.
  3. Rigorous proofs: prove the construction meets the definition, relative to the stated assumption.

Principle 1: exact definitions

NoteWhy definitions come first

  • Design: without a target you can’t tell when you’ve hit it, and post hoc definitions risk stopping when patience runs out or overbuilding.
  • Usage: match the guarantee a scheme provides to what the application needs (the strongest scheme may be needlessly slow).
  • Study: compare schemes on security, not just efficiency.

ExampleFive attempts to define secure encryption

AttemptSecure if no adversary can…Flaw
1find the keyEnc that outputs the plaintext is “secure”
2find the plaintextleaking 90% (say, all but the salary in a contract) passes
3find any character of the plaintextlearning “salary > $100,000” passes
4derive meaningful information”meaningful” depends on the application
5compute any function of the plaintextthe right idea, once formalised (Chapters 2–3)

The general principle: definitions should cover all possible applications, because libraries get reused in unforeseen ways. And it is hard to turn intuition into a correct definition: if the definition isn’t what you meant, a “proven secure” scheme may protect nothing.

DefinitionAnatomy of a security definition

A scheme is secure if no adversary of a specified power can achieve a specified break.

  • Break: what the adversary must achieve (here: learn any function of the plaintext).
  • Power: what it can do (the attack model) and how much computation it has (unbounded in Chapter 2; polynomial time elsewhere in the book).
  • Arbitrary adversary principle: assume things about the adversary’s abilities, never its strategy. Predicting attack strategies has always failed.

WarningModels versus reality

A definition is a mathematical model of a real need. A scheme proven secure may still leak its key through a smart card’s power consumption: the proof is fine, the model omitted side channels. The fix is to refine the definition or harden the hardware. Even a mis-specified definition tells you where you stand; without one you can’t even say what went wrong. Turing faced the same issue for computability and justified his model by intuition, equivalence of definitions, and examples. Cryptographic definitions are validated the same way, plus the test of time.

Principle 2: precise assumptions

NoteWhy state assumptions precisely

Most constructions can’t be proven secure unconditionally (that would resolve open complexity questions). So assumptions must be:

  1. validated: only a precisely stated assumption can be studied and possibly refuted, and confidence grows as it survives scrutiny;
  2. comparable: prefer the scheme resting on the weaker (or better-studied) assumption;
  3. usable in proofs: “secure if X holds” needs X stated exactly.

Assuming the scheme itself is secure is technically precise but frowned upon. Simple, low-level assumptions (a mathematical problem is hard) are easier to study and can be shared across many constructions and swapped out if one instantiation fails. The book’s arc: build encryption and MACs from pseudorandom functions (Chapters 3–4), build PRFs in practice (Chapter 5), then from lower-level primitives (Chapter 6).

Principle 3: rigorous proofs

ImportantWhy proofs are essential here

Security can’t be tested like functionality: garbled-looking ciphertext proves nothing. Intuition in security has a long record of failure, the stakes are high, and unlike ordinary users, attackers actively hunt for the exact failure modes. Reductionist proofs: to show “if assumption X holds, construction Y is secure”, show how any adversary breaking Y can be used as a subroutine to break X.


Perfect secrecy

NoteSetting and conventions

Gen induces a distribution on keys KK, the sender’s message is a random MM (modelling the adversary’s prior), and KK and MM are independent (the key is fixed before the message is known). These determine the distribution of the ciphertext CC. Enc may be randomised; correctness is exact, so Dec can be taken deterministic. Convention for the chapter: every message and ciphertext has positive probability, so conditioning is always defined (Exercise 2.6 removes this). The adversary is computationally unbounded.

DefinitionPerfect secrecy (Def. 2.1)

(Gen,Enc,Dec)(\mathrm{Gen},\mathrm{Enc},\mathrm{Dec}) over M\mathcal M is perfectly secret if for every distribution on M\mathcal M, every mm and every cc with Pr⁡[C=c]>0\Pr[C = c] > 0,

Pr⁡[M=m∣C=c]=Pr⁡[M=m]\Pr[M = m\mid C = c] = \Pr[M = m]

Seeing the ciphertext doesn’t change the adversary’s beliefs: MM and CC are independent. In information-theoretic terms, I(M;C)=0I(M;C) = 0 (mutual information).

LemmaLemma 2.2 — Ciphertext distribution ignores the message

Perfectly secret ⟺ for every distribution on M\mathcal M, every mm, cc:

Pr⁡[C=c∣M=m]=Pr⁡[C=c]\Pr[C = c\mid M = m] = \Pr[C = c]

ProofBayes’ rule, both directions

(⇐) Multiply by Pr⁡[M=m]/Pr⁡[C=c]\Pr[M = m]/\Pr[C = c]; by Bayes, the left side is Pr⁡[M=m∣C=c]\Pr[M = m\mid C = c]. (⇒, Exercise 2.1) Reverse the same steps: Pr⁡[C=c∣M=m]=Pr⁡[M=m∣C=c]Pr⁡[C=c]/Pr⁡[M=m]=Pr⁡[C=c]\Pr[C = c\mid M = m] = \Pr[M = m\mid C = c]\Pr[C = c]/\Pr[M = m] = \Pr[C = c]. Positivity of all probabilities is what licenses the divisions.

∎

LemmaLemma 2.3 — Perfect indistinguishability

Perfectly secret ⟺ for every m0,m1m_0, m_1 and cc: Pr⁡[C=c∣M=m0]=Pr⁡[C=c∣M=m1]\Pr[C = c\mid M = m_0] = \Pr[C = c\mid M = m_1]. The ciphertext distribution C(m)\mathcal C(m) is the same for every message.

ProofConstant conditional ⇒ equals the marginal

(⇒) Both sides equal Pr⁡[C=c]\Pr[C = c] by Lemma 2.2. (⇐) If Pr⁡[C=c∣M=m]=γ\Pr[C = c\mid M = m] = \gamma for all mm, total probability gives Pr⁡[C=c]=∑mγPr⁡[M=m]=γ\Pr[C = c] = \sum_m\gamma\Pr[M = m] = \gamma, so Lemma 2.2 applies.

∎

DefinitionAdversarial indistinguishability experiment PrivKA,Πeav\mathrm{PrivK}^{\mathrm{eav}}_{\mathcal A,\Pi}

  1. A\mathcal A outputs m0,m1∈Mm_0, m_1\in\mathcal M.
  2. k←Genk\leftarrow\mathrm{Gen}, b←{0,1}b\leftarrow\{0,1\} uniform, c←Enck(mb)c\leftarrow\mathrm{Enc}_k(m_b) given to A\mathcal A.
  3. A\mathcal A outputs b′b'; the experiment outputs 1 (success) iff b′=bb' = b.

Definition 2.4: Π\Pi is perfectly secret iff Pr⁡[PrivKA,Πeav=1]=12\Pr[\mathrm{PrivK}^{\mathrm{eav}}_{\mathcal A,\Pi} = 1] = \frac12 for every A\mathcal A, with no limit on its computation. Random guessing already achieves 12\frac12; the requirement is that nothing does better.

TheoremProposition 2.5 — The definitions agree

Definitions 2.1 and 2.4 are equivalent.

ProofBoth directions (Exercises 2.7–2.8)

(2.1 ⇒ 2.4) Perfect secrecy holds for the uniform distribution on {m0,m1}\{m_0,m_1\} (Exercise 2.6), so by Lemma 2.3 cc has the same law whatever bb is. Then cc is independent of bb, and no function of cc guesses bb with probability other than 12\frac12.

(2.4 ⇒ 2.1) If not perfectly secret, Lemma 2.3 gives m0,m1,c∗m_0, m_1, c^* with Pr⁡[C=c∗∣m0]≠Pr⁡[C=c∗∣m1]\Pr[C = c^*\mid m_0]\ne\Pr[C = c^*\mid m_1]. The adversary outputs (m0,m1)(m_0,m_1) and guesses the bb maximising Pr⁡[C=c∣M=mb]\Pr[C = c\mid M = m_b] (maximum likelihood). Its success probability is 12∑cmax⁡bPr⁡[C=c∣mb]>12\frac12\sum_c\max_b\Pr[C = c\mid m_b] > \frac12, since the max exceeds the average at c∗c^*. (Sketch worked here.)

∎


The one-time pad (Vernam’s cipher)

DefinitionOne-time pad

M=K=C={0,1}ℓ\mathcal M = \mathcal K = \mathcal C = \{0,1\}^\ell; Gen picks kk uniformly; Enck(m)=k⊕m\mathrm{Enc}_k(m) = k\oplus m; Deck(c)=k⊕c\mathrm{Dec}_k(c) = k\oplus c. Correctness: k⊕k⊕m=mk\oplus k\oplus m = m. Patented by Vernam (1917); proven perfectly secret by Shannon about 25 years later.

TheoremTheorem 2.6 — The one-time pad is perfectly secret

ProofEvery ciphertext is equally likely under every message

For any mm, cc: Pr⁡[C=c∣M=m]=Pr⁡[m⊕K=c]=Pr⁡[K=m⊕c]=2−ℓ\Pr[C = c\mid M = m] = \Pr[m\oplus K = c] = \Pr[K = m\oplus c] = 2^{-\ell}, since KK is uniform and independent of MM. This doesn’t depend on mm, so by Bayes,

Pr⁡[M=m0∣C=c]=2−ℓPr⁡[M=m0]∑m2−ℓPr⁡[M=m]=Pr⁡[M=m0]\Pr[M = m_0\mid C = c] = \frac{2^{-\ell}\Pr[M = m_0]}{\sum_m2^{-\ell}\Pr[M = m]} = \Pr[M = m_0]

Intuition: for any cc, every mm has exactly one key k=m⊕ck = m\oplus c producing it, and every key is equally likely.

∎

WarningDrawbacks

  1. Key as long as the message, and an upper bound on message length must be known in advance.
  2. One use only. With c=m⊕kc = m\oplus k, c′=m′⊕kc' = m'\oplus k: c⊕c′=m⊕m′c\oplus c' = m\oplus m'. That already breaks perfect secrecy for two messages, and with enough English message pairs, frequency analysis recovers the messages.
  3. Known-plaintext attack: one pair (m,c)(m,c) gives k=c⊕mk = c\oplus m, decrypting everything else under that key.

Rumour has it that the Cold War Washington–Moscow hotline used a one-time pad: governments can afford to courier long keys. Commercial settings can’t.

ExampleExcluding the all-zero key doesn’t help (Exercise 2.3)

Drawing kk uniformly from {0,1}ℓ∖{0ℓ}\{0,1\}^\ell\setminus\{0^\ell\} is not perfectly secret: now ∣K∣<∣M∣\lvert\mathcal K\rvert < \lvert\mathcal M\rvert, so Theorem 2.7 applies. Concretely, c=mc = m is now impossible, so seeing cc rules out m=cm = c. The resolution of the paradox: k=0ℓk = 0^\ell sends mm in the clear, but the adversary doesn’t know which key was used, so the ciphertext mm is indistinguishable from any other. Security is a property of the key distribution, not of individual keys. (Worked here.)


Limitations of perfect secrecy

TheoremTheorem 2.7 — Keys must be at least as numerous as messages

Any perfectly secret scheme has ∣K∣≥∣M∣\lvert\mathcal K\rvert\ge\lvert\mathcal M\rvert. For fixed-length keys and messages: the key is at least as long as the message.

ProofA ciphertext can only decrypt to ∣K∣\lvert\mathcal K\rvert messages

Suppose ∣K∣<∣M∣\lvert\mathcal K\rvert < \lvert\mathcal M\rvert. Take the uniform distribution on M\mathcal M and any cc that is a possible encryption. Let M(c)={Deck^(c):k^∈K}\mathcal M(c) = \{\mathrm{Dec}_{\hat k}(c) : \hat k\in\mathcal K\}; since Dec is deterministic, ∣M(c)∣≤∣K∣<∣M∣\lvert\mathcal M(c)\rvert\le\lvert\mathcal K\rvert < \lvert\mathcal M\rvert. So some m′∉M(c)m'\notin\mathcal M(c) has Pr⁡[M=m′∣C=c]=0≠Pr⁡[M=m′]\Pr[M = m'\mid C = c] = 0\ne\Pr[M = m'].

∎

Warning“One-time-pad security with short keys”

Anyone claiming an unbreakable scheme with OTP-level security and short keys either misunderstands cryptography or is lying. Theorem 2.7 makes it impossible. (The other limitations, such as single use, are inherent too: Exercise 2.9.)

IntuitionEntropy version

The information-theoretic form of the same fact is H(K)≥H(M)H(K)\ge H(M) for perfect secrecy: the key must carry at least as much uncertainty as the message it hides (Shannon 1949; compare mutual information).

Shannon’s theorem

TheoremTheorem 2.8 — Shannon’s characterisation

Suppose ∣M∣=∣K∣=∣C∣\lvert\mathcal M\rvert = \lvert\mathcal K\rvert = \lvert\mathcal C\rvert (the most economical case: ∣K∣≥∣M∣\lvert\mathcal K\rvert\ge\lvert\mathcal M\rvert by Theorem 2.7, and ∣C∣≥∣M∣\lvert\mathcal C\rvert\ge\lvert\mathcal M\rvert by decryptability). The scheme is perfectly secret iff

  1. every key is chosen with probability 1/∣K∣1/\lvert\mathcal K\rvert; and
  2. for every mm and cc there is exactly one key kk with Enck(m)=c\mathrm{Enc}_k(m) = c.
ProofCounting forces uniqueness, Bayes forces uniformity (deterministic Enc)

(⇒) Uniqueness. Every (m,c)(m,c) needs at least one key, or Pr⁡[M=m∣C=c]=0\Pr[M = m\mid C = c] = 0. So for fixed mm, {Enck(m)}k\{\mathrm{Enc}_k(m)\}_k covers all of C\mathcal C. Its size is at most ∣K∣=∣C∣\lvert\mathcal K\rvert = \lvert\mathcal C\rvert, so k↦Enck(m)k\mapsto\mathrm{Enc}_k(m) is a bijection: exactly one key per (m,c)(m,c).

(⇒) Uniform keys. Fix cc and label keys kik_i so that Encki(mi)=c\mathrm{Enc}_{k_i}(m_i) = c (distinct by uniqueness). Perfect secrecy and Bayes give Pr⁡[M=mi]=Pr⁡[K=ki]Pr⁡[M=mi]/Pr⁡[C=c]\Pr[M = m_i] = \Pr[K = k_i]\Pr[M = m_i]/\Pr[C = c], so Pr⁡[K=ki]=Pr⁡[C=c]\Pr[K = k_i] = \Pr[C = c] for all ii: all keys are equally likely.

(⇐) Each (m,c)(m,c) has a single key of probability 1/∣K∣1/\lvert\mathcal K\rvert, so Pr⁡[C=c∣M=m]=1/∣K∣\Pr[C = c\mid M = m] = 1/\lvert\mathcal K\rvert for all mm. Lemma 2.3 finishes.

∎

ImportantUses of Shannon’s theorem

  • Complete characterisation in the economical case: perfect secrecy is the one-time pad’s structure (a Latin-square key table with uniform keys).
  • Distribution-free: conditions 1–2 don’t mention the message distribution, so perfect secrecy for one distribution implies it for all.
  • Easy checking: verify uniform keys and a unique key per pair, with no probability calculations. Theorem 2.6 is immediate.
  • Only when ∣M∣=∣K∣=∣C∣\lvert\mathcal M\rvert = \lvert\mathcal K\rvert = \lvert\mathcal C\rvert.

ExampleClassical ciphers that are perfectly secret (Exercise 2.4)

  • Shift cipher on a single letter: ∣M∣=∣K∣=∣C∣=26\lvert\mathcal M\rvert = \lvert\mathcal K\rvert = \lvert\mathcal C\rvert = 26, uniform keys, and k=c−mk = c - m is the unique key. Shannon applies.
  • Substitution: perfectly secret for messages of a fixed length n≤26n\le26 with all distinct letters. A uniform permutation sends any such message to a uniform distinct-letter string of length nn. The largest such space is all 26!26! orderings of the alphabet (n=26n = 26). Repeated letters leak the pattern of equalities, and different lengths leak length.
  • Vigenère: use a uniformly random key as long as the word. Each letter is then an independent single-letter shift, which is a one-time pad mod 26.

Reconciliation with Chapter 1: those attacks needed the key to be reused across many letters (fixed mapping, short period). Perfect secrecy holds exactly when there is no reuse. (Worked here.)


Further exercises

ExampleShort answers

  • 2.2 (posteriors all equal?) False. Perfect secrecy gives Pr⁡[M=m∣C=c]=Pr⁡[M=m]\Pr[M = m\mid C = c] = \Pr[M = m], which differs across mm under a non-uniform prior.
  • 2.5 (uniform key and ∣K∣=∣M∣\lvert\mathcal K\rvert = \lvert\mathcal M\rvert suffice?) False. Enck(m)=m\mathrm{Enc}_k(m) = m has both properties and is correct, but leaks everything. Shannon’s condition 2 is what matters.
  • 2.9 (two-message perfect secrecy is impossible) Under one key, deterministic decryption forces c=c′⇒m=m′c = c'\Rightarrow m = m'. Conditioning on c=c′c = c' makes Pr⁡[M=m,M′=m′∣⋅]=0\Pr[M = m, M' = m'\mid\cdot] = 0 for m≠m′m\ne m', which differs from the prior under any distribution with two messages of positive probability.
  • 2.10 (secrecy given distinct messages) Achievable by a uniformly random permutation of M\mathcal M as the key: any two distinct messages map to a uniform pair of distinct ciphertexts. The key is about log⁡2(∣M∣!)≈∣M∣log⁡2∣M∣\log_2(\lvert\mathcal M\rvert!)\approx\lvert\mathcal M\rvert\log_2\lvert\mathcal M\rvert bits, exponentially longer than a message.
  • 2.11 (allowing decryption error ≤1−2−t\le1-2^{-t}) Encrypt by ignoring mm and outputting nothing (or random bits); decrypt by guessing uniformly. Perfectly secret with ∣K∣=1\lvert\mathcal K\rvert = 1, and correct with probability 1/∣M∣≥2−t1/\lvert\mathcal M\rvert\ge2^{-t} whenever ∣M∣≤2t\lvert\mathcal M\rvert\le2^t.

(Answers worked here.)

TheoremAlmost-perfect secrecy (Exercise 2.12)

Take uniform MM and a possible ciphertext cc, and let M(c)\mathcal M(c) be its decryptions under all keys, so ∣K∣≥∣M(c)∣\lvert\mathcal K\rvert\ge\lvert\mathcal M(c)\rvert.

  • Pointwise version (as stated: ∣Pr⁡[M=m∣c]−Pr⁡[M=m]∣<ε\lvert\Pr[M = m\mid c] - \Pr[M = m]\rvert < \varepsilon for all mm): the posterior sums to 1 over M(c)\mathcal M(c) with each term below 1/∣M∣+ε1/\lvert\mathcal M\rvert + \varepsilon, so ∣K∣>∣M∣1+ε∣M∣\lvert\mathcal K\rvert > \frac{\lvert\mathcal M\rvert}{1 + \varepsilon\lvert\mathcal M\rvert}. This is weak: about 1/ε1/\varepsilon for large message spaces.
  • Statistical-distance version (12∑m∣Pr⁡[M=m∣c]−Pr⁡[M=m]∣≤ε\frac12\sum_m\lvert\Pr[M = m\mid c] - \Pr[M = m]\rvert\le\varepsilon): each excluded message contributes its full 1/∣M∣1/\lvert\mathcal M\rvert, so at most 2ε∣M∣2\varepsilon\lvert\mathcal M\rvert messages are excluded and ∣K∣≥(1−2ε)∣M∣\lvert\mathcal K\rvert\ge(1 - 2\varepsilon)\lvert\mathcal M\rvert. This is the hint’s ”(1−ε)(1-\varepsilon) fraction” bound, up to the factor of 2.

Either way, near-perfect secrecy still demands keys of essentially message length. Breaking this barrier needs computational security.


Quick reference

ObjectStatementNote
Scheme(Gen,Enc,Dec)(\mathrm{Gen},\mathrm{Enc},\mathrm{Dec}), Deck(Enck(m))=m\mathrm{Dec}_k(\mathrm{Enc}_k(m)) = mprivate key
Kerckhoffsonly the key is secret; publish algorithmsno security by obscurity
Attacksciphertext-only < known-plaintext < chosen-plaintext < chosen-ciphertext
Shift26 keys; brute force
Substitution26!≈28826!\approx2^{88} keys; frequency analysislarge key space ≠ security
Shift statisticIj=∑piqi+j≈0.065I_j = \sum p_iq_{i+j}\approx0.065 at the key
Vigenèrett interleaved shiftsKasiski gcd; IC 0.0650.065 vs 0.0380.038
Principlesdefinitions, precise minimal assumptions, proofs
Definition formno adversary of given power achieves given breakarbitrary-adversary principle
Encryption breakcomputing any function of the plaintext
Perfect secrecyPr⁡[M=m∣C=c]=Pr⁡[M=m]\Pr[M = m\mid C = c] = \Pr[M = m]I(M;C)=0I(M;C) = 0
EquivalentsPr⁡[C=c∣m]\Pr[C = c\mid m] constant in mm; PrivKeav\mathrm{PrivK}^{\mathrm{eav}} success =12=\frac12unbounded adversary
One-time padc=k⊕mc = k\oplus m, kk uniformperfectly secret
OTP failure modesreuse leaks m⊕m′m\oplus m'; known plaintext gives kk
Key bound∣K∣≥∣M∣\lvert\mathcal K\rvert\ge\lvert\mathcal M\rvertH(K)≥H(M)H(K)\ge H(M)
Shannonuniform keys + unique key per (m,c)(m,c)when ∣M∣=∣K∣=∣C∣\lvert\mathcal M\rvert = \lvert\mathcal K\rvert = \lvert\mathcal C\rvert

Facts to keep to hand

  • Classical ciphers fail for structural reasons. A fixed mapping or a reused short key preserves the statistics of language, so frequency analysis, Kasiski and the index of coincidence break them, and any known or chosen plaintext breaks them instantly. A huge key space is necessary but never sufficient.
  • Modern cryptography is definitions, assumptions and proofs. Say exactly what a break is and what the adversary can do (but never how it will attack), rest on minimal well-studied assumptions, and prove security by reduction.
  • Perfect secrecy means the ciphertext is independent of the message. Equivalently, every message induces the same ciphertext distribution, and no adversary, however powerful, beats a coin flip at telling two messages apart.
  • Perfect secrecy costs a key as long as the message. The one-time pad achieves it, Shannon’s theorem says it is essentially the only way, and the key-length bound (plus single use) is why the rest of the book relaxes to computational security.

References

← All notes