Professional Documents
Culture Documents
Chapter4 - Number Theory and Cryptography
Chapter4 - Number Theory and Cryptography
Chapter4 - Number Theory and Cryptography
5 4.6 Cryptography
4.1 Divisibility and Modular Arithmetic
4.2 Integer Representations and Algorithms
4.3 Primes and Greatest Common Divisors
4.5 Applications of Congruences
4.6 Cryptography
3/30
Theorem 1
Let a, b, and c be integers, where a 6= 0. Then
i) if a | b and a | c, then a | (b + c),
ii) if a | b, then a | bc for all integers c,
iii) if a | b and b | c, then a | c.
a = dq + r .
a 6≡ b (mod m)
Theorem 4
Let m be a positive integer. The integers a and b are congruent
modulo m if and only if there is an integer k such that
a = b + km.
Theorem 5
Let m be a positive integer.
If a ≡ b (mod m) and c ≡ d (mod m) , then
i) a + c ≡ b + d (mod m)
ii) ac ≡ bd (mod m)
Theorem 1
Let b be an integer greater than 1. Then if n is a positive integer,
it can be expressed uniquely in the form
n = ak b k + ak−1 b k−1 + . . . + a1 b + a0 ,
9/30
Binary Expansions
bn mod m =?
k−1 +...+a k−1
b n = b ak−1 ·2 1 ·2+a0
= b ak−1 ·2 . . . b a1 ·2 · b a0
Primes, Composites
An integer p greater than 1 is called prime if the only positive
factors of p are 1 and p.
An integer that is greater than 1 and is not prime is called
composite.
17/30
Theorem 1 (The Fundamental Theorem of Arithmetic)
Every integer greater than 1 can be written uniquely as a prime or
as the product of two or more primes where the prime factors are
written in order of nondecreasing size.
Theorem 3
There are infinitely many primes.
Theorem 4 (The Prime Number Theorem)
The ratio of the number of primes not exceeding x and x/ ln x
approaches 1 as x grows without bound.
Example 12. What is the greatest common divisor of 120 and 500.
Greatest Common Divisors and Least Common Multiples
Example 12. What is the greatest common divisor of 120 and 500.
Solution:
120 = 23 31 51
500 = 22 53
⇒ gcd(120, 500) = 22 51 = 20
Relatively Prime
The integers a and b are relatively prime if their greatest
common divisor is 1.
The integers a1 , a2 , . . . , an are pairwise relatively prime if
gcd(ai , aj ) = 1 whenever 1 ≤ i < j ≤ n.
Example 13.
gcd(17, 22) = 1 ⇒ 17 and 22 are relatively prime.
7, 10, 11, 17, 23 are pairwise relatively prime.
Least Common Multiples
The least common multiple of the positive integers a and b,
denoted by lcm(a, b), is the smallest positive integer that is
divisible by both a and b.
Example 14.
What is the least common multiple of m = 75 1112 1390 and
n = 24 73 1114 ?
Theorem 5
ab = gcd(a, b) · lcm(a, b)
The Euclidean Algorithm.
Lemma
Let a = bq + r , where a, b, q, and r are integers. Then
gcd(a, b) = gcd(b, r ).
Example 15. Find the greatest common divisor of 252 and 198
using the Euclidean algorithm.
4.1 Divisibility and Modular Arithmetic
4.2 Integer Representations and Algorithms
4.3 Primes and Greatest Common Divisors
4.5 Applications of Congruences
4.6 Cryptography
Hashing Functions
A hashing function h assigns memory location h(k) to the
record that has k as its key.
One of the most common is the function
h(k) = k mod m
26/30
Pseudorandom Numbers
xn+1 = (axn + c) mod m
where
a : multiplier, 2 ≤ a < m
c : increment, 0 ≤ c < m
x0 : seed, 0 ≤ x0 < m.
Find x6 .
4.1 Divisibility and Modular Arithmetic
4.2 Integer Representations and Algorithms
4.3 Primes and Greatest Common Divisors
4.5 Applications of Congruences
4.6 Cryptography
Classical Cryptography
Number theory is the basis of many classical ciphers. These
ciphers encrypt messages by changing each letter to a
different letter.
Replace each letter by an integer from 0 to 25 (replace A by
0, K by 10, and Z by 25).
In the encrypted version of the message, the letter represented
by p is replaced with the letter represented by
28/30
Example 18. Encrypt the message “ATTACK” using the shift
cipher with shift k = 5.