Chapter 1: The Integers - Z: Divisibility
Chapter 1: The Integers - Z: Divisibility
Chapter 1: The Integers - Z: Divisibility
Divisibility
1
Primes Prime number divisible only by self
and 1; Infinite number of them (Euclid).
Easy proof.
2
Equivalence Relations
3
Equivalence Relations cont.
• a, b, n ∈ Z, n 6= 0. Then a ≡ b (mod m) if
a − b is a multiple of n (a = b + nk: they
have same remainder if divided by n).
• Congruence (mod m) is an equivalence
relation, and integers mod m is just the
collection of equivalence classes, denoted
Z/m.
• Z/m can be represented 0̄, 1̄, ..., m ¯
− 1, for
instance: pick reps 0, 1, ...m − 1.
• Remember
(x + y)%m = ((x%m) + (y%m))%m,
(x ∗ y)%m = ((x%m) ∗ (y%m))%m?
These are because you can prove
(+, −, ×) behave well with congruence
and define analogous operations on the
equivalence classes, so you get
associativity, distributivity, etc.
5
More Congruence
a, b, c, d, n, n 6= 0 ∈ Z, a ≡ b (mod n), c ≡ d
(mod n). Then
a + c ≡ b + d, a − c ≡ b − d, ac ≡ bd (mod n).
Congruences inherit:
• Distributivity
• Associativity of +, ×:
(x + y) + z ≡ x + (y + z) (mod m)
(xy)z ≡ x(yz) (mod m)
• +, × identities: 0 + x ≡ x + 0 ≡ x
(mod m), 1 · x ≡ x · 1 ≡ x (mod m)
6
Just-for-fun Applications
7
Fermat’s Little Theorem
Little Lemma:
gcd(bm − 1, bn − 1) = b(gcd(m,n)) − 1, so for
numbers of form bn, is n is composite, then
for all factors d of n, bn − 1 and bd − 1 have a
factor in common: bd − 1.
8
FLT Proof
9
Unique Factorization
10
Phi Function
e e
N = ±p11 p22 ...penn .
11
Finding Primes (factors)
q
• Divide by all i < (n)
• Eratosthenes’s Sieve
• Identities: x2 − y 2 = (x − y)(x + y),
• x5 +y 5 = (x+y)(x4 −x3y +x2y 2 −xy 3 +y 4),
etc.
• Mersenne prime: 2n − 1 prime.
• Fermat prime: 2n + 1 prime.
12
Euclidean Algorithm
13
Euclidean Algorithm E.g.
210 - 1 * 119 = 91
119 - 1 * 91 = 28
91 - 3 * 28 = 7
28 - 4 * 7 = 0 ==> gcd is 7
26 - 1 * 19 = 7
19 - 2 * 7 = 5
7 - 1 * 5 = 2
5 - 2 * 2 = 1
2 - 2 * 1 = 0 ==> gcd is 1
14
Find Multiplicative Inverse
15
E.g. EEA for 19, 26
1 = 5 - 2 * 2
= 5 - 2 * (7 - 1 * 5) = -2 * 7 + 3 * 5
= -2 * 7 + 3 * (19 - 2 * 7) = 3 * 19 - 8 * 7
= 3 * 19 - 8 *(26 - 1 * 19)= -8 *26 + 11 *19
16
Fun with Division
• Unless d | b no solution.
• Solve (a/d)x ≡ (b/d) (mod n/d) to get
soln x0.
• All Solns are of form
x0 + q(n/d), 0 ≤ q ≤ (d − 1).
17
Fast Exponentiation
Then
18
Algorithm
19
Square Roots and More
If
x ≡ a (mod m)
x ≡ b (mod n)
then
22
General Case: n congruences
24
Square Roots mod Composite (cont.)
25
Backwards...
26
Chinese Bagel
x%5
| 0 1 2 3 4
---|---------------
0 |00 06 12 03 09
x%3 1 |10 01 07 13 04
2 |05 11 02 08 14
27
Back to roots mod composites Find x
such that x2 = y (mod pq). Such an x must
also satisfy x2 = y (mod p), x2 = y
(mod q). Sun Ze’s theorem tells us, given
y1 ∈ Z/p and y2 ∈ Z/q, how to find the unique
y ∈ Z/pq that satisfies y%p = y1 and
y%q = y2.
Examples ...
29
Using Euler’s Theorem
With a, n, x, y ∈ Z, n ≥ 1, gcd(a, n) = 1,
30
Key Exchange Example
31
Primitive Roots – Why do we care?
32
Primitive Roots, Discrete Logs
33
Prim. Root Properties
34
Prim. Root Existence
35
Quadratic Symbols – Why?
36
Jacobi Symbols
37