IT WAS a shocking disclosure that made headlines around the world. An American intelligence professional revealed the existence of a secret American bureau, which obtained, decoded and read the private messages of nearly 20 foreign governments. He disclosed methods of surveillance and subterfuge, describing a clandestine world of pilfered telegrams, forged wax seals and invisible inks. Laws had been broken and the privacy of many intruded upon. Telecommunications companies had co-operated secretly with the government. America’s past and future enemies learned how their encrypted messages had been read. When in 1931 Herbert Yardley spilled the secrets of America’s eavesdropping programme, he may well have endangered national security. But, unlike Edward Snowden, he was no mid-level whistleblower shocked at the excesses of a lawless surveillance state. Yardley was the proud father of that surveillance state, creating the forerunner of the National Security Agency. He published a blockbuster book after the government decided that reading private messages was not in keeping with American values and shut his clandestine operation.

Mr Snowden, with his leaks, tapped into a fundamental libertarian fear that too much knowledge in too few hands could destroy Americans’ freedom. Yardley sold the opposite view: that more secret knowledge could protect them from evildoers. Each claimed to be a patriot defending his country’s values. But whereas Mr Snowden endures exile in Russia, charged with espionage, Yardley lies buried in Arlington National Cemetery, with a place in the NSA’s Hall of Honour. A hard-drinking poker player, born in 1889, in the last days of the old West, Yardley long ago faded into history. But, thanks to him, our metadata will live for ever.

Born to be a spook

American snooping has a history older than the republic. With the help of a code-breaker, George Washington deciphered British messages during the critical siege of Yorktown. At least three times he planted false war plans and military documents on agents in successful bids to deceive the British. Abraham Lincoln was a regular presence in the War Department’s telegraph room, as he sought to keep track of his army and learn of Confederate plans. But information collection was still spotty and primitive.

By Yardley’s lifetime the world was much more interconnected thanks to the telegraph, a technology he was born to master. His father was a railroad telegrapher in Worthington, Indiana, and taught the craft, including Morse code, to his son. A precocious student, Yardley learned poker in the saloons of Worthington, where he probably also developed his lifelong affinity for tall tales. (He said he saw one player bet his farm and then die of a heart attack at the table while clutching the winning hand, four aces.) He learned how to detect a bluff and how to fool others out of a pot. And he learned never to show his cards when he tricked opponents into folding theirs, lest he expose his stratagems.

The young man had a mind for games, numbers and deception. David Kahn, a historian of cryptography and biographer of Yardley, writes that he was a voracious reader, had a talent with words and was considered by one friend “the smartest boy in the county”. Another said: “His mind was on a different level than anyone in town.” But he had no place in Worthington to apply his mind except at the poker table. His destiny changed in 1912 when he aced a civil-service test and moved to Washington to work as a telegraph clerk in the State Department.

Working the night shift in the code room, in what is now the Old Executive Office Building, Yardley felt history pass through his hands in coded messages from America’s embassies. Before America entered the first world war in 1917, it was naive about secure communications. There was no military office devoted to intercepting and decoding enemy messages until Yardley suggested himself for the job. He worried about foreign eavesdropping. “Other countries must have cryptographers. Why did America have no bureau for the reading of secret diplomatic code and cipher telegrams of foreign governments?” He knew then, he wrote, that this would be his life’s mission. “Perhaps I, too, like the foreign cryptographer, could open the secrets of the capitals of the world.”

Yardley set about teaching himself code-breaking. He started solving codes by trial and error, working on whatever codedtelegrams he could get, both foreign and domestic. This included many he should not have been reading. One night in March 1915, listening in on a line between New York and the White House, he copied down a telegram meant for President Woodrow Wilson from his trusted adviser Edward House. It was perhaps the first case of an American cryptographer eavesdropping on the president. Yardley said he solved their code in less than two hours, and was soon reading House’s report of his meeting in Germany with Kaiser Wilhelm II, the emperor, about the prospects for peace.

Edward Snowden tapped into the fear that too much knowledge in too few hands could destroy Americans’ freedom

He was aghast at the “schoolboy” techniques used to encode communications with the president. He burned the evidence, but would later present a detailed report on America’s easy-to-crack diplomatic codes. He eventually persuaded his government of the need, with war at hand, for tougher codes and a cryptography section to match those of the Europeans. “America must know who her friends were and who her enemies,” he later wrote. “How except by reading the secret messages of foreign governments was she to learn the truth?”

Wheels within wheels

Britain, America’s putative best friend in Europe, was already reading the president’s telegrams and much more. So were the other major European powers, to whatever extent they could manage. Britain’s military code-breaking operation, Room 40, helped usher the United States into the war, without American leaders having any idea of its precise role. The unit made copies of every message that went over America’s trans-Atlantic telegraph cable by tapping into all traffic that passed through a relay station at Porthcurno, on the western edge of England, before they travelled across the ocean.

In January 1917 Room 40 intercepted a coded telegram sent by Arthur Zimmermann, the German foreign secretary, promising support for Mexico to take three American states in exchange for allying with Germany against the United States. In a telling indication of how little was thought of America’s intelligence prowess, Germany had trusted that a hostile telegram sent over America’s own communications lines would be secure; it was indeed safe from American eyes but not from Room 40. British officials handed the “Zimmermann telegram” to the American government, inventing a cover story about how they had got it. Its publication caused a national furore, and the United States was finally jolted out of its neutrality and into the Great War.

Yardley knew that code-breakers would be needed for the war. He persuaded the head of military intelligence to admit him to the army to set up MI-8, a new cryptographic bureau. At just 28 years old, writes Mr Kahn, fast-walking, smooth-talking Herbert Yardley—standing all of five foot five (1.65 metres), with a prematurely receding hairline—became the father of American cryptography. But when he started he had no cryptographic staff: deciphering tasks were being sent to a sprawling private estate outside Chicago owned by George Fabyan, a wealthy eccentric. Fabyan had created an amateur decryption staff to look for messages hidden in Shakespeare’s plays that would prove his belief that Francis Bacon was the real author. The brightest among them was a young geneticist named William Friedman, who wrote influential training texts on cryptography and would emerge years later as Yardley’s chief rival.

Yardley quickly developed MI-8 into a fully fledged cryptographic agency. This precursor of the NSA was a primitive, hands-on operation of trial and error. Once a Justice Department agent brought him a dead carrier-pigeon to see if its perforated feathers contained a hidden message (the feathers contained only lice, he concluded). The head of military intelligence gave him a blank sheet of paper that had been found in the heel of a suspect’s shoe, to check for invisible writing. Yardley telephoned around for a chemist in Washington who applied heat until the sheet revealed a message written in Greek.

This all occasioned more thorough searches of suspicious individuals crossing borders, and of thousands of innocuous-looking letters that might contain invisible messages. Much of it led nowhere. Most of the telegrams MI-8 decoded during the war were of no value. There was one notable exception, a 424-letter cryptogram found sewn into the sleeve of a suspected German agent as he attempted to cross the Mexican border with a Russian passport. Yardley’s best cryptographer cracked it, showing it identified the bearer as a “German secret agent”. The man turned out to be Lothar Witzke, who was connected to the sabotage of munitions at a navy shipyard in San Francisco in 1917 and who probably helped engineer a massive, deadly explosion of a munitions depot in New York harbour in July 1916.

With the incriminating cryptogram used as evidence against him, Witzke became the only spy sentenced to death by America during the war, though he was never executed. On the strength of such achievements, and with Yardley urging that American cryptography continue in peacetime, the State Department and the War Department decided jointly to provide $100,000 ($1.4m today) to fund a secret civilian agency. Yardley moved to New York in the summer of 1919 and leased a nondescript office building on East 38th Street near Fifth Avenue. Employees were told to say they worked for the War Department’s “translation section”. Under deep cover, what Yardley came to call the American Black Chamber was born.

Despite his claims that the Black Chamber never had an equal, the level of cryptography remained behind that of the allies. Yardley’s cryptographers never moved much beyond searching for patterns in letters and numbers by eye, and trying to match sequences that appeared frequently with commonly used phrases. They also had less material to work with, as Western Union and other cable companies balked at handing over copies of all the messages that were asked of them. They had complied in wartime and for a while after the war, but soon Yardley had to resort to bribery to get cables he wanted, putting cable-company employees on the payroll. European powers did not have these limitations, Mr Kahn notes: in Britain after 1920 telegraph companies had to hand over telegrams requested with a warrant. It was in America that privacy was valued most, perhaps because it had not been the battleground for a world war.

Yardley’s breakthrough was the cracking of Japanese codesbefore a disarmament conference in Washington in 1921. Japan was the rising power causing most worry in Western capitals. He promised after setting up the Black Chamber in 1919 that he would solve Japanese codes in a year. That he knew no Japanese seems not to have bothered him. He studied its system of transliteration into a Western alphabet, and a deputy studied the language itself. They guessed correctly that distinctive words in the news might be in the diplomatic dispatches. With such trial and error, and intuitive “cipher brains”, they pieced together Japan’s complex code in a matter of months.

At the arms conference the United States and Britain hoped to hold the size of Japan’s navy to six ships for every ten in their respective fleets; Japan wanted seven. American officials were kept abreast of Japan’s thinking by the Black Chamber’s decryption of its communications. A telegram intercepted in November 1921 spelled it out: if pushed, Japanese negotiators should give in to the allies’ preferred ratio, as “it is necessary to avoid any clash with Great Britain and America”. It was a coup for the United States, which got the deal it wanted. Yardley gloated: “Stud poker is not a very difficult game after you see your opponent’s hole card.”

In 1922 Yardley would receive the army’s Distinguished Service Medal, with the real reason being kept a secret. This, though, would prove the high point of his cryptographic career. Friedman, his rival, was helping to prepare America for the age of (temporarily) unbreakable cipher machines, including Enigma, that would later play a vital role in the second world war. In the 1920s, however, it was peacetime, and in the lull Yardley became distracted with other pursuits, according to his biographer, trying to make money with schemes such as buying and selling property in New Jersey.

It was his own government that suddenly put an end to the eavesdropping programme. In 1929 the new secretary of state, Henry Stimson, upon learning of the Black Chamber’s existence, deemed it unethical and un-American. “Gentlemen do not read each other’s mail,” he is supposed to have said, as he put Yardley and his team out of work. It came as a rude shock. America’s first professional cryptographer felt abandoned and disillusioned.

They read each other’s books, though

The Black Chamber was shut down on the eve of the Great Depression. Now Yardley needed money all the more. He had a wife and son and his property speculations were not paying off. In 1930 he approached George Bye, a literary agent in New York, and, with no prior writing experience, rather quickly delivered a manuscript of a book, which would be called “The American Black Chamber”. He hoped it would convince the government and the public of the importance of his work.

The publisher consulted a lawyer, and Yardley changed a few names and removed a few details, including that he had broken federal laws. The book was a blockbuster nonetheless. It sold 18,000 copies in America and at least 40,000 more around the world, by his biographer’s count, earning Yardley some $10,000 in royalties ($156,000 in today’s money). Pirated copies were also sold in China, as Yardley would later find for himself.

He embellished wildly. “Spies were hiding behind every bush,” he wrote at one point. At another: “The Black Chamber, bolted, hidden, guarded, sees all, hears all.” (His flair for drama would serve him well in future, when he wrote spy novels and screenplays, invariably featuring a thinly veiled version of himself as “a man to be reckoned with”, a beautiful damsel ending up in his arms.) The book sold best in Japan, where the public was outraged, mostly at America but partly at its own government for having been outsmarted. Norway was moved by it to get into cryptography. Made aware of the power of government eavesdropping, societies were starting to grapple with its moral ambiguity.

In America Yardley became a celebrity. He toured the country for speaking engagements. William Powell, a Hollywood star, played a character based on him in a film called “Rendezvous”. One writer called him “a living Sherlock Holmes”. Many in government, including Friedman, were less impressed. They wanted his head. The New York Evening Post wrote: “We wish Theodore Roosevelt were alive to read to the author of this book a lecture on betraying the secrets of one’s country.” But he was never charged with a crime, as it was not clear he had broken any law (a new one was soon passed).

Yardley was free to work for the highest bidder, and foreign governments were willing to pay. In 1938 he went to Chongqing, China, on a salary of $10,000 a year, to form a “Chinese Black Chamber”. Chiang Kai-shek’s Nationalists, at war with Japan’s occupying forces, wanted the famous breaker of Japanese codes. Yardley would later claim that he exposed a plot to kidnap Chiang, unmasking a Nazi spy not by decrypting cables but by playing poker with him.

It was poker, oddly enough, that would ultimately provide Yardley with lasting fame, respect and financial reward. In 1957 his final book, a memoir called “The Education of a Poker Player”, became an instant success and was eventually considered a classic, remaining in print long after his death in 1958. He had turned to it at the end of a frustrating late chapter of his life. After returning from China in 1940 he was hired to help set up Canada’s wartime code-breaking operation, a job he clearly loved and which earned enthusiastic reviews from his Canadian staff. But British and American officials insisted they would not work with him; he was let go, never trusted to do intelligence work again.

There may have been more reason for distrust than was apparent at the time. After Yardley’s death it emerged in Japanese official documents that he may have sold his cryptographic secrets to Japan. A review by the NSA concluded that he probably did so in 1930, when he was out of work, a year before he published his book. What damage had he done, by writing the book or selling his secrets? Friedman maintained that Yardley had done serious harm to national security. Japan upgraded its encryption systems.

But as the NSA notes in an official biography of Yardley, American cryptographers still managed to crack “the best systems the Japanese could devise”, even if time might have been lost. Yardley, for his part, had always insisted it was the government that, by shutting the Black Chamber, had endangered national security. He hoped his revelations would push America to invest in cryptography and surveillance. Frank Rowlett, who would help break Japan’s advanced “Red” and “Purple” ciphers, told the NSA that Yardley’s indiscretions had proved to be a great boost to American cryptanalysis —fulfilling, in a way, Yardley’s wishes.

The NSA was born in 1952, under Harry Truman. America during the cold war was no longer the naif of before. The “puzzle palace” became the world’s most advanced cryptographic bureau. After the attacks on September 11th 2001, its powers only expanded. Eavesdropping went far beyond anything Yardley could have dreamed possible. Then, along came Mr Snowden.