Course: Cryptography and Network Security
Branch: B.Tech
Lecture – 2: Euclidean and Extended Euclidean Algorithms
Department of Computer Science and Engineering
Motilal Nehru National Institute of Technology Allahabad,
Prayagraj-211004
Integer Arithmetic
• In integer arithmetic, we use a set and a few operations.
• Reviewed here to create a background for modular arithmetic.
• The set of integers, denoted by Z, contains all integral numbers (with
no fraction) from negative infinity to positive infinity
Binary Operations
• In cryptography, we are interested in three binary operations applied
to the set of integers.
• A binary operation takes two inputs and creates one output.
Example #1
Integer Division
• In integer arithmetic, if we divide a by n, we can get q and r.
• The relationship between these four integers can be shown as
Example #2
Integer Division
Integer Division
• When we use a computer or a calculator, r and q are negative
when a is negative.
• How can we apply the restriction that r needs to be positive?
• The solution is simple, we decrement the value of q by 1 and
we add the value of n to r to make it positive.
Integer Division
• Graph of division algorithm
Divisibility
• If a is not zero and we let r = 0 in the division relation, we get
• If the remainder is zero, n | a
• If the remainder is not zero, n | a
Example #3
Divisibility
• Properties
Divisibility
Divisibility
Divisibility
Example #4
Divisibility
Divisibility
Example #5
Divisibility
Class Exercise #1
Divisibility
• Extended Euclidean Algorithm
Given two integers a and b, we often need to find other two
integers, s and t, such that
The extended Euclidean algorithm can calculate the gcd (a, b)
and at the same time calculate the value of s and t.
Divisibility
Divisibility
• It is left Intentionally blank
Divisibility
Divisibility
Divisibility
Divisibility
Assignment #1
• Explore and Investigate the following and submit a report by clearly
mentioned your name and registration number in MS Word
• WhatsApp End to End Encryption Algorithm
• Security and Privacy Features in WhatsApp
• Internet Banking of your respective accounts