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.
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.
| Era | Approach | Typical outcome |
|---|---|---|
| Classical | ad hoc design, security by intuition | broken, sometimes centuries later |
| Shannon (1949) | definitions + proofs, no assumptions | perfect secrecy, but keys as long as messages |
| Modern (Goldwasser–Micali, 1980s) | definitions + precise assumptions + proofs | practical 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 :
- Gen (probabilistic) outputs a key from the key space ;
- Enc takes and a plaintext , outputs a ciphertext ;
- Dec takes and , outputs a plaintext .
and determine the ciphertext space . Correctness: for every key output by Gen and every .
| Component | Detail |
|---|---|
| Symmetric | the same key encrypts and decrypts (contrast public-key, Chapter 9) |
| Hidden assumption | the parties somehow shared the key secretly beforehand |
| Where it suffices | disk 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:
- a short random key is far easier to keep secret than a program, which can leak or be reverse engineered;
- a compromised key is easy to replace; a compromised algorithm isn’t, and many pairs of users can share one algorithm with different keys;
- 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)
| Attack | Adversary can | Type |
|---|---|---|
| Ciphertext-only | observe ciphertexts | passive |
| Known-plaintext | also see some plaintext–ciphertext pairs under the same key | passive |
| Chosen-plaintext | obtain encryptions of plaintexts of its choice | active |
| Chosen-ciphertext | also 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 , and 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 (, wrapping ). “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 uniformly from ; and .
ExampleBreaking it by brute force
Only 26 keys: try them all. The book’s challenge ciphertext OVDTHUFWVZZPISLRLFZHYLAOLYL decrypts with 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 – 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 .
Mono-alphabetic substitution
DefinitionSubstitution cipher
The key is a permutation of the alphabet, applied letter by letter: keys, far beyond brute force.
WarningLarge key space, still trivially broken
Two facts kill it:
- the mapping is fixed, so each plaintext letter always becomes the same ciphertext letter;
- 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 be English letter frequencies, so (1.1), and let be the ciphertext frequencies. If the key is , then . Compute
and output the whose is closest to . 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 (the period ). Plaintext position is shifted by key letter , cycling through the key. Equivalently, 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 streams . Each is a shift cipher with key . Break each stream with frequency matching or the statistic. This needs frequency tables, not a search over 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 , so distances between repeats are (mostly) multiples of . Take the gcd. (Book example: with key “beads”, two occurrences of “the” both become MJJ, 40 positions apart, and .)
Index of coincidence: for , compute over the stream . At the stream is a shifted English distribution, so . Otherwise letters look roughly uniform and . 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 times more (each of 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)
| Cipher | Known plaintext needed | Chosen plaintext needed |
|---|---|---|
| Shift | 1 letter: | encrypt “a” |
| Substitution | text covering 25 distinct letters (the 26th is forced) | encrypt “abc…y” (25 letters) |
| Vigenère | consecutive letters, (if unknown, read it off a long enough sample) | encrypt “aaa…a”: the ciphertext is the key repeated, revealing and |
(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 substitution alphabets: split into streams (period via index of coincidence, which is invariant under substitution), then break each stream with frequency analysis.
- Block-dependent shifts in block : decryption just subtracts . Kasiski weakens: identical plaintext now repeats identically only when the block distance is a multiple of 26, so the effective period is . Better attack: by Kerckhoffs the structure is known, so subtract from every letter of block (for a guessed ) to recover ordinary Vigenère ciphertext, then attack as usual.
(Worked here.)
ImportantLessons from classical ciphers
- Sufficient key space is necessary, never sufficient.
- 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
- Exact definitions: formulate a rigorous definition of security before anything else.
- Precise assumptions: if security relies on an unproven assumption, state it precisely and keep it minimal.
- 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
| Attempt | Secure if no adversary can… | Flaw |
|---|---|---|
| 1 | find the key | Enc that outputs the plaintext is “secure” |
| 2 | find the plaintext | leaking 90% (say, all but the salary in a contract) passes |
| 3 | find any character of the plaintext | learning “salary > $100,000” passes |
| 4 | derive meaningful information | ”meaningful” depends on the application |
| 5 | compute any function of the plaintext | the 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:
- validated: only a precisely stated assumption can be studied and possibly refuted, and confidence grows as it survives scrutiny;
- comparable: prefer the scheme resting on the weaker (or better-studied) assumption;
- 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 , the sender’s message is a random (modelling the adversary’s prior), and and are independent (the key is fixed before the message is known). These determine the distribution of the ciphertext . 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)
over is perfectly secret if for every distribution on , every and every with ,
Seeing the ciphertext doesn’t change the adversary’s beliefs: and are independent. In information-theoretic terms, (mutual information).
LemmaLemma 2.2 — Ciphertext distribution ignores the message
Perfectly secret ⟺ for every distribution on , every , :
ProofBayes’ rule, both directions
(⇐) Multiply by ; by Bayes, the left side is . (⇒, Exercise 2.1) Reverse the same steps: . Positivity of all probabilities is what licenses the divisions.
∎
LemmaLemma 2.3 — Perfect indistinguishability
Perfectly secret ⟺ for every and : . The ciphertext distribution is the same for every message.
ProofConstant conditional ⇒ equals the marginal
(⇒) Both sides equal by Lemma 2.2. (⇐) If for all , total probability gives , so Lemma 2.2 applies.
∎
DefinitionAdversarial indistinguishability experiment
- outputs .
- , uniform, given to .
- outputs ; the experiment outputs 1 (success) iff .
Definition 2.4: is perfectly secret iff for every , with no limit on its computation. Random guessing already achieves ; 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 (Exercise 2.6), so by Lemma 2.3 has the same law whatever is. Then is independent of , and no function of guesses with probability other than .
(2.4 ⇒ 2.1) If not perfectly secret, Lemma 2.3 gives with . The adversary outputs and guesses the maximising (maximum likelihood). Its success probability is , since the max exceeds the average at . (Sketch worked here.)
∎
The one-time pad (Vernam’s cipher)
DefinitionOne-time pad
; Gen picks uniformly; ; . Correctness: . 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 , : , since is uniform and independent of . This doesn’t depend on , so by Bayes,
Intuition: for any , every has exactly one key producing it, and every key is equally likely.
∎
WarningDrawbacks
- Key as long as the message, and an upper bound on message length must be known in advance.
- One use only. With , : . That already breaks perfect secrecy for two messages, and with enough English message pairs, frequency analysis recovers the messages.
- Known-plaintext attack: one pair gives , 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 uniformly from is not perfectly secret: now , so Theorem 2.7 applies. Concretely, is now impossible, so seeing rules out . The resolution of the paradox: sends in the clear, but the adversary doesn’t know which key was used, so the ciphertext 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 . For fixed-length keys and messages: the key is at least as long as the message.
ProofA ciphertext can only decrypt to messages
Suppose . Take the uniform distribution on and any that is a possible encryption. Let ; since Dec is deterministic, . So some has .
∎
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 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 (the most economical case: by Theorem 2.7, and by decryptability). The scheme is perfectly secret iff
- every key is chosen with probability ; and
- for every and there is exactly one key with .
ProofCounting forces uniqueness, Bayes forces uniformity (deterministic Enc)
(⇒) Uniqueness. Every needs at least one key, or . So for fixed , covers all of . Its size is at most , so is a bijection: exactly one key per .
(⇒) Uniform keys. Fix and label keys so that (distinct by uniqueness). Perfect secrecy and Bayes give , so for all : all keys are equally likely.
(⇐) Each has a single key of probability , so for all . 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 .
ExampleClassical ciphers that are perfectly secret (Exercise 2.4)
- Shift cipher on a single letter: , uniform keys, and is the unique key. Shannon applies.
- Substitution: perfectly secret for messages of a fixed length with all distinct letters. A uniform permutation sends any such message to a uniform distinct-letter string of length . The largest such space is all orderings of the alphabet (). 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 , which differs across under a non-uniform prior.
- 2.5 (uniform key and suffice?) False. 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 . Conditioning on makes for , 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 as the key: any two distinct messages map to a uniform pair of distinct ciphertexts. The key is about bits, exponentially longer than a message.
- 2.11 (allowing decryption error ) Encrypt by ignoring and outputting nothing (or random bits); decrypt by guessing uniformly. Perfectly secret with , and correct with probability whenever .
(Answers worked here.)
TheoremAlmost-perfect secrecy (Exercise 2.12)
Take uniform and a possible ciphertext , and let be its decryptions under all keys, so .
- Pointwise version (as stated: for all ): the posterior sums to 1 over with each term below , so . This is weak: about for large message spaces.
- Statistical-distance version (): each excluded message contributes its full , so at most messages are excluded and . This is the hint’s ” 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
| Object | Statement | Note |
|---|---|---|
| Scheme | , | private key |
| Kerckhoffs | only the key is secret; publish algorithms | no security by obscurity |
| Attacks | ciphertext-only < known-plaintext < chosen-plaintext < chosen-ciphertext | |
| Shift | 26 keys; brute force | |
| Substitution | keys; frequency analysis | large key space ≠ security |
| Shift statistic | at the key | |
| Vigenère | interleaved shifts | Kasiski gcd; IC vs |
| Principles | definitions, precise minimal assumptions, proofs | |
| Definition form | no adversary of given power achieves given break | arbitrary-adversary principle |
| Encryption break | computing any function of the plaintext | |
| Perfect secrecy | ||
| Equivalents | constant in ; success | unbounded adversary |
| One-time pad | , uniform | perfectly secret |
| OTP failure modes | reuse leaks ; known plaintext gives | |
| Key bound | ||
| Shannon | uniform keys + unique key per | when |
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
- Katz & Lindell, Introduction to Modern Cryptography — Chapters 1–2
- Shannon, “Communication Theory of Secrecy Systems” (1949)
- Kahn, The Codebreakers — history of classical ciphers