






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







The man pictured above is Alan Turing, the most important figure in the history of computer science. For decades, his fascinating life story was shrouded by government secrecy, societal taboo, and even his own deceptions.
At 24 Turing wrote a paper entitled On Computable Numbers, with an Application to the Entscheidungsproblem. The crux of the paper was an elegant way to model a computer in mathematical terms. This was a breakthrough, because it allowed the tools of mathemat ics to be brought to bear on questions of computation. For example, with his model in hand, Turing immediately proved that there exist problems that no computer can solve— no matter how ingenius the programmer. Turing’s paper is all the more remarkable be cause he wrote it in 1936, a full decade before any computer actually existed.
The word “Entscheidungsproblem” in the title refers to one of the 28 mathematical problems posed by David Hilbert in 1900 as challenges to mathematicians of the 20th century. Turing knocked that one off in the same paper. And perhaps you’ve heard of the “ChurchTuring thesis”? Same paper. So Turing was obviously a brilliant guy who generated lots of amazing ideas. But this lecture is about one of Turing’s lessamazing ideas. It involved codes. It involved number theory. And it was sort of stupid.
Let’s look back to the fall of 1937. Nazi Germany was rearming under Adolf Hitler, world shattering war looked imminent, and— like us— Alan Turing was pondering the useful
ness of number theory. He forsaw that preserving military secrets would be vital in the coming conflict and proposed a way to encrypt communications using number theory. This is an idea that has ricocheted up to our own time. Today, number theory is the basis for numerous publickey cryptosystems, digital signature schemes, cryptographic hash functions, and digital cash systems. Every time you buy a book from Amazon, check your grades on WebSIS, or use a PayPal account, you are relying on number theoretic algorithms.
Soon after devising his code, Turing disappeared from public view, and half a century would pass before the world learned the full story of where he’d gone and what he did there. We’ll come back to Turing’s life in a little while; for now, let’s investigate the code Turing left behind. The details are uncertain, since he never formally published the idea, so we’ll consider a couple possibilities.
The first challenge is to translate a text message into an integer so we can perform math ematical operations on it. This step is not intended to make a message harder to read, so the details are not too important. Here is one approach: replace each letter of the message with two digits (A = 01, B = 02, C = 03, etc.) and string all the digits together to form one huge number. For example, the message “victory” could be translated this way:
“v i c t o r y” → 22 09 03 20 15 18 25
Turing’s code requires the message to be a prime number, so we may need to pad the result with a few more digits to make a prime. In this case, appending the digits 13 gives the number 2209032015182513, which is prime.
Now here is how the encryption process works. In the description below, m is the unencoded message (which we want to keep secret), m∗^ is the encrypted message (which the Nazis may intercept), and k is the key.
Beforehand The sender and receiver agree on a secret key, which is a large prime k.
Encryption The sender encrypts the message m by computing:
m∗^ = m ·k
Decryption The receiver decrypts m∗^ by computing:
= m k k
On page 1 of his masterpiece on number theory, Disquisitiones Arithmeticae, Gauss intro duced the notion of “congruence”. Now, Gauss is another guy who managed to cough up a halfdecent idea every now and then, so let’s take a look at this one. Gauss said that a is congruent to b modulo n if n |(a − b). This is denoted a ≡ b (mod n). For example:
29 ≡ 15 (mod 7) because 7 |(29 − 15).
Intuitively, the ≡ symbol is sort of like an = sign, and the mod 7 describes the specific sense in which 29 is equalish to 15. Thus, even though (mod 7) appears over on the right side, it is in no sense more strongly associated with the 15 than the 29; in fact, it actually defines the meaning of the ≡ sign.
Here’s another way to think about congruences: congruence modulo n defines a partition of the integers into n sets so that congruent numbers are all in the same set. For example, suppose that we’re working modulo 3. Then we can partition the integers into 3 sets as follows: {... , − 6 , − 3 , 0 , 3 , 6 , 9 ,... } {... , − 5 , − 2 , 1 , 4 , 7 , 10 ,...
... , − 4 , − 1 , 2 , 5 , 8 , 11 ,...
Now integers in the same set are all congruent modulo 3. For example, 6 and 3 are both in the first set, and they’re congruent because their difference, 6 − (−3) = 9, is a multiple of 3. Similarly, 11 and 5 are both in the last set, because 11 − 5 = 6 is a multiple of 3. On the other hand, numbers in different sets are not congruent. For example, 9 is in the first set and 11 in the last set, and they’re not congruent because 11 − 9 = 2 is not a multiple of
There are many useful facts about congruences, some of which are listed in the lemma below. The overall theme is that congruences work a lot like equations, though there are a couple exceptions.
Lemma 1 (Facts About Congruences). The following hold for n ≥ 1 :
Proof. We prove only parts 1 and 7; the other parts are proved similarly.
(part 1) Every integer divides 0, so n |(a − a), which means a ≡ a (mod n).
(part 7) The assumption a ≡ b (mod n) implies that ac ≡ bc (mod n) by part 5. Similarly, the assumption c ≡ d (mod n) implies bc ≡ bd (mod n). Therefore, ac ≡ bd (mod n) by part 3.
There is a close connection between modular arithmetic and the remainder operation, which we looked at last time. To clarify this link, let’s reconsider the partition of the integers defined by congruence modulo 3:
{... , − 6 , − 3 , 0 , 3 , 6 , 9 ,... } {... , − 5 , − 2 , 1 , 4 , 7 , 10 ,...
... , − 4 , − 1 , 2 , 5 , 8 , 11 ,...
Notice that two numbers are in the same set if and only if they leave the same remainder when divided by 3. The numbers in the first set all leave a remainder of 0 when divided by 3, the numbers in the second set leave a remainder of 1, and the numbers in the third leave a remainder of 2. Furthermore, notice that each number is in the same set as its own remainder. For example, 11 and 11 rem 3 = 2 are both in the same set. Let’s bundle all this happy goodness into a lemma.
Lemma 2 (Congruences and Remainders). The following assertions hold:
Proof. (of part 2) By the division algorithm, there exist unique pairs of integers q 1 , r 1 and q 2 , r 2 such that:
a = q 1 n + r 1 (where 0 ≤ r 1 < n) b = q 2 n + r 2 (where 0 ≤ r 2 < n)
In these terms, (a rem n) = r 1 and (b rem n) = r 2. Subtracting the second equation from the first gives:
a − b = (q 1 − q 2 )n + (r 1 − r 2 ) (where −n < r 1 − r 2 < n)
Now a ≡ b (mod n) if and only if n divides the left side. This is true if and only if n divides the right side, which holds if and only if r 1 −r 2 is a multiple of n. Given the bounds on r 1 = r 2 , this happens precisely when r 1 = r 2 , which is equivalent to (a rem n) = (b rem n).
The mutiplicative inverse of a number x is another number x−^1 such that:
x ·x−^1 = 1
Generally, multiplicative inverses exist over the real numbers. For example, the multi plicative inverse of 3 is 1 / 3 since: 1 3 · = 1 3 The sole exception is that 0 does not have an inverse.
On the other hand, inverses generally do not exist over the integers. For example, 7 can not be multiplied by another integer to give 1.
Surprisingly, multiplicative inverses do exist when we’re working modulo a prime num ber. For example, if we’re working modulo 5, then 3 is a multiplicative inverse of 7, since:
7 · 3 ≡ 1 (mod 5)
(All numbers congruent to 3 modulo 5 are also multiplicative inverses of 7; for example, 7 · 8 ≡ 1 (mod 5) as well.) The only exception is that numbers congruent to 0 modulo 5 (that is, the multiples of 5) do not have inverses, much as 0 does not have an inverse over the real numbers. Let’s prove this.
Lemma 3. If p is prime and k is not a multiple of p, then k has a multiplicative inverse.
Proof. Since p is prime, it has only two divisors: 1 and p. And since k is not a multiple of p, we must have gcd(p, k) = 1. Therefore, there is a linear combination of p and k equal to 1: sp + tk = 1
Rearranging terms gives: sp = 1 − tk
This implies that p | 1 − tk by the definition of divisibility, and therefore tk ≡ 1 (mod p) by the definition of congruence. Thus, t is a multiplicative inverse of k.
Multiplicative inverses are the key to decryption in Turing’s code. Specifically, we can recover the original message by multiplying the encoded message by the inverse of the key:
m∗^ · k−^1 ≡ (mk rem p) ·k−^1 (mod p) ≡ mkk−^1 (mod p) ≡ m (mod p)
This shows that m∗k−^1 is congruent to the original message m. Since the m was in the range 0 , 1 ,... , p − 1 , we can recover it exactly taking a remainder:
m = m∗k−^1 rem p
So now we can decrypt!
Another sense in which real number are nice is that one can cancel multiplicative terms. In other words, if we know that m 1 k = m 2 k, then can cancel the k’s and conclude that m 1 = m 2 , provided k =� 0. In general, cancellation is not valid in modular arithmetic. For example, this congruence is correct:
2 · 3 ≡ 4 · 3 (mod 6)
But if we cancel the 3’s, we reach a false conclusion:
2 ≡ 4 (mod 6)
The fact that multiplicative terms can not be cancelled is the most significant sense in which congruences differ from ordinary equations. However, this difference goes away if we’re working modulo a prime; then cancellation is valid.
Lemma 4. Suppose p is a prime and k is not a multiple of p. Then
ak ≡ bk (mod p) implies a ≡ b (mod p)
Proof. Multiply both sides of the congruence by k−^1.
We can use this lemma to get a bit more insight into how Turing’s code works. In particular, the encryption operation in Turing’s code permutes the space of messages. This is stated more precisely in the following corollary.
Corollary 5. Suppose p is a prime and k is not a multiple of p. Then the sequence: � � (0 · k) rem p, (1 · k) rem p, (2 · k) rem p,... , (p − 1) · k rem p
is a permutation of the sequence:
0 , 1 , 2 ,... , (p − 1)
This remains true if the first term is deleted from each sequence.
Proof. The first sequence contains p numbers, which are all in the range 0 to p − 1 by the definition of remainder. Furthermore, the numbers in the first sequence are all different; by part 2 of Lemma 2, m 1 k rem p = m 2 k rem p if and only if m 1 ≡ m 2 (mod p), and no two numbers in the range 0, 1,... , p 1 are congruent modulo p. Thus, the first sequence must contain all of the numbers from 0 to p − 1 in some order. The claim remains true if the first terms are deleted, because both sequences begin with 0.
For example, suppose p = 5 and k = 3. Then the sequence: (0 � · 3) rem 5 �� �, (1 � · 3) rem 5 �� �, (2 � · 3) rem 5 �� �, (3 � · 3) rem 5 �� �, (4 � · 3) rem 5 �� � =0 =3 =1 =4 =
is a permutation of 0, 1, 2, 3, 4 and the last four terms are a permutation of 1, 2, 3, 4. As long as the Nazis don’t know the secret key k, they don’t know how the message space is permuted by the process of encryption and thus can’t read encoded messages.
German weather reports were not encrypted with the highlysecure Enigma system. After all, so what if the Allies learned that there was rain off the south coast of Iceland? But, amazingly, this practice provided the British with a critical edge in the Atlantic naval battle during 1941.
The problem was that some of those weather reports had originally been transmitted from Uboats out in the Atlantic. Thus, the British obtained both unencrypted reports and the same reports encrypted with Enigma. By comparing the two, the British were able to determine which key the Germans were using that day and could read all other Enigmaencoded traffic. Today, this would be called a knownplaintext attack.
Let’s see how a knownplaintext attack would work against Turing’s code. Suppose that the Nazis know both m and m∗^ where:
m∗^ ≡ mk (mod p)
Now they can compute:
mp−^2 ·m∗^ ≡ mp−^2 · (mk rem p) (mod p) (def. of m∗) ≡ mp−^2 ·mk (mod p) (part 2 of Lemma 2) ≡ mp−^1 ·k (mod p) (simplification) ≡ k (mod p) (Fermat’s Theorem)
Now the Nazis have the secret key k and can decrypt any message!
This is a huge vulnerability, so Turing’s code has no practical value. Fortunately, Tur ing got better at cryptography after devising this code; his subsequent cracking of Enigma surely saved thousands of lives, if not the whole of Britain.
A few years after the war, Turing’s home was robbed. Detectives soon determined that a former homosexual lover of Turing’s had conspired in the robbery. So they arrested him; that is, they arrested Alan Turing. Because, at that time, homosexuality was a crime in Britain, punishable by up to two years in prison. Turing was sentenced to a humiliating hormonal “treatment” for his homosexuality: he was given estrogen injections. He began to develop breasts.
Three years later, Alan Turing, the founder of computer science, was dead. His mother explained what happened in a biography of her own son. Despite her repeated warnings, Turing carried out chemistry experiments in his own home. Apparently, her worst fear was realized: by working with potassium cyanide while eating an apple, he poisoned himself.
However, Turing remained a puzzle to the very end. His mother was a devoutly re ligious woman who considered suicide a sin. And, other biographers have pointed out, Turing had previously discussed committing suicide by eating a poisoned apple. Evi dently, Alan Turing, who founded computer science and saved his country, took his own life in the end, and in just such a way that his mother could believe it was an accident.