MATHEMATICAL BACKGROUND
OF CRYPTOGRAPHY
TCS 491 UNIT 3
Prime Numbers
• Prime numbers only have divisors of 1 and self
– They cannot be written as a product of other numbers
– Note: 1 is prime, but is generally not of interest
• e.g. 2, 3, 5, 7 are prime, 4, 6, 8, 9, 10 are not
• Prime numbers are central to number theory
• List of prime number less than 200 is:
2 3 5 7 11 13 17 19 23 29 31 37 41 43
47 53 59 61 67 71 73 79 83 89 97 101
103 107 109 113 127 131 137 139 149
151 157 163 167 173 179 181 191 193
197 199
Prime Factorisation
• To Factor a number n is to write it as a
product of other numbers: n=a × b × c
• Note that factoring a number is relatively hard
compared to multiplying the factors together
to generate the number.
• The prime factorisation of a number n is
when its written as a product of primes
– e.g. 91=7x13 ; 3600=24x32x52
Relatively Prime Numbers & GCD
• Two numbers a,b are relatively prime if
have no common divisors apart from 1
– e.g. 8 & 15 are relatively prime since factors
of 8 are 1,2,4,8 and of 15 are 1,3,5,15 and 1
is the only common factor.
• Conversely can determine the greatest
common divisor by comparing their
prime factorizations and using least
powers
– e.g. 300=21x31x52 18=21x32 hence
GCD(18,300)=21x31x50=6
Fermat's Theorem
• If ‘p’ is a prime and ‘a’
is a positive integer
such that gcd(a,p)=1,
then
• ap-1 ≡ 1 (mod p)
• Also known as Fermat’s Little Theorem
• Also ap ≡ p (mod p)
• Useful in public key and primality testing
Fermat's Theorem
• a = 7, p = 19
• GCD(a, p) = GCD(7, 19) = 1
• ap-1 ≡ 1 (mod p)
• 718 = 716×72 (mod 19)≡ 7× 11 (mod 19)
= 77 mod 19 = 1 (mod 19)
• (716 mod 19 = 121 mod 19 = 7)
• (72 mod 19 = 49 mod 19 = 11)
Euler Totient Function ø(n)
• When doing arithmetic modulo n
• Complete set of residues is: 0..N-1
• Reduced set of residues is those numbers
(residues) which are relatively prime to n
– e.g. for n=10,
– Complete set of residues is {0,1,2,3,4,5,6,7,8,9}
– Reduced set of residues is {1,3,7,9}
• Number of elements in reduced set of
residues is called the Euler Totient Function
ø(n)
Euler Totient Function ø(n)
• To compute ø(n) need to count number
of residues to be excluded
• In general need prime factorization, but
–For p (p prime) ø(p) = p-1
–For p.q (p,q prime)ø(pq)=(p-1)x(q-1)
• e.g.
ø(37) = 36
ø(21) = (3–1)x(7–1) = 2x6 = 12
Euler's Theorem
• A generalisation of Fermat's Theorem
• aø(n) ≡ 1 (mod n)
–for any a,n where gcd(a,n)=1
• e.g.
a=3;n=10; ø(10)=4;
hence 34 = 81 = 1 mod 10
a=2;n=11; ø(11)=10;
hence 210 = 1024 = 1 mod 11