Archive for codes

Playfair Again

Posted in Crosswords with tags , , , , on November 8, 2022 by telescoper

It’s been a while since I’ve blogged about my passion for crosswords, but this Sunday’s Azed puzzle in the Observer was in one of my favourite forms so I thought I’d mention it briefly here.

Azed is the pseudonym used by Jonathan Crowther who has been setting the Observer crossword since 1972; this week’s was number 1967. His  puzzles are usually standard cryptic crosswords which, though quite difficult as such things go, are nevertheless set in a fairly straightforward style. Every now and again, however,  he puts together a different type of puzzle that makes a different set of demands on the solver.  To be honest, I don’t always like these “funny” ones, as they sometimes seem to me to be contrived and inelegant, but this last one was a type I really like as it combines the normal cryptic crossword style with another interest of mine, namely codes and codebreaking.

The interesting aspect of this particular puzzle, which is laid out on a normal crossword grid, is that it involves a type of code called a Playfair cipher. In fact, this particular scheme was invented by the scientist Charles Wheatstone whom most physicists will have heard of through “Wheatstone Bridge“. It was, however, subsequently popularized by Lord Playfair, whose name stuck rather than its real inventor’s. Stigler’s Law of Eponymy strikes again!

The Playfair scheme is built around the choice of a code word, which must have the special property that no letter occurs twice within it.  Other than that, and the fact that the more letters in the codeword the better the code, there aren’t any real constraints on the choice. The particular example used by Azed to illustrate how it works is ORANGESTICK.

The codeword is used to construct a Playfair square which is a 5×5 arrangement of letters involving the codeword first and then afterwards the rest of the alphabet not used in the codeword,  in alphabetical order. Obviously, there are 26 letters altogether and the square only holds 25 characters,  so we need to ditch one: the usual choice is to make I stand for both I and J, doing double duty, which rarely causes ambiguity in the deciphering process. The Playfair square formed from ORANGESTICK is thus

This square is then used as the basis of a literal digraph substitution cipher, as follows. To encode a word it must first be split into pairs of letters e.g. CR IT IC AL. Each pair is then seen as forming the diagonally opposite corners of a rectangle within the word square, the other two corner letters being the encoded form. Thus, in the example shown, CR gives SG (not GS, which RC would give).

Where a pair of letters appears in the same row or column in the word square, its encoded form is produced from the letters immediately to the right of or below each respectively. For the last letters in a row or column the first letters in the same row or column become the encoded forms. Thus IC is encoded as CE. When all the pairs are encoded, the word is joined up again, thus CRITICAL is encoded as SGCICEOP.

Obviously, to decipher encrypted text into plain one simply inverts the process as it is completely reversible.

The advantage of this over simpler methods of encipherment is that a given letter in the plain text is not always rendered as the same letter in the encrypted form: that depends on what other letter is next to it in the digraph. That means it isn’t cracked so easily using letter frequencies, as simple subsitution ciphers are.

Now, what does this have to do with a crossword? Well, in a Playfair puzzle like the one I’m talking about a certain number of answers – in the case of the latest Azed puzzle, eight – have to be encrypted before they will fit in the diagram. These “special” clues, however, are to the unencrypted form of the answer words. The codeword is not given, but must be deduced.

What one has to do, therefore, is to solve the clues for the unencrypted words, then solve all the other clues that intersect with them on the grid. Given a sufficient number of digraphs in both plain text and encrypted form one can infer the codeword and hence encrypt the remaining (unchecked) letters for the special answers.

It probably sounds very convoluted, but in this puzzle it isn’t so bad because the “special” clues are relatively straightforward which generates enough “cribs” in the form of letter-pairs in both plain and encrypted form. There aren’t enough pairs to deduce the codeword exactly – as not every letter in the codeword appears among the digraphs – but it helps knowing that it is an actual word rather than a jumble of letters. That, together with the rules for encryption using the  Playfair square, gives enough information to infer the codeword; the digraph PA which encrypts to AE is particularly useful in this case. In this case the codeword has 14 letters. I won’t tell you what it is because the competition is not yet closed!

What has to be done then is to use the codeword to complete the unchecked letters in the specials in their encrypted form. That bit is relatively straightforward but for the competition one also has to supply a “normal” cryptic clue for 9 down. That’s always the bit I find hardest!

 

 

The Queen’s Agent

Posted in History, Literature with tags , , , , , on February 9, 2014 by telescoper

francis-walsinghamI’ve just finished reading The Queen’s Agent: Francis Walsingham at the Court of Elizabeth I by John Cooper and thought I’d post a quick review before settling down to an afternoon of work in the office. Sir Francis Walsingham (left) has acquired an almost mythical status as chief “spymaster” for the Crown during a time when Queen Elizabeth I was beset on all sides by plots and intrigues; The Queen’s Agent tries to find the man behind the legend. Not surprisingly, as Walsingham was as secretive as his trade might suggest, it doesn’t always succeed, but it does at least explode a few myths and give some insights into the character of a very complex man who was capable of great compassion as well as terrible ruthlessness.

Apart from anything else this book allowed me to indulge a longstanding interest in codes and ciphers; specifically, there are many interesting parallels between the story of the Spanish Armada and the breaking of the Enigma code at Bletchley Park during World War II, of which more shortly.

My first encounter with Sir Francis Walsingham came during history lessons at School, especially concerning his role in the infamous Babington Plot of 1586, which resulted in the execution for treason of Mary Stuart (Mary Queen of Scots). Mary had been officially under arrest for 18 years, and had been moved around the country for much of that time with her retinue lest she become a focus for a Catholic plot to put her on the throne of England. In fact for much of her time in captivity, Mary had been communicating in secret with various individuals for precisely that purpose but, unknown to her, most of her letters were being read by Walsingham and his expert team of code-breakers, including  Thomas Phelippes. By 1586 Walsingham already had more than enough evidence to have Mary Stuart tried for treason, but he hit on a plan that if it worked would lead to the entrapment of a large number of her supporters as well as ensuring that he knew the full extent of the conspiracy surrounding Mary Stuart. And so the Babington plot was hatched.

In late 1585, Mary Stuart was moved to Chartley Hall in Staffordshire. A young man called Gilbert Gifford with impeccable Catholic credentials, and apparently sympathetic to the Stuart cause, starting working for the household.  Gifford was in fact a double agent, placed there by Walsingham. Mary was shown a new way to communicate with the outside world, by concealing letters in the beer barrels that were brought regularly in and out of the Hall. She was eventually persuaded to try this channel, but was reluctant to take too many risks; her caution led her to commit a terrible error.

The encryption system used by Mary Stuart was widespread in Europe at that time. It was a form of substitution cipher known as a nomenclator. This consisted of a large alphabet with symbols (some made up, some from other languages) standing sometimes for individual letters, and sometimes for the names of individuals or places. Interesting devices were also deployed to try to confound the frequency analysis that was already being used in code-breaking at this time: symbols were included in the alphabet to instruct the recipient to “repeat the next letter”, for example.

In fact the Babington cipher (or at least a copy of it) still exists:

443px-Mary-cipher-code

Incidentally, in the nomenclators in use by Spain during the time of the Spanish Armada the symbol for Sir Francis Drake was “22”. I’m tempted to suggest that this is the origin of the Bingo call “two little ducks, quack quack”!

As is the case with most ciphers of this type, both sender and receiver would have to have a copy of the agreed alphabet and it is in the possibility of intercepting the key that such methods are most vulnerable . Nomenclators are not impossible to break without the key but not easy either; some 16th century codes of this type remain unbroken to this day. Mary did not know that the communication channel that had opened up was compromised at the very outset, so it probably seemed a sensible move for her to use it first to send a new cipher alphabet to Babington. Of course that decision was an enormous stroke of luck for Elizabeth’s agents because it meant that Phelippes and Walsingham could immediately read every single word of her subsequent messages all of which were intercepted and transcribed, before being replaced in the beer barrels and delivered to their recipient. Her fate, and that of a dozen or so co-conspirators, was quickly sealed. A transcript of the crucial item of correspondence, in which Mary discussed openly the strategy for the planned coup, was forwarded to Walsingham after decryption with a macabre addition: a picture of a gallows drawn in Phelippes’ own hand.

Another dimension that emerges from this story relates to just how difficult it must have been to know who was really on what side. Double agents abounded, and Walsingham must have known that some of his own men were actually working for the enemy at least some of the time; he apparently kept them going despite knowing that they had been turned in order to feed them with false information for the purposes of deception. That’s a very dangerous game to play, but they were dangerous times.

A couple of years after the Babington Plot came the Spanish Armada. The English army was so tiny in comparison with the huge force that planned to invade in 1588 that there was no way it could defend the entire coastline of England. Walsingham relied on intelligence in order to come to the conclusion that the invasion (if it came) would be in Essex. The Spanish would have wanted to get to London as quickly as possible, so this was far more likely to be the landing place than Sussex or the Isle of Wight, both of which were touted as possibilities. An English army of 16,500 was therefore assembled at Tilbury. It’s by no means clear how they would have fared against the Spanish, who outnumbered them by more than two-to-one and who were vastly more experienced and better equipped, but at least they would have had a chance. Walsingham must have been vastly relieved when he received news that the Armada had passed Portsmouth without attempting a landing, because had they done so they would not have met with any meaningful opposition.

Of course we all know what actually happened: harried but not seriously disrupted by a much smaller English naval force, the Armada proceeded up the English channel to Gravelines where it was planned to link up with Spanish ground forces encamped in the Netherlands. There they were attacked by Drake’s Fire Ships and fled into the North Sea in panic. The bulk of the Armada foundered on the coasts of Scotland and Ireland trying to find its way back to Spain in terrible weather.

We’re all taught at school that this was a defining period in English history, when our island nation was saved from Spanish tyranny and emerged into an age of unparalleled peace and prosperity. That’s the narrative we like to hear over and over again, perhaps because it provides us with a sense of moral certainty. A truer picture perhaps emerges when you look at it through the eyes of a man like Walsingham. This is history in all its cloak-and-dagger brutality, fascinating but at the same time profoundly unsettling because it reveals that all that ever really happens is that one side is slightly cleverer and more ruthless than the other.

So what was Walsingham really like as  a man? Obviously we’ll never know. But I’m glad I’ll never have him as an enemy…