The extended Euclidean Algorithm
The Euclidean algorithm to nd d = gcd(a, b) , a > b , computes a sequence of remainders cfw_rj by
a = q1 b + r1
b = q2 r1 + r2
.
.
.
rk2 = qk rk1 + rk
rk1 = qk+1 rk
We can also write the last line as rk1 = qk+1 rk + rk+1

MATH 470H Exam 1
You may use a calculator provided it only has the ability to add, multiply, subtract and divide.
[2] Describe in detail the steps taken to set up a Hill cipher system.
Alice and Bob agree to use a Hill cipher with a 4 4 encryption
matrix

Math 470 Exam 1 Notes
Name:
Instructions:
You must print out this sheet and hand it in with your exam. Print only on standard letter size paper.
You may write any notes you would like on this side of the paper only.
Your notes must be handwritten in pen o

MATH 470H, Exam 2
You may use a calculator provided it only has the ability to add, multiply, subtract and divide.
[1] Describe fully how each of the following primality tests work and illustrate your answers to the above
by working out the decision by ea

Math 470 Exam 2 Notes
Name:
Instructions:
You must print out this sheet and hand it in with your exam. Print only on standard letter size paper.
You may write any notes you would like on this side of the paper only.
Your notes must be handwritten in pe

Fermats Little Theorem
Theorem. Let p be prime and a such that p | a . Then ap1 1 (mod p) .
There are several proofs of this result and probably the most straighforward one that does not
require anything beyond a counting argument.
Proof: Let S = cfw_x :

Math 470 Final Exam Notes
Name:
Instructions:
You must print out this sheet and hand it in with your exam. Print only on standard letter size paper.
You may write any notes you would like on either side of the of this paper.
Your notes must be handwrit

Letter and Digraph Frequency in English
Letter
Frequency (%)
Letter
Frequency (%)
Digraph
Frequency
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
8.167
1.492
2.782
4.253
12.702
2.228
2.015
6.094
6.966
0.153
0.772
4.025
2.406
6.749
7.507
1.929
0.095

MATH 470H Homework 1
Solutions
[1] If you make up an afne cipher with the function y 15x + 11 (mod 26) what would be the
decryption function? [Some trial and error might be needed for now, but we will soon correct
this].
Then 15x y 11 (mod 26). Also 7.15

MATH 470H Homework 2 Solutions
[1] There is turmoil in Wonderland , Eve has broken their Hill cipher, again. The Queen of Hearts
declared to all, I have had enough. We are no longer using a Hill cipher with short blocksize.
These small words such as dear

MATH 470H Homework 3 Solutions
3 1
is invertible (mod n).
6 5
This matrix has determinant det A = 15 6 = 9. To invert this mod n we require that
gcd(det A, n) = 1. Obviously, gcd(9, n) = 0 if n 0 (mod 3), so the matrix isnt invertible
in this case, but ot

MATH 470H Homework 4 Solutions
[1] Let y and n be integers and assume the integer x is written in binary as x = b1 b2 . . . bm .
Consider the following algorithm pseudocode;
s1 = 1;
for k = 1; k m; k = k + 1cfw_
if bk = 1, let rk sk y (mod n)
else, let rk

MATH 470H Homework 6 Solutions
[1] Show that if gcd(e, 24) = 1, then e2 1 (mod 24).
Show that if n = 35 is used as an RSA modulus then the decryption exponent d always equals the encryption
exponent e.
Clearly, if gcd(e, 24) = 1 then e cannot be even nor

MATH 470H Homework 7 Solutions
[1] Sally Silly makes up her own version of RSA. She doesnt want to mess with two primes so she just takes the
modulus n to be a prime p but everything else is the same. Why is this not a good idea?
Because now she has to ch

MATH 470H Homework 8 Solutions
[1] Try to factor n = 1545013 by using Fermat factorisation: (compute n + 12 , n + 22 , n + 32 , . . ., until we
nd a square.).
First note that n = 1242.99 and so n = 1243. Note that 12432 = 1545049 and 12442 = 1547536.
Now

MATH 470H Homework 9 Solutions
This homework set features the prime p = 421 and some of its primitive roots = 2, 23. In each question you
may use a calculator (symbolic Matlab or Maple/Mathematica is probably best) to do the tedius computations of
squarin

MATH 470H Homework 910
[1] We know that if g is a primitive root for the prime p then so also is g1 (mod p). The question is: if g1 and
g2 are primitive roots is g1 g2 also a primitive root? Always? Never? Sometimes?
You might want to think about the cons

Testing for square roots
The central issue in this section is to decide if a given number a is a square root modulo n . As expected,
the easiest case is when n = p is prime. The following gives an answer:
Theorem 1. Let p > 2 be prime and the integer a su

MATH 470.200/501
Examination 1 Solutions
October 6, 2011
1.
Complete the statements of the following theorems and denitions we have covered.
Solution: The following are valid answers, but there are other possibilities.
(a) Let a and m be integers. Then a

MATH 470.200/501
Examination 2 Solutions
November 3, 2011
1. Alice and Bob are using RSA to communicate.
(a) Alices encryption key is (n1 , e1 ) = (187, 7). Alice wants to encode the plaintext 10 to
send to Bob. What is the ciphertext that she sends?
(b)

Primality Testing
The very basic result is the following - simply the contrapositive of Fermats Little Theorem
Fermats Primality Test. Suppose 1 < a < n , and let an1 b (mod n) . Then if b 1
declare n probably prime, otherwise declare n composite.
This wo