CH5 Flashcards
recall thm euler fermat
application
If a is coprime with n, then a^{ϕ(n)} ≡ 1 (mod n).
applications:
looking at RSA
how to we check if a large number is prime?
Definition 5.1.1 (The RSA algorithm)
First of all, we generate the keys.
(1) fix a product N = pq of two large distinct prime numbers;
(2) compute ϕ(N) = (p − 1)(q − 1);
(3) pick some e with 1 < e < ϕ(N) such that e is coprime to ϕ(N);
(4) the** public key is the pair (N, e);**
(5) compute s such that es ≡ 1 (mod ϕ(N));
(6) the private key is the pair (N, s);
(7) throw away the numbers p, q, ϕ(N).
A message (either plaintext or cyphertext) is an integer m with 0 < m < N. in {1,2,…,N-1}
* To encrypt m: compute the remainder r of m^e modulo N.
* To decrypt r: compute the remainder m of r^s modulo N.
By the Euler-Fermat theorem, encrypting and decrypting a message returns the original back:
(m^e)^s = m^{1+kϕ(N)} ≡ m (mod N).
large primes
Encryption and decryption are symmetric
Example 5.1.2. Let us write calendar dates in the format DDMM as four-digit numbers.
For example, the 5th of November is 0511 = 511. Suppose someone has encoded their birthday using RSA with public key (3599, 17) and obtained 725. What is their
birthday?
First of all, we must finish generating the keys. If we factorise N =
3599, we find N = 59 · 61, hence ϕ(N) = 58 · 60 = 3480.
We then use Euclid’s algorithm(links to Bezouts lemma proof):
3480 = 204 · 17 + 12
17 = 1 · 12 + 5
12 = 2 · 5 + 2
5 = 2 · 2 + 1
2 = 2 · 1 + 0.
Reversing the equalities:
1 = 5 − 2 · 2 = 5 − 2 · (12 − 2 · 5) = 5 · 5 − 2 · 12
= 5 · (17 − 1 · 12) − 2 · 12 = 5 · 17 − 7 · 12
= 5 · 17 − 7 · (3480 − 204 · 17) = 1433 · 17 − 7 · 3480.
Thus s = 1433 works as a private key: indeed, se = 1433 · 17 ≡ 1 (mod 3480).
In turn, we calculate 725^1433 modulo 3599 and find 2701. :
725¹⁴³³=725⁷¹⁶*²⁺¹ = (725²)⁷¹⁶ .725
repeated squares again and again will help efficiently calc
modulo 3599
So the birthday is the 27th
of January.
here we break the encryption without knowing private key
(REALLY REALLY important- do ex in PS3 )
when do we break the encryption?
because 3599 is a small number that we can easily factor by hand, at worst with the help of a calculator.
RSA relies on the fact that factorising a large number can take an impossible amount of time
To generate good RSA keys, we must be able to generate large prime numbers
Example 5.2.1. If n is prime, and gcd(a, n) = 1, then a^{n−1} congruent to?
when does this fail?
Can we use to test primes?
aⁿ⁻¹≡ 1 (mod n). Thus, if the
congruence fails for some a chosen at random, n is definitely not prime.
e.g
n=21
a = 2: we have 2²⁰ ≡ 2⁸ (because ϕ(21) = 12), thus
2⁸ ≡ (2⁴)²≡ (−5)² ≡ 4 ̸≡ 1 modulo 21.
A much less obvious example is
n = 2³² + 1 = 4294967297 and a = 3. Then
3ⁿ⁻¹ = 3²^³²
≡ . . . (32 squaring later) . . . ≡ 3029026160 ̸≡ 1 (mod n).
Thus n cannot be prime.
strategy isn’t the best, not reliable
why not reliable to test primes by seeing if aⁿ⁻¹≡ 1 (mod n).
strategy isn’t the best, not reliable infinitely many ns s.t congruent to 1 and n is composite: these are called Carmichael numbers
there are infinitely many of them
approx n^{2/7}of them in {1,.. n} as n goes to infinity
Definition 5.2.2 (Carmichael numbers)
An integer n > 1 is a Carmichael number if a^n ≡ a (mod n) for every a ∈ Z.
Example 5.2.3. The smallest Carmichael number is n = 561
n = 561 = 3 · 11 · 17. Indeed,
observe that n − 1 = 560 is divisible by 2 = 3 − 1, 10 = 11 − 1, 16 = 17 − 1. Then pick
some arbitrary a, and note that:
* if 3 ∤ a, then a² ≡ 1 (mod 3), thus a⁵⁶¹ = a²⁸⁰²⁺¹≡ a (mod 3);
if 3 | a, then also a³ ≡ 0 ≡ a (mod 3);
* if 11 ∤ a, then a¹⁰ ≡ 1 (mod 11), thus a⁵⁶¹ = a⁵⁶¹⁰⁺¹ ≡ a (mod 11); if 11 | a,
then also a¹¹ ≡ a (mod 11);
* if 17 ∤ a, then a¹⁶ ≡ 1 (mod 17), thus a⁵⁶¹ = a³⁵*¹⁶⁺¹ ≡ a (mod 17); again, if
17 | a, then a¹⁷ ≡ a (mod 17).
BY CRT: a⁵⁶¹≡ a (mod 561).
(FLT a⁵⁶⁰ ≡1 mod 561
a⁵⁶⁰ ≡a^2≡ 1 mod 561??)
Exercise 5.2.4 (⋆⋆, in exercise sheet). Show that a composite number n is a Carmichael
number if and only if whenever a prime p divides n, then (p − 1) | (n − 1) and p^2∤ n.
(This is known as ‘Korselt’s criterion’, 1899)
.
when you attempt, notice it matches when checking if is a carmichael number for our prev example 561: prime divisors 3,11,17 of 561 well 10 divides 560 2 divides 560, 16 divides 560 etc becomes generalised in this exercise
tricky exercise
Exercise 5.2.5 (Extra). Use Korselt’s criterion to verify that 561 is the smallest Carmichael number.
Some hints below. Let n be a Carmichael number.
(1) Show that n must be odd.
(2) Show that n must be the product of at least three primes.
(3) Suppose that n = pqr for p, q,r distinct odd primes. Show that pq ≡ 1 (mod r − 1).
(4) Suppose n = 3qr, 3 < q < r: deduce that q ≥ 11 and r ≥ 17. Thus the Carmichael
numbers of this form are ≥ 561
(5) Suppose n = 5qr: deduce that q ≥ 13 and r ≥ 17. Thus the Carmichael numbers
of this form are ≥ 1105 (which happens to be Carmichael).
(6) Deduce that 561 is the smallest Carmichael number (just check how big the remaining product of distinct primes are).
(1) Suppose by contradiction that n is even. It is not divisible by 4, so it is divisible
by some odd prime p. Then (p − 1) | (n − 1), but p − 1 is even and n − 1 is
odd, a contradiction.
(2) Suppose that n = pq for two distinct primes p, q. Then (p − 1) | (pq − 1), so
1 ≡ pq ≡ q (mod p−1), hence (p−1) | (q−1). By symmetry, (q−1) | (p−1),
so p = q, a contradiction.
(3) Same as above: r ≡ 1 (mod r − 1), while (r − 1) | (pqr − 1), thus 1 ≡ pqr ≡ pq
(mod r − 1).
(4) Suppose n = 3qr, 3 < q < r. We have 3r ≡ 1 (mod q − 1). It follows that
gcd(3, q − 1) = 1 and similarly gcd(3, r − 1) = 1. This excludes the primes 7
and 13 right away for both q and r.
If q = 5, then 15 ≡ 1 (mod r − 1), thus (r − 1) | 14, hence r ∈ {3, 8, 15}, a
contradiction. Thus q ≥ 11, hence r ≥ 13 > 11, and so r ≥ 17.
(5) Suppose n = 5qr, 5 < q < r. Just like before, 5q ≡ 1 (mod r − 1), so gcd(5, r −
1) = 1, and similarly gcd(5, q − 1) = 1. This excludes 11 for both q and r.
If q = 7, then 5q = 35 ≡ 1 (mod r − 1), hence r − 1 | 34, so r ∈ {3, 18, 35}, a
contradiction. Thus, q ≥ 13, and in turn r ≥ 17 > 13.
(6) If n is a product of three primes and not divisible by 3 nor 5, then it is at least
n ≥ 7 · 11 · 13 = 1001 > 561, and if it is a product of four or more primes, then
n ≥ 3 · 5 · 7 · 11 = 1155 > 561.
Proposition 5.3.1
Detecting composite numbers with primitive roots
We can spot non-primes better by playing with orders
Witness liar
Let n > 1 be an integer and p_1, . . . , p_t be the distinct prime factors of n − 1. If for some a we have
(1)
aⁿ⁻¹≡ 1 (mod n)
and
a[ⁿ⁻¹]/[ᵖ-ᶦ]/≡ 1 (mod n) for all i,
then n is prime.
To simplify the discussion: an a satisfying (1) is a witness that n is prime. If n is prime but a does not satisfy (1), we call a liar.
a witness or a liar?
an a satisfying (1) is a witness that n is prime. If n is prime
but a does not satisfy (1), we call a liar.
witness could be prime or Carmichael number
proof for PROPn
Let n > 1 be an integer and p_1, . . . , p_t be the distinct prime factors of
n − 1. If for some a we have
(1)aⁿ⁻¹≡ 1 (mod n)
and
a[ⁿ⁻¹]/[ᵖ-ᶦ]≡ 1 (mod n) for all i,
then n is prime.
To simplify the discussion: an a satisfying (1) is a witness that n is prime. If n is prime
but a does not satisfy (1), we call a liar.
Proof. A witness a must be coprime to n and have order n − 1 modulo n.
and for all number k strictly less than n-1
a^k is not going to be congruent to 1
we know that if a^k ≡ 1 then a^(gcd(n-1,k) ≡ 1 by bezouts lemma
therefore a has order n-1
Since a^{ϕ(n)} ≡ 1 (mod n), we must have n − 1 ≤ ϕ(n). Therefore, ϕ(n) = n − 1, thus n is prime. □
Example 5.3.2. Let us determine if 700001 is prime
Use the fact that 3⁷⁰⁰⁰⁰⁰≡ 1 (mod 700001)
3⁷⁰⁰⁰⁰⁰≡ 1 (mod 700001)
(squaring and taking the 5th power)
The prime factors of 700000 are 2, 5, 7, so dividing by these:
3³⁵⁰⁰⁰⁰ ≡ 700000 ̸≡ 1 (mod 700001),
3¹⁴⁰⁰⁰⁰ ≡ 425344 ̸≡ 1 (mod 700001),
3¹⁰⁰⁰⁰⁰ ≡ 591336 ̸≡ 1 (mod 700001).
Therefore, 700001 is prime.