Mathematics and Cryptography: Numbers
Mathematics and Cryptography: Numbers
Mathematics and Cryptography: Numbers
Schellinx
Numbers
ℕ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ
Natural numbers, integers (whole numbers), rational numbers, real numbers and complex
numbers.
Prime numbers: A number p ∈ ℕ is a prime number (or: is prime) when it has exactly
two distinct divisors, namely 1 and itself.
(A proof of this important fact can already be found in Euclid’s ‘The Elements’. It is
proposition 20 in book IX. We did the proof in class. Can you recall it?)
Prime numbers are like atoms in our number system, which is the ‘essence’ of the
fundamental theorem of arithmetic: Any number n ∈ ℕ can be written as a product of
primes in a way that is, essentially, unique (by putting the separate prime factors in
increasing order). ⊠
m m′ m
Corollary: For any fraction we can find numbers m′ and n′ such that = , with
n n′ n
m′ ≤ m, n′ ≤ n and the greatest common divisor of m′ and n′, gcd(m′, n′), is equal to 1.
We say that m′ and n′ are co-prime. Note that this implies that whenever for two integers
k m′
k and l, we have = , then k ≥ m′ and l ≥ n′.
l n′
The division of two natural numbers b and a: for all natural numbers a, b with 0 ≠a<b
we can find two other natural numbers (the quotient q and the remainder r) such that
b = q ⋅ a + r, and 0 ≤ r < a.
We use (and used in class) Euclid’s Algorithm to find the greatest common divisor
gcd(a, b) of two natural numbers a and b; when we ‘run the algorithm in reverse’, we find
two integers x and y that satisfy a ⋅ x + b ⋅ y = gcd(a, b). This equality is called Bézout’s
identity.
The fact that these two integers always exist follows from Bézout’s Theorem: The
equation a x + by = c has a solution in whole numbers iff gcd(a, b) | c. ⊠
Another corollary of this theorem is the following important and very useful fact: two
natural numbers a and b are co-prime iff ∃x, y ∈ ℤ such that a x + by = 1.
Exercise 1:
a. Use Euclid’s algorithm to determine gcd(77,9) and find x and y such that 77x + 9y = gcd(77,9)
b. Use Euclid’s algorithm to determine gcd(321,27) and find x, y such that 321x + 27y = gcd(321,27)
Sets
Recall:
• a set is ‘a bag of things’, like !E = {all natural numbers that divisible by 2} = !{x ∈ ℕ | ∃k ∈ ℕ . x = 2k} ; if
something is ‘inside the bag’, we write that, e.g., !2 ∈ E ; or 25679564
! ∈ E ; if something is ‘not inside the bag’, we
write that, e.g., 17
! ∉ E.
• the intersection !A ∩ B of two sets A and B, which contains those elements that are in both of the sets
• the union !A ∪ B of two sets A and B, which contains those elements that are in at least one of the sets
If E and F are non-empty set, the cartesian product E × F is the set of all possible pairs
with a first element from E and a second one from F: E × F = {(x, y) | x ∈ E, y ∈ F}.
For example, let E = {0, 1, 2}, then the graph GR = {(0,0), (0,2), (1,0)} ⊂ E 2 is a
binary relation R on E, and we write 0R0, 0R2, 1R0 to indicate the ‘relations’ between
the elements of E.
Given an equivalence relation R on a set E, the so-called quotient set E /R is the set of
all R− equivalence classes in E: E /R = {cl(x) | x ∈ E}.
Partitions
Let A be a non-empty set and A1, A2, A3, . . . , Ap a collection of subsets of A. We say
⋃
—A = Ai
i=1
proof: This is pretty much evident from the definition of an equivalence relation: by reflexivity each
of the elements of E is included in an equivalence class, and by transitivity and symmetry these
2022 - ESIEA Dr. H. Schellinx
classes are disjoint. For, suppose that y ∈ cl(x) and y ∈ cl(z). Then x R y and z R y, so x R z and
z R x: z ∈ cl(x) and x ∈ cl(z), hence cl(x) = cl(z). ⊠
Modular arithmetic
This is a system of arithmetic for integers, where the numbers ‘wrap around’ when
reaching a value, called the modulus.
- 3 hours after 11 o’clock in the evening we say without any hesitation that it is now ‘2
o’clock’ …
Given a positive integer n (the modulus), two integers a and b are said to be congruent
modulo n if their difference is divisible by n, i.e. iff n | (a − b)
n | (a − b) iff 12 | (13 − 37)
∃k ∈ ℤ, a − b = k n iff (13 − 37) = − 2 × 12
∃k ∈ ℤ, b − a = k n iff (37 − 13) = 2 × 12
n | (b − a) iff 12 | (37 − 12)
b ≡ a [n] 37 ≡ 13[12]
For each n, the relation a≡ b [n] is a binary relation on the set of integers ℤ, i.e. it is a
subset of the cartesian product ℤ × ℤ = ℤ2.
Proposition: For each n, the relation a ≡ b [n] is an equivalence (relation) on the set of
integers ℤ.
proof: Exercise. ⊠
As our congruence relation is an equivalence, we can consider, for any given n the
resulting equivalence classes: x and y will be in the same equivalence class modulo n if
and only of x
≡ y [n]. The equivalence class modulo n of a given integer x is written as x.
We have: x = {y | y ≡ x[n]} = {x + k n | k ∈ ℤ}
Here are some of the properties of these equivalence classes x, given some modulus n:
Examples:
123 [5] — if we divide 123 by 5 we find: 123
= 24 × 5 + 3 ; 3 is the remainder … we
write : 123 ≡ 3 (mod 5). Hence 123 = 3 (mod 5)
Exercise:
n−1
⋃
[ More generally, modulo n, ℤ = k ]
k=0
For each n, the ≡n − equivalence classes partition the integers ℤ in n disjoint parts.
ℤ/nℤ = {0, 1, 2, . . . , n − 1}
… -22
-7 -6 -5 -4 -3 -2 -1
0 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 …