Crypto

Cryptography is a funny business; shady from the beginning, the whole business of codes and ciphers has been specifically designed to hide your intentions and move in the shadows, unnoticed. However, the art of cryptography has been changed almost beyond recognition in the last hundred years thanks to the invention of the computer, and what was once an art limited by the imagination of the nerd responsible has now turned into a question of sheer computing might. But, as always, the best way to start with this story is at the beginning…

There are two different methods of applying cryptography to a message; with a code or with a cipher. A code is a system involving replacing words with other words (‘Unleash a fox’ might mean ‘Send more ammunition’, for example), whilst a cipher involves changing individual letters and their ordering. Use of codes can generally only be limited to a few words that can be easily memorised, and/or requires endless cross-referencing with a book of known ‘translations’, as well as being relatively insecure when it comes to highly secretive information. Therefore, most modern encoding (yes, that word is still used; ‘enciphering’ sounds stupid) takes the form of employing ciphers, and has done for hundreds of years; they rely solely on the application of a simple rule, require far smaller reference manuals, and are more secure.

Early attempts at ciphers were charmingly simple; the ‘Caesar cipher’ is a classic example, famously invented and used by Julius Caesar, where each letter is replaced by the one three along from it in the alphabet (so A becomes D, B becomes E and so on). Augustus Caesar, who succeeded Julius, didn’t set much store by cryptography and used a similar system, although with only a one-place transposition (so A to B and such)- despite the fact that knowledge of the Caesar cipher was widespread, and his messages were hopelessly insecure. These ‘substitution ciphers’ suffered from a common problem; the relative frequency with which certain letters appear in the English language (E being the most common, followed by T) is well-known, so by analysing the frequency of occurring letters in a substitution-enciphered message one can work out fairly accurately what letter corresponds to which, and work out the rest from there. This problem can be partly overcome by careful phrasing of messages and using only short ones, but it’s nonetheless a problem.

Another classic method is to use a transposition cipher, which changes the order of letters- the trick lies in having a suitable ‘key’ with which to do the reordering. A classic example is to write the message in a rectangle of a size known to both encoder and recipient, writing in columns but ‘reading it off’ in rows. The recipient can then reverse the process to read the original message. This is a nice method, and it’s very hard to decipher a single message encoded this way, but if the ‘key’ (e.g. the size of the rectangle) is not changed regularly then one’s adversaries can figure it out after a while. The army of ancient Sparta used a kind of transposition cipher based on a tapered wooden rod called a skytale (pronounced skih-tah-ly), around which a strip of paper was wrapped and the message written down it, one on each turn of paper. The recipient then wrapped the paper around a skytale of identical girth and taper (the tapering prevented letters being evenly spaced, making it harder to decipher), and read the message off- again, a nice idea, but the need to make a new set of skytale’s for everyone every time the key needed changing rendered it impractical. Nonetheless, transposition ciphers are a nice idea, and the Union used them to great effect during the American Civil War.

In the last century, cryptography has developed into even more of an advanced science, and most modern ciphers are based on the concept of transposition ciphers- however, to avoid the problem of using letter frequencies to work out the key, modern ciphers use intricate and elaborate systems to change by how much the ‘value’ of the letter changes each time. The German Lorenz cipher machine used during the Second World War (and whose solving I have discussed in a previous post) involved putting the message through three wheels and electronic pickups to produce another letter; but the wheels moved on one click after each letter was typed, totally changing the internal mechanical arrangement. The only way the British cryptographers working against it could find to solve it was through brute force, designing a computer specifically to test every single possible starting position for the wheels against likely messages. This generally took them several hours to work out- but if they had had a computer as powerful as the one I am typing on, then provided it was set up in the correct manner it would have the raw power to ‘solve’ the day’s starting positions within a few minutes. Such is the power of modern computers, and against such opponents must modern cryptographers pit themselves.

One technique used nowadays presents a computer with a number that is simply too big for it to deal with; they are called ‘trapdoor ciphers’. The principle is relatively simple; it is far easier to find that 17 x 19 = 323 than it is to find the prime factors of 323, even with a computer, so if we upscale this business to start dealing with huge numbers a computer will whimper and hide in the corner just looking at them. If we take two prime numbers, each more than 100 digits long (this is, by the way, the source of the oft-quoted story that the CIA will pay $10,000 to anyone who finds a prime number of over 100 digits due to its intelligence value) and multiply them together, we get a vast number with only two prime factors which we shall, for now, call M. Then, we convert our message into number form (so A=01, B=02, I LIKE TRAINS=0912091105201801091419) and the resulting number is then raised to the power of a third (smaller, three digits will do) prime number. This will yield a number somewhat bigger than M, and successive lots of M are then subtracted from it until it reaches a number less than M (this is known as modulo arithmetic, and can be best visualised by example: so 19+16=35, but 19+16 (mod 24)=11, since 35-24=11). This number is then passed to the intended recipient, who can decode it relatively easily (well, so long as they have a correctly programmed computer) if they know the two prime factors of M (this business is actually known as the RSA problem, and for reasons I cannot hope to understand current mathematical thinking suggests that finding the prime factors of M is the easiest way of solving this; however, this has not yet been proven, and the matter is still open for debate). However, even if someone trying to decode the message knows M and has the most powerful computer on earth, it would take him thousands of years to find out what its prime factors are. To many, trapdoor ciphers have made cryptoanalysis (the art of breaking someone else’s codes), a dead art.

Man, there’s a ton of cool crypto stuff I haven’t even mentioned yet… screw it, this is going to be a two-parter. See you with it on Wednesday…

Advertisements

Why do we call a writer a bard, anyway?

In Britain at the moment, there are an awful lot of pessimists. Nothing unusual about this, as it’s hardly atypical human nature and my country has never been noted for its sunny, uplifting outlook on life as a rule anyway. Their pessimism is typically of the sort adopted by people who consider themselves too intelligent (read arrogant) to believe in optimism and nice things anyway, and nowadays tends to focus around Britain’s place in the world. “We have nothing world-class” they tend to say, or “The Olympics are going to be totally rubbish” if they wish to be topical.

However, whilst I could dedicate an entire post to the ramblings of these people, I would probably have to violate my ‘no Views’ clause by the end of it, so will instead focus on one apparent inconsistency in their argument. You see, the kind of people who say this sort of thing also tend to be the kind of people who really, really like the work of William Shakespeare.

There is no denying that the immortal Bard (as he is inexplicably known) is a true giant of literature. He is the only writer of any form to be compulsory reading on the national curriculum and is known of by just about everyone in the world, or at least the English-speaking part. He introduced between 150 and 1500 new words to the English language (depending on who you believe and how stringent you are in your criteria) as well as countless phrases ranging from ‘bug-eyed monster’ (Othello) to ‘a sorry sight’ (Macbeth), wrote nearly 40 plays, innumerable sonnets and poems, and revolutionised theatre of his time. As such he is idolised above all other literary figures, Zeus in the pantheon of the Gods of the written word, even in our modern age. All of which is doubly surprising when you consider how much of what he wrote was… well… crap.

I mean think about it- Romeo and Juliet is about a romance that ends with both lovers committing suicide over someone they’ve only known for three days, whilst Twelfth Night is nothing more than a romcom (in fact the film ‘She’s the Man’ turned it into a modern one), and not a great one at that. Julius Caesar is considered even by fans to be the most boring way to spend a few hours in known human history, the character of Othello is the dopiest human in history and A Midsummer Night’s Dream is about some fairies falling in love with a guy who turns into a donkey. That was considered, by Elizabethans, the very height of comedic expression.

So then, why is he so idolised? The answer is, in fact, remarkably simple: Shakespeare did stuff that was new. During the 16th century theatre hadn’t really evolved from its Greek origins, and as such every play was basically the same. Every tragedy had the exact same formulaic plot line of tragic flaw-catharsis-death, which, whilst a good structure used to great effect by Arthur Miller and the guy who wrote the plot for the first God of War game, does tend to lose interest after 2000 years of ceaseless repetition. Comedies & satyrs had a bit more variety, but were essentially a mixture of stereotypes and pantomime that might have been entertaining had they not been mostly based on tired old stories, philosophy and mythology and been so unfunny that they required a chorus (who were basically a staged audience meant to show how the audience how to react). In any case there was hardly any call for these comedies anyway- they were considered the poorer cousins to the more noble and proper tragedy, amusing sideshows to distract attention from the monotony of the main dish. And then, of course, there were the irreversibly fixed tropes and rules that had to be obeyed- characters were invariably all noble and kingly (in fact it wasn’t until the 1920’s that the idea of a classical tragedy of the common man was entertained at all) and spoke with rigid rhythm, making the whole experience more poetic than imitative of real life. The iambic pentameter was king, the new was non-existent, and there was no concept whatsoever that any of this could change.

Now contrast this with, say, Macbeth. This is (obviously) a tragedy, about a lord who, rather than failing to recognise a tragic flaw in his personality until right at the very end and then holding out for a protracted death scene in which to explain all of it (as in a Greek tragedy), starts off a good and noble man who is sent mental by a trio of witches. Before Shakespeare’s time a playwright could be lynched before he made such insulting suggestions about the noble classes (and it is worth noting that Macbeth wasn’t written until he was firmly established as a playwright), but Shakespeare was one of the first of a more common-born group of playwrights, raised an actor rather than aristocrat. The main characters may be lords & kings it is true (even Shakespeare couldn’t shake off the old tropes entirely, and it would take a long time for that to change), but the driving forces of the plot are all women, three of whom are old hags who speak in an irregular chanting and make up heathen prophecies. Then there is an entire monologue dedicated to an old drunk bloke, speaking just as irregularly, mumbling on about how booze kills a boner, and even the main characters get in on the act, with Macbeth and his lady scrambling structureless phrases as they fairly shit themselves in fear of discovery. Hell, he even managed to slip in an almost comic moment of parody as Macbeth compares his own life to that of a play (which, of course, it is. He pulls a similar trick in As You Like It)

This is just one example- there are countless more. Romeo and Juliet was one of the first examples of romance used as the central driving force of a tragedy, The Tempest was the Elizabethan version of fantasy literature and Henry V deserves a mention for coming up with some of the best inspirational quotes of all time. Unsurprisingly, whilst Shakespeare was able to spark a revolution at home, other countries were rocked by his radicalism- the French especially were sharply divided into two camps, one supporting this theatrical revolution (such as Voltaire) and the other vehemently opposing it. It didn’t do any good- the wheels had been set in motion, and for the next 500 years theatre and literature continued (and continues) to evolve at a previously unprecedented rate. Nowadays, the work of Shakespeare seems to us as much of a relic as the old Greek tragedies must have appeared to him, but as theatre has moved on so too has our expectations of it (such as, for instance, jokes that are actually funny and speech we can understand without a scholar on hand). Shakespeare may not have told the best stories or written the best plays to our ears, but that doesn’t mean he wasn’t the best playwright.