दुर्गा बेरागी Durga Beragi, homeEnter the study →

Library › Cryptography, blockchain and crypto

The Code Book

Simon Singh · 1999 · Fourth Estate

More by Simon Singh on this shelf · 2 books →

History of codes from Mary Queen of Scots to public keys.

About the book

Simon Singh, a science writer with a doctorate in particle physics, published The Code Book in 1999. It is a popular history of cryptography told through stories. Singh begins with the cipher letters that led to the execution of Mary Queen of Scots, then covers the Vigenere cipher and how Charles Babbage broke it, the unsolved Beale ciphers, the Zimmermann telegram, the Enigma machine and its breaking by Polish and British codebreakers, the Navajo code talkers, and the decipherment of ancient scripts such as Egyptian hieroglyphs and Linear B. Later chapters cover public-key cryptography, PGP and quantum cryptography. The book included a ten-stage cipher challenge with a prize, solved in 2000.

Key ideas

  • Weak encryption is worse than none because it creates false confidence. Mary Queen of Scots wrote openly in a cipher she trusted, and its breaking provided evidence for her execution.
  • Each type of cipher is eventually broken by a new method. Frequency analysis defeated simple substitution, and the Vigenere cipher fell to methods worked out by Babbage and Kasiski.
  • Enigma was broken first by Polish mathematicians, including Marian Rejewski, and then at Bletchley Park by Alan Turing and others, using machines and the Germans' procedural mistakes.
  • Deciphering lost scripts uses the same reasoning as codebreaking. Champollion's work on hieroglyphs and Ventris's decipherment of Linear B relied on patterns, guesses and known names.
  • Public-key cryptography solved the key distribution problem. Diffie, Hellman, Rivest, Shamir and Adleman published it, but British researchers at GCHQ had found the ideas earlier in secret.
  • Quantum cryptography promises key exchange whose security rests on the laws of physics. Any attempt to eavesdrop on the quantum signal disturbs it and so reveals the eavesdropper.

Why it is on this shelf

It is the clearest single-volume story of how codes are made and broken, ending with the public-key ideas that make wallets and signatures possible. It reads quickly and explains real methods, not just anecdotes. Good for understanding why key distribution was the problem Bitcoin inherited a solution for.

How to start reading it

Read straight through; the chapters build on each other. Pay special attention to the chapters on Vigenere, Enigma and public-key cryptography. Try the worked examples with pencil and paper.

About this book

The Code Book is a popular history of secret writing by the British science writer Simon Singh, first published in 1999 by Fourth Estate in London. In the United States it carried a subtitle about the science of secrecy from ancient Egypt to quantum cryptography, which gives a fair sense of its range. It tells the story of how people have hidden messages and how others have uncovered them, from early substitution ciphers to the mathematics that now protects digital communication.

Singh wrote it for general readers: people with curiosity but no special training in mathematics. His aim was to show that the history of codes is not a collection of curiosities but a long contest with a clear logic. Each new way of hiding messages eventually met a new way of revealing them, and each victory for the codebreakers forced the codemakers to invent something stronger. Along the way the contest shaped wars, trials, diplomacy and, by the end of the twentieth century, the basic infrastructure of commerce and privacy.

The book appeared at a significant moment. The public internet was spreading quickly, online shopping was new, and governments in several countries were still arguing over whether ordinary people should be allowed to use strong encryption. Public-key cryptography, invented in the 1970s, had moved from academic papers into everyday software. Singh wanted his readers to understand where these tools came from and why they mattered, and he believed that the best way to do so was to tell the whole story from the beginning.

The question at the centre of the book is simple to state: is it possible to create a secret message that cannot be read by anyone except the intended recipient? For most of history the honest answer was no, not for long. Singh traces how that answer changed, and why by the end of the twentieth century it had become, for practical purposes, yes, provided the methods are sound and used with care.

Singh also included a practical challenge. At the end of the book he set a series of ten ciphers of increasing difficulty, spanning the methods described in its pages, and offered a cash prize to the first person or team to solve them all. The challenge drew wide participation and was solved in 2000 by a team from Sweden. It was a characteristic gesture. Singh wanted readers to do cryptography, not merely to read about it.

The book is among the most widely read introductions to its subject, and it has been used in schools and universities as a first text. It was adapted for television, and a version for younger readers was published. It remains, for many people, the book that first made them understand what a cipher is and why breaking one can change history.

The author

Simon Singh was born in England in 1964. He studied physics and took a doctorate in particle physics at Cambridge, with research connected to work at CERN, the European laboratory near Geneva. He then left research to work in television, joining the BBC as a producer and director of science programmes.

His first great success came with the story of Fermat's Last Theorem and its proof by the mathematician Andrew Wiles. Singh co-directed a documentary on the subject for the BBC's Horizon series, which was widely praised, and then wrote a book on it, published in 1997. That book established his method: take a hard subject, find the human story inside it, and explain the essential ideas so clearly that a general reader can follow the logic, not just the drama.

The Code Book was his second book, and it applied the same method to a broader subject. He went on to write a history of cosmology, a book with the medical researcher Edzard Ernst examining the evidence for alternative medicine, and a book on the mathematics hidden in a popular animated television series. He became well known in Britain for his advocacy of science and evidence, and for a long legal case in which he was sued for libel over an article about chiropractic. The case ended in his favour and contributed to a reform of English libel law.

Several features of Singh's career bear directly on The Code Book. His training as a physicist shows in his comfort with mathematics and in the chapter on quantum cryptography, which explains a difficult subject without hand-waving. His television background shows in the book's structure: vivid scenes, clear characters, cliffhangers, and a steady return to the human stakes. And his commitment to public understanding of science shows in the care he takes to explain how methods actually work, with worked examples readers can follow.

Singh is not a professional cryptographer, and the book is not a technical treatise. It relies on historians and researchers for its facts, and on interviews with some of the people involved in the modern story. Its distinctive contribution is synthesis and explanation: bringing scattered episodes into one narrative and making their logic clear.

The shape of the book

The book is organised roughly in time, but its real structure is a sequence of contests. Each part presents a method of concealment, explains how it works, shows it in use at a moment of high stakes, and then shows how it was broken. The breaking of one method prepares the ground for the next, so the reader feels the pressure that drove invention. The overall movement is from hand ciphers, worked with pen and paper, to machines, and from machines to mathematics and physics.

Several threads run through the whole. One is the contest between codemakers and codebreakers, presented almost as an evolutionary struggle in which each side adapts to the other. A second is the human cost and consequence of secrecy: lives saved or lost, plots exposed, wars shortened. A third is the recurring theme of the key, the secret that controls a cipher, and the problem of getting it safely to the person who needs it. A fourth is the gradual move from secrecy as a craft to secrecy as a science, with mathematics taking over from intuition.

The book also contains a substantial detour that at first seems out of place: the decipherment of ancient scripts. Singh treats the reading of Egyptian hieroglyphs and of the Bronze Age Greek script known as Linear B as codebreaking problems in a broad sense, where the writers never intended secrecy but time has made their messages unreadable. This section shows that the same reasoning, about patterns, frequencies, guesses and confirmations, applies whether a text was hidden on purpose or by history.

The final part changes character. Having told the story of how every method could be broken, Singh turns to the late twentieth century, when public-key cryptography appeared to solve the oldest problem in the subject. He tells the story of its invention, including the long-secret parallel work in British intelligence, and of the political struggle over whether ordinary people should be allowed strong encryption. He ends with quantum cryptography, which promises security based not on the difficulty of a mathematical problem but on the laws of physics.

Throughout, Singh includes technical explanations, often set apart from the narrative, so that readers can see exactly how a cipher works and how it was broken. These are the heart of the book's value. They are short enough to follow without training, and complete enough that a careful reader can reproduce the methods with paper and pencil.

The book's design rewards reading in order. Later ideas depend on earlier ones, and much of the pleasure lies in seeing how each advance answers an earlier failure. But it is also possible to read the parts on their own, since each episode is told as a complete story.

Idea one: the arms race between makers and breakers

The central idea of the book is that cryptography has developed through a continuous contest between those who make codes and those who break them. Singh presents this almost as an arms race, or as evolution under pressure: each successful attack forces the defenders to invent something new, and each new defence challenges the attackers to find a fresh weakness.

A simple example shows the pattern. The oldest common type of cipher replaces each letter of the alphabet with another letter or symbol according to a fixed rule. For centuries this seemed secure, because the number of possible rules is enormous, far too many to try one by one. The weakness was found not by trying every rule but by noticing that languages have patterns. In English, some letters occur much more often than others, and the most common symbols in a ciphertext probably stand for the most common letters. This method, frequency analysis, made simple substitution ciphers breakable by anyone who knew the trick.

The codemakers responded by using several alphabets in turn, so that the same plain letter could be enciphered differently at different points. This flattened the frequency patterns and defeated simple frequency analysis. For a long time such ciphers were regarded as unbreakable. Eventually the codebreakers found that the repetition of the key created its own patterns, which could be detected and exploited. Each step in the contest followed the same logic: find the regularity the defenders overlooked.

Singh traces frequency analysis back to the Arab world. The earliest known written description of the method comes from the ninth-century scholar al-Kindi, who worked in Baghdad at a time when Islamic scholarship was flourishing in mathematics, linguistics and the study of texts. Singh suggests that the close study of religious texts, including counting how often particular words and letters appeared, helped prepare the ground. The point is a good one: codebreaking grew out of careful reading, not only out of espionage. Europe learned the method later, and by the Renaissance the courts of Italian states and other European powers employed cipher secretaries who could break the simple ciphers of their rivals.

The story of the polyalphabetic cipher associated with the sixteenth-century French diplomat Blaise de Vigenere shows the next turn. For about three centuries it had a reputation as indecipherable, although in practice many users avoided it because it was slow and error-prone. In the nineteenth century it was broken twice, independently. The English mathematician and inventor Charles Babbage worked out a method but did not publish it, and the Prussian officer Friedrich Kasiski published a similar method some years later. The key insight was that a short keyword repeats, so that the same fragment of plaintext enciphered at the same point in the key cycle produces the same fragment of ciphertext. The distances between such repetitions reveal the length of the keyword. Once the length is known, the cipher splits into several simple substitution ciphers, each of which yields to ordinary frequency analysis.

This is a characteristic move in codebreaking, and Singh makes it vivid: break a hard problem into several easy ones. The defenders thought the multiplicity of alphabets protected them. The attackers found that the multiplicity had a structure, and that the structure could be used to undo it.

Singh's way of telling this story has a clear message: no cipher is safe merely because it is complicated or because its users believe it is safe. A method is only as good as the best attack against it, and the best attack may not yet have been found. This is the same principle that underlies modern cryptographic practice, where algorithms are published and attacked openly for years before they are trusted.

The idea is often confused with a claim that every cipher can be broken. Singh does not say that. He describes one method, the one-time pad, that is provably unbreakable if used correctly, and he shows that modern methods may be practically unbreakable. His point is about history: for most of it, the breakers eventually won, and overconfidence was the codemakers' greatest enemy.

The arms race idea leads directly to the modern era. Once machines and then computers entered the contest, the speed of both sides increased dramatically. Codemakers could use far more complex methods; codebreakers could test far more possibilities. The race did not end, but its terms changed, and by the late twentieth century mathematics had given the codemakers a lead that, so far, the breakers have not overturned.

Idea two: false confidence is worse than none

One of the book's most vivid lessons comes from its opening story, about Mary Queen of Scots, who was imprisoned in England in the 1580s and corresponded secretly with supporters plotting to free her and to assassinate Elizabeth I. The letters were enciphered, and the conspirators wrote openly of their plans, trusting the cipher to protect them. The letters were intercepted, the cipher was broken, and the deciphered letters provided the evidence that led to Mary's trial and execution.

Singh draws a general lesson from this case, and he returns to it throughout the book: a weak cipher is more dangerous than no cipher at all, because it encourages people to say things they would never say in the open. Had Mary and her correspondents believed their letters could be read, they would have been more careful. Their confidence in the cipher made them reckless.

The lesson applies far beyond the sixteenth century. People today often trust security they do not understand. A messaging app described as encrypted may be encrypted only between the user and the company's server, not end to end. A password that feels strong may be easily guessed. A system that was secure when designed may have been weakened by later discoveries. In each case the danger is not only that the protection fails, but that the user behaves as though it will not.

An everyday analogy is a lock on a garden shed that can be opened with any small screwdriver. If the owner knows this, they keep valuable tools elsewhere. If they believe the lock is strong, they store everything in the shed. The weak lock has not merely failed to protect; it has drawn valuables into an unsafe place.

The idea is often confused with the claim that encryption is useless. It is the opposite. Singh's point is that encryption must be judged honestly, by experts, against the best known attacks, and that users must understand its limits. This is why modern cryptographers insist on open publication and scrutiny of algorithms, rather than trusting secret methods whose strength cannot be independently checked.

Where the idea leads is to a habit of mind. Whenever one relies on a security measure, it is worth asking: what exactly does this protect against, who has tested it, and what would happen if it failed? People who ask these questions are less likely to repeat Mary's mistake.

Idea three: the key is the whole problem

A thread that runs through the entire book is the problem of the key. In almost every cipher before the 1970s, sender and receiver needed to share a secret, the key, before they could communicate securely. The cipher's design could be known to everyone; what had to stay secret was the key. Getting the key to the right person, without anyone else learning it, was a persistent practical difficulty.

Singh shows this problem in many settings. Armies had to distribute key books to units in the field, knowing that any captured book would compromise every message sent with it. Diplomatic services sent keys by trusted couriers. During the Second World War, the operators of cipher machines received schedules of daily settings, and the capture of such schedules was among the most valuable prizes in intelligence. The more people needed to communicate, the larger the distribution problem became.

The principle that the method may be public while the key stays secret is an important one, and Singh explains why it matters. If security depends on hiding the method, then any leak of the method, through capture, betrayal or analysis, destroys it for everyone. If security depends only on the key, then the method can be published and examined, and only the key needs protecting. Keys can be changed often; methods cannot. This principle, associated with the nineteenth-century writer Auguste Kerckhoffs, is now a foundation of the field.

An analogy is a combination padlock. The design of the lock can be widely known, sold in shops, and studied by anyone. What keeps the locker secure is the combination. If the combination is lost or overheard, one changes it. But one still needs a way to tell a friend the combination without being overheard. That last step is the key distribution problem.

The importance of this thread becomes clear in the final part of the book. Public-key cryptography solved the key distribution problem in a way that had seemed impossible. Two people who had never met, communicating over a channel anyone could hear, could establish a shared secret or send each other protected messages without first exchanging any secret at all. Singh presents this as the greatest single advance in the history of the subject, and the long build-up through earlier chapters allows the reader to feel why.

For readers of this bay, this thread is especially important. Digital money depends on public-key methods. Each owner holds a private key and publishes a corresponding public key or address. Without a solution to the key distribution problem, such systems could not exist. The Code Book explains why that solution was so hard to find and why it changed everything.

Idea four: perfect secrecy exists, and is hard to use

In the middle of the story of the arms race, Singh introduces a method that breaks the pattern: the one-time pad. Here the key is a sequence of truly random letters or numbers, as long as the message itself, used once and then destroyed. Each letter of the message is shifted by the corresponding random value. Because every possible message of the same length is equally consistent with the ciphertext, an interceptor learns nothing from it. No amount of computing power helps. The method is not merely hard to break; it is impossible to break, provided its rules are followed exactly.

Why, then, was it not used for everything? Singh explains the practical difficulties clearly. The key must be as long as all the messages that will ever be sent with it. It must be truly random, which is harder to produce than it sounds. It must be delivered in advance to the recipient by some secure means. And it must never be reused, because two messages enciphered with the same pad can be compared to strip away the key. For a military service sending thousands of messages a day, these demands are crushing.

The one-time pad therefore occupies a special place in the story. It shows that perfect secrecy is possible in principle, which means the arms race is not a law of nature. But it also shows that perfect secrecy moves the whole difficulty into the key. The pad does not solve the key distribution problem; it makes that problem as large as it can be. It has been used where the stakes justify the cost, for instance in certain diplomatic and intelligence links, but not as an everyday tool.

An analogy is a private courier who carries a sealed envelope of random numbers to a friend before any message is sent, and who must make the trip again whenever the envelope runs out. The messages that follow are perfectly safe. But the safety has been paid for in advance with trips that themselves could be intercepted.

The idea is often misunderstood in two directions. Some people think any cipher with a long random-looking key is a one-time pad. It is not: if the key is generated by a formula from a shorter seed, or reused, the guarantee vanishes. Others think that because the one-time pad is impractical, perfect secrecy is irrelevant. In fact the idea guides modern design. Stream ciphers try to imitate a one-time pad by generating a long keystream from a short key, accepting that this gives practical rather than perfect security.

Seen in the light of the whole book, the one-time pad clarifies what public-key cryptography achieved. The pad showed that the problem of secrecy could be solved completely if keys could be distributed. Public-key methods showed that keys could be established without prior meeting. Put together, these two insights explain why modern systems use public-key methods to agree on a key and then fast symmetric methods to protect the actual data.

Idea five: a broken cipher can change history

Singh insists that codebreaking is not a parlour game. His episodes are chosen to show that reading another side's secrets has repeatedly altered the course of events. The execution of Mary Queen of Scots is the first example. The most striking from the early twentieth century is the Zimmermann telegram of 1917.

During the First World War, the German foreign minister Arthur Zimmermann sent an enciphered message to the German ambassador in Mexico. It proposed that, if the United States entered the war against Germany, Mexico should be invited into an alliance and promised the recovery of territory it had lost to the United States in the nineteenth century. British naval intelligence, working in a section known as Room 40, intercepted and deciphered the message. The British then faced a delicate problem: how to reveal the message to the Americans without revealing that they were reading German traffic. They found a way, the telegram was made public, and it helped to turn American opinion toward entering the war, which the United States did a few weeks later.

Singh uses the story to show two things. The first is the strategic value of codebreaking: a single deciphered message shifted the balance of a world war. The second is a dilemma that recurs throughout intelligence history. Knowledge gained by breaking a cipher is only useful if it can be acted on, but acting on it risks revealing that the cipher has been broken, which will lead the enemy to change it. Codebreakers must constantly weigh the value of a secret against the value of keeping their success secret.

Other episodes reinforce the point in different keys. A French codebreaker in 1918 broke a new German field cipher during a critical offensive and gave his army advance warning of an attack. The elaborate cipher used by the court of Louis XIV defeated readers for two centuries and, when finally broken in the late nineteenth century, illuminated historical puzzles of its era. And the Beale ciphers, a set of numbered texts published in nineteenth-century America and said to describe the location of buried treasure, show the opposite face of the subject: one of the three was solved using a famous American document as a key, while the others have never been read, and some researchers suspect the whole affair was a hoax. Singh includes the Beale story as a lesson in how an unsolved cipher can draw obsessive effort and how difficult it is to know whether a text contains any message at all.

The common thread is that ciphers are not abstract. They are used by real people under pressure, and their failure or success has consequences in courts, battles and diplomacy. Singh's narrative never lets the reader forget this, and that is one reason the book holds attention. It is also a reason to take the subject seriously today, when the protection of financial assets and private communication rests on the same kind of contest.

Idea six: machines change the scale of the contest

The twentieth century brought cipher machines, and with them a change in the scale of the contest. The most famous is the German Enigma, an electromechanical device invented after the First World War and adopted in various forms by the German armed forces. Its rotors scrambled each letter differently from the last, and with its plugboard the number of possible settings was astronomically large. To its users it seemed beyond the reach of any codebreaker.

Singh tells the story of its breaking in two stages. The first belongs to Poland. In the 1930s, Polish mathematicians at the Cipher Bureau in Warsaw, led in this work by Marian Rejewski, attacked Enigma using mathematics rather than linguistic intuition. Helped by documents obtained by French intelligence from a German informant, Rejewski reconstructed the machine's wiring and found ways to recover its daily settings from patterns in the way messages were set up. The Poles built machines to speed the search. When German procedures changed and the work became too large for them, they shared their results with British and French intelligence shortly before the war began.

The second stage belongs to Bletchley Park in England. There a large organisation of mathematicians, linguists and support staff, including Alan Turing and Gordon Welchman, built on the Polish work. Turing designed a machine, the bombe, that could search for Enigma settings using a guessed fragment of plaintext, known as a crib. The work depended on mathematics, engineering, organisation and also on the captured material and procedural mistakes that gave the codebreakers their footholds. Singh explains these elements with care.

The story makes several points. First, machines did not end the contest; they raised its scale. A machine cipher is still a fixed method, and a sufficiently organised effort, with machines of its own, can attack it systematically. Second, the breaking of a strong machine cipher was not the work of a lone genius but of a team, built over years, that combined many kinds of skill. Third, the work showed that mathematics, not just language, could break ciphers, a shift that prepared the way for the computer age.

An analogy is a lock with a very large number of possible keys. Trying them one at a time by hand is hopeless. But if one can build a machine that tests many keys quickly, and if one can use clues to rule out most keys without testing them, the task becomes feasible. Enigma's breakers did both.

Singh also tells the contrasting story of the Navajo code talkers, who served with the United States Marines in the Pacific during the Second World War. Their method used a natural language that was almost unknown outside its own community, with an added layer of code words for military terms. It was fast, worked by speech, and was never broken. The story is a reminder that the strongest protection is not always the most technical, and that secrecy can rest on knowledge rather than on machinery.

The broader significance of the Enigma story is that it brought codebreaking into the history of computing. The machines built at Bletchley Park to attack German ciphers were among the precursors of electronic computers. From this point on, the contest between makers and breakers would be fought largely with computation.

Idea seven: people are the weakest link

A recurring theme in Singh's account is that ciphers are usually broken not because the mathematics fails, but because people use them badly. Again and again, the codebreakers' footholds come from human habits: predictable message openings, reused keys, lazy choice of settings, standard formats, and the tendency to repeat the same words in the same places.

The breaking of Enigma is the clearest example. The machine itself was strong. But operators sometimes chose easily guessed settings, sent routine messages with predictable content such as weather reports, repeated parts of their setup in ways that leaked information, and resent messages in a weaker cipher that had already been broken. Each of these habits gave the codebreakers a starting point. Without them, the task would have been far harder.

The same pattern appears in earlier periods. Cipher clerks reused keys because generating new ones was tedious. Diplomats sent the same message in two systems, one weak and one strong, letting the weak one unlock the strong. Writers used common words as keys, making them guessable. Singh's stories show that procedure and discipline matter as much as design.

The analogy is a high-quality safe whose combination is written on a note inside the desk drawer. No skill is needed to open it; only knowledge of human behaviour. Codebreakers throughout history have been, among other things, students of human habit.

This idea is often confused with the claim that technology does not matter. It does matter: a weak cipher used carefully is still weak. The point is that strength in design must be matched by care in use. Modern security practice reflects this in its attention to key management, randomness, user interfaces and operational procedures, and in the observation that most real breaches involve human error somewhere along the way.

There is a further lesson in how the codebreakers organised themselves to exploit human habits. At Bletchley Park, staff kept careful records of the routines of particular operators and stations: who tended to begin messages in the same way, which units sent reports at fixed times, which settings had been used before. This patient accumulation of small regularities was as important as any machine. It is the same work that modern security analysts do when they study how attackers or users behave, and it shows that attention to ordinary detail is one of the most powerful tools in the subject. A reader who takes nothing else from the book should take this: systems are run by people, and people leave patterns.

For readers of this bay, the lesson is direct. The cryptography behind digital money is strong, but losses happen constantly through stolen keys, careless storage, fraudulent interfaces and simple mistakes. The history in The Code Book is a long demonstration of why that is to be expected.

Idea eight: lost scripts are codes set by time

Singh devotes a section of the book to the decipherment of ancient scripts, and it is one of the most enjoyable parts. He argues that reading a forgotten writing system is a close relative of codebreaking. The writers did not mean to hide anything, but because the knowledge of their language and script was lost, their texts became as unreadable as any cipher.

The first story is the reading of Egyptian hieroglyphs. For centuries scholars believed hieroglyphs were purely symbolic, each sign representing an idea. The discovery of the Rosetta Stone, which carried the same decree in hieroglyphs, a later Egyptian script and Greek, offered a foothold. The English scholar Thomas Young made important early progress, and the French scholar Jean-Francois Champollion completed the breakthrough in the 1820s, showing that hieroglyphs combined sound signs and meaning signs, and using his knowledge of Coptic, a late descendant of the Egyptian language. Names of rulers, written inside oval frames, served as cribs.

The second story is the decipherment of Linear B, a script found on clay tablets at Bronze Age sites in Crete and mainland Greece. Here there was no bilingual text. The American scholar Alice Kober showed by careful analysis that the language was inflected, with word endings that changed according to grammar, and organised the signs according to those patterns. The English architect Michael Ventris built on this, constructed a grid of signs by their likely sound values, and in the early 1950s found to general surprise that the language was an early form of Greek. He worked with the scholar John Chadwick to confirm and publish the result.

Singh draws out the common logic. In both cases the decipherers used patterns and frequencies, looked for names and other likely words that could act as cribs, made guesses, and tested them against more text. In both cases the decisive step depended on knowing, or correctly guessing, the underlying language. And in both cases there was a moment when a hypothesis suddenly made many unrelated pieces fall into place, which is the sign of a correct solution in codebreaking too.

An analogy is a jigsaw puzzle without the picture on the box. One starts with the edges and the distinctive pieces, groups pieces by colour and shape, and tests guesses about what the picture might be. Once a correct guess about the picture is made, the remaining pieces go in quickly.

This section is sometimes seen as a digression, and it is true that it is not about secret writing in the strict sense. But it widens the reader's understanding of what codebreaking is: a disciplined way of reasoning from patterns to meaning. That way of reasoning applies to many problems beyond cryptography, from linguistics to data analysis.

Idea nine: public keys solve the oldest problem

The climax of the book is the invention of public-key cryptography. Singh tells it as the resolution of the key distribution problem that has run through every earlier chapter. Until the 1970s it seemed obvious that two people could not communicate secretly without first sharing a secret. Public-key methods showed that this obvious belief was false.

The idea came in stages. In the mid-1970s Whitfield Diffie and Martin Hellman, at Stanford, with Ralph Merkle working on related ideas, showed how two people could agree on a shared secret key by exchanging messages in public, in such a way that an eavesdropper who saw everything could not work out the key. The method relied on a mathematical operation that is easy to perform in one direction and very hard to reverse. Shortly after, Ronald Rivest, Adi Shamir and Leonard Adleman at MIT devised a system, named RSA from their initials, in which each person has two keys: a public key that anyone can use to encrypt a message, and a private key, kept secret, that alone can decrypt it. RSA's security rests on the difficulty of factoring the product of two very large prime numbers.

Singh explains these ideas with analogies that make them accessible. A well-known one, which he uses in a form of his own, involves padlocks. If Alice wants to send Bob a box safely, she can put her padlock on it and send it. Bob adds his own padlock and sends it back. Alice removes her padlock and sends it again. Bob removes his and opens the box. At no point did they share a key, and at no point was the box unlocked in transit. The analogy is imperfect as a description of the actual mathematics, and Singh is careful about this, but it shows that the impossible-seeming is not impossible.

A simpler analogy for RSA is an open padlock that anyone can snap shut, while only the owner holds the key that opens it. Bob hands out open padlocks freely. Anyone can lock a message in a box with one of them and send it to Bob. Only Bob can open it. The padlock is the public key; the key that opens it is the private key.

Singh then tells a twist that gave the book much of its early fame. In the late 1990s it was revealed that researchers at GCHQ, the British signals intelligence agency, had discovered the essential ideas of public-key cryptography several years before the published American work. James Ellis had conceived the possibility, Clifford Cocks had found a method equivalent to RSA, and Malcolm Williamson had found a method equivalent to Diffie-Hellman key exchange. Their work was classified and could not be published. Singh was among the first popular writers to tell this story in full, and he treats it with sympathy for researchers who could not receive public credit.

The idea of public-key cryptography is often confused with the idea of encryption in general. Its real novelty is not that it hides messages, which older methods also did, but that it removes the need for a prior shared secret. It also makes possible digital signatures, in which a private key is used to sign and a public key to verify, so that anyone can check who wrote a message. Singh explains this application more briefly, but it is the one most directly relevant to digital money, where the right to spend is proved by a signature.

This idea leads to the modern world. Secure web connections, encrypted messaging, signed software updates and digital currencies all rest on public-key methods. Singh's narrative makes clear that these did not appear from nowhere. They are the answer to a problem that troubled every generation of codemakers before them.

Idea ten: encryption becomes a political question

Once strong encryption became available to anyone with a computer, it became a political question. Singh devotes part of the later book to this struggle, focusing on the American programmer Phil Zimmermann and the program he released in the early 1990s, Pretty Good Privacy, known as PGP. It put strong public-key encryption into the hands of ordinary people, free of charge.

The United States government at the time treated strong encryption software as a military technology subject to export controls. When PGP spread internationally over the internet, Zimmermann became the subject of a criminal investigation that lasted several years before it was dropped without charges. Singh presents the episode as a case study in a wider conflict between two legitimate concerns: the privacy of individuals and businesses, and the ability of law enforcement and intelligence agencies to intercept communications of criminals and hostile powers.

Singh sets out both sides. Advocates of strong encryption argued that privacy is a basic right, that commerce needs secure communication, and that criminals would obtain encryption anyway, so restrictions would mainly harm the law-abiding. Law enforcement argued that encryption would let terrorists and criminals communicate beyond the reach of lawful warrants. Proposals at the time included systems in which keys would be held in escrow by authorities, to be released under court order. Critics argued that such systems would be insecure and open to abuse.

The analogy that often framed this debate was the telephone wiretap. For decades, a court order allowed police to listen to a suspect's calls. Strong encryption threatened to make such orders useless, since the intercepted signal would be unreadable. The question was whether society should accept that loss, or require that encryption be designed with a way in.

Singh's treatment is balanced, though his sympathies lean toward privacy and toward the inevitability of strong encryption. Since the book appeared, the debate has continued in new forms, over encrypted messaging, device encryption and digital money. Export controls were substantially relaxed around the turn of the century, and strong encryption is now built into everyday products. But governments continue to seek access, and the basic tension Singh described remains unresolved.

The idea is often confused with a simple contest of good and bad. Singh's account shows that both sides had serious concerns. Readers who come to the subject through the digital money books in this bay, which often treat any government interest in encryption as illegitimate, will find his account a useful corrective, and readers who think privacy is a minor concern will find it equally useful.

Idea eleven: physics may end the contest

The book ends with quantum cryptography, which Singh presents as a possible end point of the long contest. All earlier methods, including public-key cryptography, rely on the practical difficulty of some task. Quantum cryptography, in the form he describes, relies instead on the laws of physics.

The essential idea is that information can be carried by single particles of light, photons, prepared in particular quantum states. A basic principle of quantum mechanics is that measuring such a particle can disturb it, and that an unknown quantum state cannot be copied perfectly. If two people exchange key material using such particles, an eavesdropper who tries to intercept and measure them will inevitably introduce errors. The two people can check a sample of their data for errors. If there are too many, they know someone was listening and discard the key. If not, they can use it with confidence, for example as a one-time pad.

Singh tells the story of the idea's origins, beginning with an early proposal by Stephen Wiesner that went unpublished for years, and continuing with the work of Charles Bennett and Gilles Brassard, who developed a practical protocol for quantum key distribution in the 1980s and built an early demonstration. He also explains why quantum computing threatens public-key cryptography: a large enough quantum computer could factor large numbers efficiently, which would break RSA. Quantum physics thus appears in the book both as a threat and as a remedy.

An analogy is a letter sealed with a wax that changes colour if anyone so much as looks at it. The letter can still be intercepted, but the recipient will know. Quantum key distribution does not prevent eavesdropping; it makes eavesdropping detectable.

This idea is often confused with a claim that quantum methods make all communication secure. They do not. They secure the distribution of keys over a particular kind of link, under particular assumptions, and real devices have proved vulnerable to attacks on their hardware rather than their physics. The practical deployment of quantum key distribution remains limited. Meanwhile, the main response to the quantum threat has been the development of new public-key methods based on mathematical problems believed to resist quantum computers, a field that has grown greatly since the book appeared.

Singh's ending is optimistic. He suggests that the codemakers may have won the long contest for good. A cautious reader will note that the history he tells is full of methods once thought final. The ending is best read as a statement about where the field stood at the end of the twentieth century, with the reminder from the rest of the book that confidence is the codemaker's oldest enemy.

The tradition around it

The Code Book belongs to a tradition of popular histories of cryptography, and it is best understood alongside the great work that preceded it, David Kahn's The Codebreakers, which is also in this bay. Kahn's book, first published in the 1960s, is a vast and detailed history of secret writing from antiquity to the Cold War. It remains the standard reference. Singh's book is much shorter, more selective and more explanatory. Where Kahn documents, Singh teaches. Many readers start with Singh and then turn to Kahn for depth.

Singh also benefited from historical revelations that came after Kahn's first edition. The full story of Bletchley Park and the breaking of Enigma was kept secret until the 1970s, and the GCHQ work on public-key cryptography was revealed only in the late 1990s. The Code Book was among the first popular books to place these episodes together in a single narrative.

For the modern era, Steven Levy's Crypto, in this bay, tells the story of the invention of public-key cryptography and the political battles over encryption in much greater detail, from the point of view of the American researchers and activists. Andy Greenberg's This Machine Kills Secrets follows the line from cypherpunk ideas to anonymous leaking. Both extend the later parts of The Code Book.

For readers who want the mathematics, Neal Koblitz's A Course in Number Theory and Cryptography explains the number theory behind public-key methods, and Katz and Lindell's Introduction to Modern Cryptography gives the formal modern treatment. The Handbook of Applied Cryptography provides precise definitions and algorithms, and Schneier's Applied Cryptography and Aumasson's Serious Cryptography offer practical surveys. Each of these assumes more from the reader than Singh does, and each is easier to approach after him.

The digital money books in the bay rest on the ideas Singh explains at the end of his book. Antonopoulos's Mastering Bitcoin, Narayanan and colleagues' Bitcoin and Cryptocurrency Technologies, and Popper's Digital Gold all assume that readers understand public keys, private keys and signatures. The Code Book is a gentle way to gain that understanding and to see where it came from. The Sovereign Individual, also in the bay, draws political conclusions from the availability of strong encryption; Singh's account of the encryption debate provides the history behind those conclusions.

Questions and criticisms

The first criticism concerns selection. To keep the story moving, Singh focuses on episodes with strong narratives and clear lessons. Much of the history of cryptography, including the work of many countries outside Europe and North America, and long stretches of routine diplomatic and commercial practice, is passed over or mentioned briefly. Readers who want a fuller picture should turn to Kahn and to specialist histories.

The second concerns the heroic narrative. The book's structure, with each chapter built around key figures and decisive breakthroughs, can give the impression that progress came mainly from individual genius. Singh does acknowledge teams and institutions, especially at Bletchley Park, but the storytelling form tends to elevate a few names. Historians of intelligence emphasise organisation, logistics and the slow accumulation of small gains.

The third concerns date. The book ends in the late 1990s. Since then, the field has changed substantially. The Advanced Encryption Standard was selected through an open competition. Weaknesses were found in widely used hash functions. Elliptic curve cryptography became common. End-to-end encrypted messaging spread to billions of users. Digital currencies appeared. Revelations about large-scale government surveillance changed the public debate. And the threat from quantum computers led to the standardisation of new post-quantum methods. None of this is in the book, and readers should be aware that its final chapters describe a moment rather than the present.

The fourth concerns the optimism of the ending. Singh suggests that the codemakers may have gained a decisive advantage. In mathematical terms this may be true, but the history of the following decades shows that the practical contest moved elsewhere: to implementation flaws, to the theft of keys, to attacks on devices, to legal pressure on service providers, and to the deception of users. The weakest link, as the book itself shows in earlier chapters, is often not the cipher.

Some specialists have noted minor simplifications in the technical explanations, especially of Enigma and of quantum cryptography. These are mostly the deliberate simplifications of a popular book and do not mislead on essential points. A reader who goes on to more technical works will find nothing in Singh that must be unlearned, only much that must be filled in.

What has held up is the book's central achievement: a clear, accurate and engaging account of how ciphers work and how they have been broken, from the beginning through the invention of public-key cryptography. Its explanations of frequency analysis, polyalphabetic ciphers, the one-time pad, Enigma and the key distribution problem remain among the best available to a general reader.

Why it is on this shelf

This shelf collects books that show how systems of thought and practice developed over time: Vedanta's long reflection on the self, Jyotish's traditions of reckoning time and pattern, the sciences' slow building of reliable knowledge, economics' account of exchange, and technology's record of what people have built. The Code Book is here because it tells, more clearly than any other single volume, the history of one practical science from its earliest form to its present foundations.

In the cryptography and blockchain bay, it is the natural first book. It introduces the vocabulary that every other book in the bay assumes, and it does so through stories that make the vocabulary memorable. A reader who has worked through its explanations of keys, ciphers and public-key methods will find the technical and economic books in the bay far easier to follow.

It also teaches a temperament we value across the shelf: respect for patterns, patience with puzzles, suspicion of easy confidence, and pleasure in understanding how something actually works. The codebreaker's habit of looking for the regularity others missed is useful in reading any text, ancient or modern.

Finally, it reminds readers of digital money that the tools they rely on are the outcome of a long human contest, with real costs and consequences. Private keys and signatures are not magic. They are the latest moves in a game that has been played for millennia, and that game is not over.

How to read it

Read the book in order. Its parts build on each other, and the story of the key distribution problem in particular only gains its full force if the earlier chapters have been read. A comfortable pace is one part every few days. The narrative is easy, but the technical sections deserve slow reading.

Keep paper and pencil beside you. When Singh explains a cipher, encipher a short message of your own with it. When he explains how a cipher was broken, try the method on your own ciphertext, or ask a friend to make one for you. Frequency analysis of a simple substitution cipher takes an hour or so and teaches more than any description. A polyalphabetic cipher with a short keyword is a good second exercise. For public-key cryptography, work through a tiny example of the RSA idea with small primes, using a calculator; the numbers will be small enough to check by hand.

On a first reading, it is reasonable to move more quickly through the sections on ancient scripts if your interest is mainly in modern cryptography, and to return to them later. Do not skip the chapters on Enigma and on public-key cryptography; they are the core of the book. The section on quantum cryptography can be read lightly the first time and revisited after the rest.

Readers who want a challenge can attempt the cipher challenge at the end of the book. The prize has long been claimed, but the early stages are well within reach of a careful reader, and they test understanding of the methods the book describes. Solutions and discussions exist, but trying first is the point.

After The Code Book, read Levy's Crypto for a fuller account of the modern era and the encryption debate. Then turn to Kahn's The Codebreakers for depth on any period that caught your interest. For the mathematics, Koblitz's A Course in Number Theory and Cryptography is the next step. For digital money, Narayanan and colleagues' Bitcoin and Cryptocurrency Technologies shows how public-key methods and hash functions combine to create a currency, and Antonopoulos's Mastering Bitcoin shows how keys and signatures are used in practice.

Questions to carry

  • Why did frequency analysis defeat simple substitution ciphers, and what does that say about the hidden regularities of language?
  • Why is a weak cipher more dangerous than no cipher at all?
  • What is the key distribution problem, and why did it persist for so long?
  • Why should the security of a cipher depend only on the key and not on the secrecy of the method?
  • What makes the one-time pad unbreakable, and what makes it impractical?
  • How much of the breaking of Enigma depended on mathematics, how much on machines, and how much on human mistakes?
  • In what sense is deciphering a lost script like breaking a code, and in what sense is it different?
  • How does public-key cryptography remove the need for a shared secret?
  • Why did the GCHQ researchers receive no public credit for so long, and what does that say about secret science?
  • How should a society balance the privacy that encryption gives against the needs of law enforcement?
  • What does quantum key distribution guarantee, and what does it leave unprotected?
  • Where has the contest between makers and breakers moved since the book was written?
  • Which of your own everyday security habits would a historical codebreaker exploit?

Words to know

  • Cipher: a method of transforming a message so that it cannot be read without a key, usually working on individual letters or symbols.
  • Code: a system that replaces whole words or phrases with other words, numbers or symbols, usually listed in a codebook.
  • Plaintext: the original, readable message before encryption.
  • Ciphertext: the message after encryption.
  • Key: the secret information that controls how a particular message is enciphered and deciphered.
  • Substitution cipher: a cipher that replaces each letter with another letter or symbol according to a fixed rule.
  • Frequency analysis: breaking a cipher by comparing how often symbols occur with how often letters occur in the language.
  • Polyalphabetic cipher: a cipher that uses several substitution alphabets in turn, so the same letter can be enciphered in different ways.
  • Vigenere cipher: a well-known polyalphabetic cipher that uses a keyword to choose the alphabet for each letter.
  • One-time pad: a cipher using a truly random key as long as the message, used once only; provably unbreakable if used correctly.
  • Kerckhoffs's principle: the rule that a cipher should remain secure even if everything about it except the key is known.
  • Enigma: the German rotor cipher machine used in the Second World War.
  • Rotor: a wired wheel in a cipher machine that changes the substitution as it turns.
  • Bombe: an electromechanical machine built to search for Enigma settings.
  • Crib: a guessed piece of plaintext used to help break a ciphertext.
  • Book cipher: a cipher in which numbers refer to words or letters in an agreed text.
  • Decipherment: the reading of a forgotten script or language, by analogy with breaking a cipher.
  • Key distribution problem: the difficulty of getting a secret key safely to the people who need it.
  • Public-key cryptography: a system in which each user has a public key for encryption or verification and a private key for decryption or signing.
  • RSA: a public-key system whose security rests on the difficulty of factoring the product of two large primes.
  • Diffie-Hellman key exchange: a method for two parties to agree on a secret key over a public channel.
  • Digital signature: a value created with a private key that anyone can check with the matching public key.
  • Key escrow: an arrangement in which copies of encryption keys are held by a third party, such as a government agency.
  • Quantum key distribution: a method of sharing a secret key using quantum states, so that eavesdropping can be detected.

A note on this edition

This is a study edition written for this shelf in our own words. It describes the themes and methods of The Code Book and comments on them, but it does not reproduce Simon Singh's text, examples or challenge ciphers. The book itself is in copyright and is well worth getting from a library or bookshop; its worked explanations are best met in the original, with a pencil in hand.

Terms from this book with their own page: Public-key cryptography, Digital signature

More from “Cryptography, blockchain and crypto”

The whole section →