You are on page 1of 33

Number Theory for

Cryptography
Nauman H. Ansari
Spring 2019 - MAJU
Number Theory
• The branch of mathematics that deals with the properties and
relationships of numbers, especially the positive integers.

• Study of Integers
DIVISIBILITY AND THE DIVISION
ALGORITHM
The Division Algorithm
• Given any positive integer n and any nonnegative integer a, if we
divide a by n, we get an integer quotient q and an integer remainder r
that obey the following relationship:
Greatest Common Devisor (GCD)
GCD/GCF
• The greatest common factor (GCF) or greatest common divisor
(GCD), is the greatest factor that divides two or more numbers
without a reminder.
• To find the GCF of two numbers: List the prime factors of each
number. Multiply those factors both numbers have in common. If
there are no common prime factors, the GCF is 1.
• For example, the gcd of 8 and 12 is 4 or gcd(8,12)=4
• gcd(54,24)=6
Greatest Common Divisor
GCD (24, 40) = 8
GCD (18, 21) = 3

a) 7, 15, 21
b) 18, 36, 45
c) 10, 45
Finding GCD of large numbers
• gcd(10,45)
• gcd(1701,3768)
• gcd(1160718174,316258250)
The Euclidean Algorithm
The Euclidean Algorithm is a technique for quickly finding the GCD of two integers.
GCD using Euclidean Algorithm

gcd(10,45)=5
gcd(1701,3768)=3
GCF/GCD/HCF of a large number
Prime Numbers
Prime Numbers and Cryptography
• Prime numbers should be two factors. i.e. factors are one and itself.
• Prime numbers are whole numbers and should be greater than one. The first
few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29.
• Most modern computer cryptography works by using the prime factors of
large numbers.
• Primes are important because the security of many encryption algorithms are
based on the fact that it is very fast to multiply two large prime numbers and
get the result, while it is extremely computer-intensive to do the reverse -
meaning: take a very large number, given which it has only two prime factors,
and find them. e.g. 19x31=589
• Primes are used in several routines in information technology, such as public-key
cryptography, which relies on the difficulty of factoring large numbers into their
prime factors.
Fundamental Theorem of Arithmetic
In number theory, the fundamental theorem of arithmetic, also called the unique factorization theorem
or the unique-prime-factorization theorem, states that every integer greater than 1 either is a prime
number itself or can be represented as the product of prime numbers
Prime Factors
Questions??
• Is 51 a prime number?
• Is 89 a prime number?
• Why prime numbers are important in cryptography?
Modular Arithmetic
The Modulus
Modular Arithmetic
• Modular arithmetic is a system of arithmetic for integers, where
numbers "wrap around" upon reaching a certain value the modulus.
• In Modular arithmetic we count in a circle.
• For example, “5 mod 3 = 2” which means 2 is the remainder when
you divide 5 by 3.
Clock Math
• We’ve already been using it for keeping time — sometimes called
“clock arithmetic”.
• The equation “14 mod 12 = 2 mod 12” means, “14 o’clock” and “2
o’clock” look the same on a 12-hour clock. They are congruent,
indicated by a triple-equals sign: 14 ≡ 2 mod 12.

This says that A is congruent to B modulo C.


Modulo in Cryptography
• Modulo is used in Diffie-Hellman Key Exchange — used in setting up
SSL connections to encrypt web traffic.
• Used in RSA

• Modulo in Cesar Cipher


Fermat’s and Euler’s Theorems
Two theorems that play important roles in public-key cryptography
Relatively Prime Numbers
• Two integers are relatively prime if there is no integer greater than
one that divides them both.
• Relative Prime numbers do not share any common factor.
• For example, 12 and 13 are relatively prime, but 12 and 14 are not.

Factors of 12= 1,2,3,4,6,12


Factors of 13=1,13

Question: Are 8 and 15 relatively prime numbers?


Euler’s Totient Function
• Euler’s totient function, written (n), is defined as the number of positive integers less than n and relatively prime
to n.
By convention, (1) = 1

Find
Fermat’s Theorem
Euler’s Theorem
Discrete Logarithm
Discrete Logarithms
• Discrete logarithms are fundamental to a number of public-key
algorithms, including Diffie–Hellman key exchange and the Digital
Signature Algorithm (DSA).
• With ordinary positive real numbers, the logarithm function is the
inverse of the exponential function. An analogous function exists for
modular arithmetic.
• So, the logarithm tells you the exponent.
Logarithms for Modular Arithmetic
ONEWAY FUNCTION - Easy to perform and hard to reverse
Review Questions – Number Theory for Crypto
1- Find the greatest common factor of the following: 3- Describe Modulus and Logarithmic functions and calculate
a) 7, 15, 21
values of following modulus and Logarithmic functions:
b) 18, 36, 45 • −9 mod 6
c) 10, 45 • 17 mod 7
d) 1701,3768 • −17 mod 7
e) 1160718174,316258250 • −29 mod 4
• 29 mod 4
2- Define Tutient Function and find value of the following Euler’s Totient • -7 mod 6
Functions:
a) (37)
b) (35) • log2 4
c) (234) • log2​ 128
d) (149) • log3 343
• dlog6,5​ 216
4- Write a program for finding GCD of a large number • dlog10,12 ​1,000,000
https://www.geeksforgeeks.org/gcd-of-two-numbers-when-one-of-them-
can-be-very-large-2/

You might also like