Lecture Slides 5
Lecture Slides 5
Primes
Modular
Arithmetic
Number Theory
Information Security
1/15
Contents
Number Theory
Primes
Modular
Arithmetic
Modular Arithmetic
2/15
Divisibility
Number Theory
I b divides a if a = mb for some m, where a, b and m are
Primes
integers
Modular
Arithmetic I b|a
I b is a divisor of a
I gcd(a, b): greatest common divisor of a and b
I Euclidean algorithm can find gcd
I Two integers, a and b, are relatively prime if
gcd(a, b) = 1
3/15
Prime Numbers
Number Theory
Primes
I An integer p > 1 is a prime number if and only if its
Modular
only divisors are ±1 and ±p
Arithmetic
I Any integer a > 1 can be factored as:
4/15
Primes Under 2000
Number Theory
Primes
Modular
Arithmetic
5/15
Contents
Number Theory
Primes
Modular
Arithmetic
Modular Arithmetic
6/15
Modular Arithmetic
Number Theory
Primes
I If a is an integer and n is a positive integer, we define
Modular
a mod n to be the remainder when a is divided by n
Arithmetic
I n is called the modulus
I Two integers a and b are congruent modulo n if
(a mod n) = (b mod n), which is written as
a≡b (mod n)
7/15
Properties of Modular Arithmetic
Number Theory
Primes
I Rules of ordinary arithmetic involving addition,
Modular
subtraction, and multiplication also apply in modular
Arithmetic arithmetic
[(a mod n) + (b mod n)] mod n = (a + b) mod n
[(a mod n) − (b mod n)] mod n = (a − b) mod n
[(a mod n) × (b mod n)] mod n = (a × b) mod n
8/15
Division in Modular Arithmetic
Number Theory
I a is additive inverse of b if a + b ≡ 0 (mod n)
Primes
I All integers have an additive inverse
Modular
Arithmetic I a is multiplicative inverse of b if a × b ≡ 1 (mod n)
I Not all integers have a multiplicative inverse
I a has a multiplicative inverse in (mod n) if a is
relatively prime to n
I Division: a ÷ b ≡ a × MultInverse(b) (mod n)
9/15
Fermat’s Theorem
Number Theory
Primes
I Fermat’s Theorem (1): if p is prime and a is a positive
Modular
integer not divisible by p, then
Arithmetic
ap−1 ≡ 1 (mod p)
10/15
Euler’s Theorem
Number Theory
I Euler’s Totient Function, φ(n): the number of positive
Primes
integers less than n and relatively prime to n
Modular
Arithmetic I φ(1) = 1
I For prime p, φ(p) = p − 1
I For primes p and q, and n = pq,
φ(n) = (p − 1) × (q − 1)
I Euler’s Theorem (1): For every a and n that are
relatively prime:
aφ(n) ≡ 1 (mod n)
aφ(n)+1 ≡ a (mod n)
11/15
Logarithms in Modular Arithmetic
Number Theory
Primes
I Exponentiation (mod n): repeated multiplication
Modular I Logarithms in ordinary arithmetic:
Arithmetic
b = ai
i = loga (b)
I Logarithms in modular arithmetic (discrete logarithm):
b = ai (mod p)
i = dloga,p (b)
I A unique exponent i can be found if a is a primitive
root of prime p
I If a is a primitive root of p then a, a2 , a3 , . . . , ap−1 are
distinct (modp)
I Only integers with primitive roots: 2, 4, p α , 2p α where
p is any odd prime and alpha is positive integer
12/15
Powers of Integers, Modulo 19
Number Theory
Primes
Modular
Arithmetic
Credit: Table 8.3 in Stallings, Cryptography and Network Security, 5th Ed., Pearson 2011
13/15
Discrete Logarithms, Modulo 19
Number Theory
Primes
Modular
Arithmetic
14/15 Credit: Table 8.4 in Stallings, Cryptography and Network Security, 5th Ed., Pearson 2011
Complexity
Number Theory
Primes
Certain problems are computationally hard . . .
Modular Integer Factorisation
Arithmetic
Euler’s Totient
I Given composite n, find φ(n)
I Harder than integer factorisation
Discrete Logarithms
I Given b, a and p, find i such that i = dloga,p (b)
I Comparable to integer factorisation
15/15