Ancient Secrets

Secret Writing: A History of Codes, Ciphers and Codebreaking

Course 1 · Chapter 2 · Ancient Secrets

Chapter 1 gave you the vocabulary. This chapter puts it to work on the oldest ciphers we know of, each of which you can carry out with a pencil in a couple of minutes. They come from Sparta, Rome, ancient Israel, India and China, and they fall into two families that will run through the rest of the course: ciphers that move letters around, and ciphers that swap letters for other letters.

Two Families of Cipher

TranspositionSubstitution
What it doesKeeps the same letters but changes their orderKeeps the order but replaces each letter
Ancient exampleThe Spartan scytaleCaesar shift, Atbash, the Indian "Kama Sutra" pairing
Letter countsUnchanged: the same letters appear the same number of timesChanged: every letter is now disguised as another

The Scytale: A Cipher You Can Hold

Greek writers describe the Spartan scytale (roughly "skytalee"), a wooden rod. A strip of leather or parchment was wound around it in a spiral, the message was written along the length of the rod, and the strip was then unwound. Off the rod, the strip showed only a jumble of letters. The recipient owned a rod of the same thickness, wound the strip back on and read the message across it.

The rod is the key. Today we would call this a transposition cipher: no letter is changed, only the order. You can imitate it with a grid, which is how the puzzle at the end of the chapter works.

Rod with 3 rows; message written across each row: S E N D H E L P N O W X (X is padding to fill the grid) Strip unwound: read down each column in turn S H N | E E O | N L W | D P X gives SHNEEONLWDPX
Not Yet Verified Historians still argue about how the scytale was really used. Some think it was a true encryption device for military orders; others suggest it was a way to authenticate a message (the strip proved it came from the right authority) or even a tally stick. The detailed descriptions we have come from writers who lived centuries after the period they describe. Checked against one web search (general history-of-cryptography summaries, which note the purpose is uncertain); I did not find Plutarch's account in that search, so the ancient source and its exact wording are not verified.

The Caesar Shift

The Roman biographer Suetonius reports that Julius Caesar protected private letters by replacing each letter with the one three places further along the alphabet: A becomes D, B becomes E, and so on, wrapping around at the end so that X becomes A, Y becomes B and Z becomes C. The same idea with any shift is now called a Caesar cipher, and the shift is the key.

Shift of 3 Plain : A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Cipher : D E F G H I J K L M N O P Q R S T U V W X Y Z A B C MEET AT THE BRIDGE becomes PHHW DW WKH EULGJH

To decipher, shift the other way. Caesar's cipher was strong enough for its day mainly because most people could not read at all, and an enemy who could read still had to realise it was a cipher rather than a foreign language. As a system it is feeble: there are only 25 useful shifts, so anyone who suspects the method can simply try them all. That is the first lesson of cryptanalysis you will meet: a key that can be guessed by trying every possibility gives little protection.

Timeline of the ancient devices Around 500 BC or earlier: Atbash in Hebrew scripture. Around 400 BC: Spartan scytale, according to later Greek writers. First century BC: Caesar's shift of three, reported by Suetonius around 120 AD. Roughly 400 BC to 200 AD (dates uncertain): the Kama Sutra lists secret writing among the skills to learn.

Atbash: Reversing the Alphabet

Atbash is a Hebrew substitution in which the first letter of the alphabet swaps with the last, the second with the second-last, and so on. The name itself shows how it works: it is built from the Hebrew letters aleph, taw, beth and shin, the first, last, second and second-last letters. Scholars note that some Hebrew scriptural passages appear to use it; the best-known example is a name for Babylon in the Book of Jeremiah, usually written "Sheshach" and read as Babylon after the substitution.

The same idea works on the Latin alphabet, where A swaps with Z, B with Y and so on:

Plain : A B C D E F G H I J K L M Cipher : Z Y X W V U T S R Q P O N (the second half simply reads the same pairs backwards: N<->M, O<->L, ...) HELP becomes SVOK

Atbash has no key at all: there is exactly one Atbash. Enciphering and deciphering are the same operation, which is neat, but anyone who knows the trick reads everything. It is a good example of Kerckhoffs's idea from Chapter 1 failing: the method is the only secret.

India and China

The Kama Sutra's pairing cipher

The Kama Sutra, an Indian text on the arts of life, lists among the skills to be learned a kind of secret writing known as mlecchita vikalpa. One method described in commentary is a pairing cipher: the alphabet is divided into pairs at random, and each letter is replaced by its partner. Atbash is the special case where the pairs are fixed by reversing the alphabet. A random pairing is better because there is now a key, the pairing, that has to be shared.

China

Chinese writing makes classic letter ciphers awkward, because it has thousands of characters rather than a short alphabet. Chinese military writers instead relied on codes (in the sense of Chapter 1): a list of agreed phrases standing for stock messages, and tokens split between commander and officer that had to match. The lesson is that the writing system itself shapes which kind of secrecy works best.

Not Yet Verified Dates for the Kama Sutra's secret-writing passage vary between sources (from about 400 BC to about 200 AD), and my one web search gave the Indian material only in outline. The comments on Chinese military codes are general background and were not checked against a specific source: treat them as a pointer to follow up rather than settled fact.

How Strong Were They?

CipherTypeNumber of keysMain weakness
ScytaleTranspositionA few dozen sensible rod sizesTry each size until text appears
Caesar shiftSubstitution25Try every shift
AtbashSubstitution1No key; anyone who knows the method reads it
Random pairingSubstitutionVery many (more than any person could try)Needs a cleverer attack: see Chapter 3

That last row points ahead. Once the number of possible keys is too large to try them all, you need a new idea to break the cipher, and it came from scholars in the Arab world, as Chapter 3 explains.

Try it yourself: Caesar's own shift This message was enciphered with Caesar's shift of three (each letter moved three places forward):

HVFDSH WR WKH ULYHU

Show the worked answer

Move each letter three places back: H→E, V→S, F→C, D→A, S→P, H→E gives ESCAPE; W→T, R→O gives TO; W→T, K→H, H→E gives THE; U→R, L→I, Y→V, H→E, U→R gives RIVER. The plaintext is ESCAPE TO THE RIVER.

Exercises

Exercise 1

Use Atbash on the Latin alphabet. (a) Encipher STONE. (b) Decipher XZVHZI. (c) Explain why enciphering and deciphering are the same operation in Atbash but not in a Caesar shift of three.

Exercise 2

A scytale message was unwound from a rod that holds 3 letters per turn: SHNEEONLWDPX. (a) Decipher it by writing the letters in columns of three and reading across. (b) A rod that holds 4 letters per turn is used by mistake. Do you get sensible text? What does this say about the rod as a key?

Exercise 3

This Caesar-type message uses an unknown shift: JHLZHY JPWOLY. (a) Break it by trying shifts one by one until you see English. (b) Which shift was used? (c) Why is this method of attack hopeless against a pairing cipher with a random key, even though both are substitution ciphers?

Quick Reference

  • Transposition: same letters, new order (scytale)
  • Substitution: same order, new letters (Caesar, Atbash, pairing)
  • Caesar shift: move every letter a fixed number of places; only 25 keys
  • Atbash: reverse the alphabet; no key at all
  • Lesson: few possible keys means trying them all breaks the cipher
  • Check: Plutarch's scytale account, the dates of the Kama Sutra passage, Chinese military code details

Next chapter: Arab Scholars and Frequency Analysis, where Al-Kindi shows that even a cipher with an enormous number of keys can fall to simple counting.