0% found this document useful (0 votes)
159 views24 pages

Unit-1 - Part-II

This document discusses fundamental concepts in mathematics relevant to cryptography. It begins by defining integer arithmetic and operations like addition, subtraction, multiplication, and division. It then covers modular arithmetic, including the modulo operator, sets of residues, and congruence. Key algorithms like the Euclidean algorithm for finding the greatest common divisor and the extended Euclidean algorithm are also summarized. The document concludes by introducing linear Diophantine equations and their solutions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views24 pages

Unit-1 - Part-II

This document discusses fundamental concepts in mathematics relevant to cryptography. It begins by defining integer arithmetic and operations like addition, subtraction, multiplication, and division. It then covers modular arithmetic, including the modulo operator, sets of residues, and congruence. Key algorithms like the Euclidean algorithm for finding the greatest common divisor and the extended Euclidean algorithm are also summarized. The document concludes by introducing linear Diophantine equations and their solutions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

UNIT – I – Part - II

Syllabus: Mathematics of Cryptography: Integer Arithmetic, the extended Euclidean


Algorithm, Modular Arithmetic, Matrices, Linear Congruence.
Algebraic Structures, Basics of Groups, Rings, Prime numbers.

Mathematics of Cryptography

Integer Arithmetic: In Integer arithmetic, we use a set and a few operations.

Set of Integers: The set of Integers, denoted by z, contains all integral numbers (with no
fraction) from negative infinity to positive infinity.

Z= {………,-4-3,-2,-1,0,1,2,3,4………}
Binary Operations: A Binary operation takes two inputs and creates one output. Three
common binary operations defined for integers are addition, subtraction and
multiplication.

Z= {………,-4-3,-2,-1,0,1,2,3,4………}

a b
+-x
c
Z= {………,-4-3,-2,-1,0,1,2,3,4………}
Examples:
Add: 5+9=14 (-5)+9=4 5+(-9)=-4
Subtract: 5-9=-4 (-5)-9=14 5-(-9)=14
Multiply: 5x9=45 (-5)x9=-45 5x(-9)=45

Integer Division: if we divide a by n, we get q and r. The relationship between these


four integers can be shown as
a=q x n + r
a is dividend, n is the divisor, q is quotient , r is remainder
Examples: Assume that a = 255 and n = 11. We can find q = 23 and r = 2
Dr. Ram Prasad Reddy Sadi Page 1
UNIT – I – Part - II

using the division algorithm. We have shown in following

Two Restrictions:
• First, we require that the divisor be a positive integer (n > 0).
• Second, we require that the remainder be a non-negative integer ( r > 0 ).
Integer Division

Examples: Assume r and q are negative when „a‟ is negative.


 To make r positive, decrement q by 1 and add value of n tor
 consider -255=(-23x 11) +(-2) ↔ -255=(-24x11)+9
 We have decremented -23 to -24 and added 11 to -2 to make 9. The relation is
still valid
Divisibility:
 If a is not zero and we let r = 0 in the division relation, we get a = q x n
 We then say that n divides a ( or n is a divisor of a ). We can also say that a is
divisible by n.
 The above is n | a .
 If the remainder is not zero, then n does not divide a and we can write the
relationship as a + n.
Properties
 If a | 1, then a= ± 1
 If a | b and b | a, then a= ± b
 If a | b and b | c, then a | c
 If a | b and a | c, then a | (m x b + n x c), where m and c are arbitrary integers

Examples: The integer 4 divides the integer 32 because 32 = 8 x 4. We show this is as 4 |


32
The number 8 does not divide the number 42 because 42 = 5 x 8 + 2. There is a remainder,
the number 2, in the equation.
We show this as 8 + 42.
Examples: The integer 4 divides the integer 32 because 32 = 8 x 4. We show this is as 4 |
Dr. Ram Prasad Reddy Sadi Page 2
UNIT – I – Part - II

32
The number 8 does not divide the number 42 because 42 = 5 x 8 + 2. There is a remainder,
the number 2, in the equation.
We show this as 8 + 42. Examples:
1) Since 3 | 15 and 15 | 45, according to third property, 3 | 45
2) Since 3 | 15 and 3 | 9, according to the fourth property, 3 |(15 x 2 + 9 x 4), which
means 3 | 66.

Greatest Common Divisor(GCD)


The greatest common divisor of two positive integers is the largest integer that can
divide both integers we can write the relationship as a + n.
Examples: GCD of 15 and 20 is 2 because divisors of 15 are 3,5 and divisors of 20 are
2,4,5,10. The GCD is 5

Euclidean Algorithm:
Euclidean algorithm is used to finding the greatest common divisor (gcd) of two
positive integers. The Euclidean algorithm is based on the following two facts
 Fact 1: gcd ( a, 0 ) = a
 Fact 2: gcd ( a, b ) = gcd ( b , r ), where r is the remainder of dividing a
by b
 When gcd ( a, b ) = 1, we say that a and b are relatively prime.

Example: gcd ( 36, 10 ) = ?

Example: gcd (2740,1760) = ?


Solution: we initialize r1 to 2740 and r2 to 1760
Answer:
gcd ( 2740, 1760 ) = 20

Dr. Ram Prasad Reddy Sadi Page 3


UNIT – I – Part - II

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 if s and t.

Example: Given a = 161 and b = 28, Find gcd (a,b) and the values of s and t.
Solution:
r = r1 – q x r2 , t = t1 – q x t2 , s = s1 – q x s2 , We use a table to follow the algorithm.

Dr. Ram Prasad Reddy Sadi Page 4


UNIT – I – Part - II

We get gcd (161,28) = 7, s=-1 and t = 6

Linear Diophantine Equations


An equation of type ax + by = c with variables is called as Linear Diophantine Equation.
The Extended Euclidean algorithm is used to find solutions to the Linear Diophantine
Equations This type of equation has either no solution or an infinite number of solutions.
Let d = gcd(a,b). if d + c, then the equation has no solution.
If d | c, then we have an infinite number of solutions. (one is particular and rest are
general solutions). Particular Solution: if d | c, a particular solution to the above equation
can be found using the following steps:
 Reduce the equation to a1x + b1y = c1 by dividing both sides of the equation
by d. This is possible because d divides a, b, and c by the assumption.
 Solve for s and t in the relation a1s + b1t = 1 using the extended Euclidean
algorithm.
 The particular solution: x0 = (c/d)s and y0 = (c/d)t
General Solutions: after finding the particular solution, the general solutions can be
found: x = x0 + k (b/d) and
y = y0 – k (a/d) where k is an integer
Example: Find the particular and general solutions to the equation
21x + 14y = 35.
Given equation, 21x+14y = 35 that is written as ax+by = c a=21, b=14, c=35
d = gcd(a,b) = gcd(21,14) [ Apply Euclidean Algorithm ]
= gcd (14,7) 1.gcd(a,0) = a
= gcd (7,0)=7 2.gcd( a,b) =gcd(b,r)
so, d=7 where ‟r‟ remainder
Note: if d | c i.e 7|35 (7divides 35), so one is Particular solution and infinity General
solutions.
Particular Solution:
21x+14y= 35 1

Divide both sides by 7 in 1 , then

3x + 2y = 5 2

using Extended Euclidean Algorithm , find “s” and “t”


such as 3s+2t = 1 Ref. (s x a + t x b = gcd (a,b))
Find gcd (3, 2) where r1 is 3 and r2 is 2 using Extended
Euclidean Algorithm r = r1 - r2 x q , s= s1 - s2 x q ,
t= t1 - t2 x q

Dr. Ram Prasad Reddy Sadi Page 5


UNIT – I – Part - II

as per particular solutions x0 = (c/d)s and y0 = (c/d)t


substitute values a=21,b=14 , c=35, d=7 for x0 and y0 x0 = (35/7)x 1= 5
y0 = (35/7)(-1)= - 5
General Solution:
x = x0 + k (b/d) and y = y0 – k (a/d) where k is an integer
x = 5+k(14/7) ; y = -5-k(21/7)
x = 5+2k y = -5-3k
here “k” is an integer ; k=0,1,2,3,4… then substitute k in above:
(5,-5), (7,-8),(9,-11), ........... are solutions to given equation

Modular Arithmetic
The division relationship ( a = q x n + r ) has two inputs ( a and n ) and two outputs ( q
and r ). In modular arithmetic, we are focused in only one of the outputs, the remainder r.
Modulo Operator:
 Modulo operator is shown as mod.
 The second input (n) is called the modulus.
 The output r is called the residue.
The below figure shows the division relation compared to the modulo operator

The modulo operator (mod) takes an integer (a) from the set Z and a positive modulus
(n). The operator creates a non-negative residue (r).
a mod n = r
Example

Dr. Ram Prasad Reddy Sadi Page 6


UNIT – I – Part - II

SET OF RESIDUES: Zn
The result of the modulo operation with modulus „n‟ is always an integer between 0 and
n-1. In other words (a mod n) is always a non-negative integer less than n
Modulus operation creates a set, that is called set of least residues modulo n or Z n
We have one set of Z(integers), but we have infinite instances of the set o residues Z n for
each n.

CONGRUENCE (≡)
If two numbers A and B have the property that their difference A-B is integrally
divisible by a number C (i.e., (A-B)/C is an integer), then A and B are said to be
"congruent modulo C." The number C is called the modulus, and the statement "A is
congruent to B (modulo C)" is written mathematically as
A ≡ B ( mod C)
This says that “ A is congruent to B modulo C”.

Example 2:
Assume, -8≡12(mod 10) 2≡12(mod 10) 12≡22(mod 10) 22≡32(mod 10)

Residue classes
A residue class [a] is the set of integers congruent modulo n. In other words it is the set of

Dr. Ram Prasad Reddy Sadi Page 7


UNIT – I – Part - II

all integers such that x=a (mod n).


For example, if n=5, we have five sets [0], [1], [2], [3], [4] as shown below
[0]= { ...., -15 -10 ,-5, 0, 5, 10,15,...}
[1]= { ...., -16 -11 ,-6, 1, 6, 11,16,...}
[2]= { ...., -17 -12 ,-7, 2, 7, 12,17,...}
[3]= { ...., -18 -13 ,-8, 3, 8, 13,18,...}
[4]= { ...., -19 -14 ,-9, 4, 9, 14,19,...}
From each set there is one lease residue that
0 in [0], 1 in [1], 2 in
[2], 3 in[3] and 4 in
[4].. The set of these
residues are shown as
Z5 ={0,1,2,3,4}
Operations in Zn
The three Binary operations (addition, subtraction and multiplication) are defined for the
set Z n.

Dr. Ram Prasad Reddy Sadi Page 8


UNIT – I – Part - II

Example 2
Perform the following operation:
a. Add 17 to 27 in Z14
(17+27) mod 14 = (44) mod 14 = 2
b. Subtract 34 from 12 in Z13
(12-34) mod 13 = (-22) mod 13 = - 9 = (-9+13) = 4
c. Multiply 123 by -10 in Z20
(123*(-10)) mod 20 = (-1230) mod 20 = -10 =(-10+20) = 10

Property 1:
(a+b) mod n= [ (a mod n )
+ (b mod n) ] mod n (4+5)
mod 2 = [ (4 mod 2) + ( 5
mod 2) ] mod 2
9 mod 2 = [0 + 1] mod 2
1 = 1
Property 2:
(a-b) mod n= [ (a mod n ) - (b mod n) ] mod n
(4 - 5) mod 2 = [ (4 mod 2) - ( 5 mod 2) ] mod 2
-1 mod 2 = [0 - 1] mod 2
-1 mod 2 = -1 mod 2
Property 3:
(axb) mod n= [ (a mod n ) x (b mod n) ] mod n (4 x 5) mod 2 = [ (4 mod 2) x ( 5 mod
2) ] mod 2
20 mod 2 = [0 x 1] mod 2
0 = 0 mod 2
0 = 0
Inverses
When we are working in modular arithmetic, we need to find inverse of a number
relative to an operation. There are two types of inverses are used modular arithmetic.
 Additive inverse (relative to an addition operation).
 Multiplicative inverse (relative to a multiplication operation).

Note: In modular arithmetic, each integer has an additive inverse.

Dr. Ram Prasad Reddy Sadi Page 9


UNIT – I – Part - II

• The sum of an integer and its additive inverse is congruent to 0 modulo n

It can be proved that „a‟ has a multiplicative inverse in Zn iff gcd(n,a)=1. (In this case „a‟
and n are said to relatively prime.
Example 1: Find multiplicative inverse of 8 in Z10.

Example 2: Find all multiplicative inverses in Z10.

Example 3: Find all multiplicative inverses 23 in Z100.

Dr. Ram Prasad Reddy Sadi Page 10


UNIT – I – Part - II

Addition and Multiplication Tables


In addition table, each integer has an additive inverse. The inverse pairs can be found when
the result of addition is zero. In Figure 2.16, we have (0,0), (1,9), (2,8), (3,7), (4,6), and (5,5).
In multiplication table, the pairs can be found whenever the result of multiplication is 1. In
Figure, we have (1,1), (3,7) and (9,9).

Fig: Addition and multiplication tables in Z10


Note: We need to use Zn when additive inverses are needed; we need to use
Z*n when multiplicative inverses are needed.
Two more Sets:
Cryptography often uses two more sets: Zp and Z*p.

Matrices
A matrix is a rectangular array of l x m elements; in which l is the number of rows and
m is the number of columns.
A matrix is normally denoted with an Uppercase Letter such as A. The element aij is
located in the ith row and jth column.

Dr. Ram Prasad Reddy Sadi Page 11


UNIT – I – Part - II

Different Types of Matrices

Operations and Relations


Relation operation:
Equality:
If two matrices are equal sized and content is same then they have equality.
Four operations:
1. Addition
2. Subtraction
3. Multiplication
4. Scalar multiplication
Examples:
Addition : CIJ=AIJ+ BIJ

Subtraction: : CIJ=AIJ - BIJ

Multiplication

Examples:

Dr. Ram Prasad Reddy Sadi Page 12


UNIT – I – Part - II

Multiplication unit matrix with normal matrix gives the same matrix
AXI=IXA=A

DETERMINANT
If A is square matrix of mxm then determinant of A is det(A)

Where Aij is a matrix obtained from A by deleting the ith row and jth column.
Determinant is obtained for only square matrices
Det(2x2) matrix

Example : det(3x3) matrix

Dr. Ram Prasad Reddy Sadi Page 13


UNIT – I – Part - II

MATRICES-Inverses
Additive Inverse
The additive inverse of the matrix A is another matrix B such that A+B=0. In other words
bij=-aij
Generally additive inverse is of A=-A Multiplicative Inverse:
The multiplicative Inverse of a square matrix A is a B such that A X B = I. Normally
Multiplicative inverse of A is defined by A-1
Note: Multiplicative inverse is defined for only square matrices

Residue Matrices

Dr. Ram Prasad Reddy Sadi Page 14


UNIT – I – Part - II

Example: Find A-1 modulo value.


Problem:

Solution:

Dr. Ram Prasad Reddy Sadi Page 15


UNIT – I – Part - II

Linear Congruence
Single variable Linear Equations:
Equations of the form ax ≡ b (mod n) might have no solution or a limited number of
solutions
Assume that the gcd(a,n) = d.
If d + b (d not divides b), there is no solution. If d | b (d divides b), there are d solutions.
If d | b, we use the following strategy to find the solutions:
Reduce the equation by dividing both sides of the equation (including the modulus) by d.
Multiply both sides of the reduced equation by the multiplicative inverse of „a‟ to find the
particular solution x0.
The General solutions are x = x0 + k ( n / d ) for k = 0, 1, 2, , (d-1). Congruence-Example
Example 1: Solve the equation
10 x = 2( mod 15).
Solution :-
Given Linear equation 10x≡ 2(mod 15) In basic form ax ≡ b(mod n)
a = 10 ; b = 2; n= 15
Now, find d = ?
d = gcd(a,n)= gcd (10,15)
= gcd (15,10) = gcd (10,5)
= gcd (5,0)
=5
check if d+b (d not divides b), then no solution 5+2 means „5‟ not divides „2‟, so, The
given equation has No solution.
Example 2: Solve the equation
14 x= 12 (mod 18) Solution :- Given Linear equation
14x ≡ 12(mod 18) In basic form ax ≡ b(mod n)
a = 14 ; b = 12; n= 18
d = gcd(a,n)= gcd (14,18) = gcd (18,14)
= gcd (14,4) = gcd (4,2)=gcd(2,0)=2 check, d b or d+ b
d|b→ 2 | 12 means “ 2 divides 12”, so the given equation have “2 solutions”.

Given equation 14 x 12 (mod 18)


divides „d‟ on both sides of equation
7x 6 (mod 9)
multiply 7 -1 on both sides of above to get particular solution „x0‟.
7 -1 x 7 * x0 ≡ 6 * 7 -1 (mod 9)
x0 ≡ 6x 7 -1 (mod 9) i.e 7-1 mod 9 ≡ 4
x0 ≡ 6 x 4 (mod 9)
x0 ≡ 24 mod 9
x0 ≡ 6
solutions are x = x0 + k (n/d) where k = 0,1
( d = 2)
if k = 0 x = x0 + 0 (n/ d) x = 6+ 0 ( 18/2) = 6
x=6
if k = 1 x = x0 +1 ((n/ d) = 6+1 ( 18/2)
x = 15
„6‟ and „15‟ are solution to 14 x 12 (mod 18)

Dr. Ram Prasad Reddy Sadi Page 16


UNIT – I – Part - II

Algebraic Structures
Cryptography requires set of integers and specific operations that are defined for those
sets. The combination of the set and the operations that are applied to the elements of the
set is called an algebraic structure.

Basics of Groups
A Group (G) is a set elements with a binary operation “ ” usually Addition or
multiplication that satisfies four properties(Axioms).
A Commutative Group, also called an abelian group, is a group in which the operator
satisfies the four properties for groups plus an extra property, commutativity.
 Closure Property: if a and b are elements of G, then c = a b is also an element
of G.
 Associatively Property: if a, b, and c are elements of “G, then ( a b ) c = a
( b c ).
 Existence of Identity Property: For all a in G, there exists an element e, called
the identity element, such that e a=a e=a
 Existence of Inverse Property: For each a in G, there exists an element a1, called the
1
inverse of a, such that = a1
 Commutativity Property: For all a and b in G,

Example 1
The set of residue integers with the addition operator, G=< Zn , + >, is a commutative group

Dr. Ram Prasad Reddy Sadi Page 17


UNIT – I – Part - II

1. Closure is satisfied. The result of adding two integers in Zn is another integer in Zn


2.Associativity is satisfied. The result of 4+(3+2) is same as (4+3) + 2
3. Commutative is satisfied. we have 3+4=4+3 4.The identity element is 0. we have
3+0=0+3=3
5. Every element has an additive inverse. The inverse of 3 is 7 (3+7 mod 10 =0 mod 10 in
Z10) and inverse of 7 is 3( 7+3 mod 10 =0 mod 10 in Z10), so inverse property satisfied

Example 2
The set Zn* with multiplication operator, G=<Zn*, x >, is also an abelian group. We can
perform multiplication and divisions on the elements. We an identity element as 1.

Finite Group: A group is called a finite group if the set has a finite number of elements;
otherwise, it is an infinite group.

Order of a Group: The order of group, |G|, is the number of elements in the group. If the
group is not finite, its order is infinite; if the group is finite, the order is finite.

Subgroups: A subset H of a group G is a subgroup of G if H itself is a group with respect to


the operation on G. In other words, if G = <S, > is a group, H = <T, > is a group under
the same operation, and T is a non-empty subset of S, then H is a subgroup of G. The above
definition implies that:
1. If a and b are members of both groups, then c=a b is also a member of both groups
2. The group share the same identity element
3. If a is a member of both groups, the inverse of a is also a member of both groups
4. The group made with the identity element of G,H=<{e}, >, is a sub group of G
5. Each group is a subgroup of itself

Cyclic Subgroup: If a subgroup of a group can be generated using the power of an element,
the subgroup is called the cyclic subgroup.
The term power means repeatedly applying the group operation to the element:
an -> a.a.a.a a (n times)

Example: The group G=< Z3, + > contains cyclic subgroups for 0,1 and 2: If generated using
0:
00 mod 3 = 0, 01 mod 3 = 0, 02 mod 3 = 0. so, H1=<{0}, +>
If generated using 1:
10 mod 3 = 0, 11 mod 3 = 1, 12 mod 3 = (1+1) mod 3=2. so, H2=G If generated using 2:
20 mod 3 = 0, 21 mod 3 = 2, 22 mod 3 = (2+2) mod 3=1. so, H3=G

Cyclic Group: A Cyclic group is a group that is its own cyclic subgroup. The element that
generates cyclic subgroup can also generates group itself.This element is referred as
generator „g‟.
Example: In the previous example, The group G=<Z3, +> is a cyclic grop with two
generators g=1 and g=2

Dr. Ram Prasad Reddy Sadi Page 18


UNIT – I – Part - II

Lagrange’s Theorem:
It related the order of a group to the order of its sub group. Assme that G is group and H is its
subgroup. If order of G and H are |G| and |H|, respectively, based on this theorem |H| divides
|G|.

Example: As per the previous cyclic subgroup example, |H1|=1, |H2|=3, |H3|=3, Obviously,
all of these orders divide the order of |G|.

Example:
In the group G=<Z3, +>, ord(0)=1, ord(1)=3, ord(2)=3
Rings
A Ring, denoted as R = < {. }, , □ >, is an algebraic structure with two
operations(addition and multiplication).
The first operation must satisfy all five properties required for an abelian group. The second
operation must satisfy only the first two.
In addition, the second operation must be distributed over the first operation.

Distributivity means that for all a, b and c elements of R, we have


a ( b c ) = ( a b ) ( a c ) and ( a b ) c = ( a c ) ( b c)

Commutative Ring: If a ring satisfies commutative property, then we say the ring is a
commutative ring.
• Rings do not need to have a multiplicative inverse.

Example: Z an Integer set is a Ring structure. Explain why Z (set of Integer numbers) is
a ring?
Suppose that 2,3,4∈Z.
Dr. Ram Prasad Reddy Sadi Page 19
UNIT – I – Part - II

• Both addition and multiplication are associative since


2+(3+4)=(2+3)+4, and 2(3x4)=(2x3)4.
• It follows that
The identity element for addition is 0 since, 2+0=2.
The identity element for multiplication is 1 since 1x2=2.
• Addition is commutative too since 2+3=3+2 Multiplication is also commutative since
2x3=3x2, so, Z can be called a commutative ring).
Addition has the inverse of -2 since 2+(−2)=0
(Note that multiplication does not need to have a multiplicative inverse. Because
multiplicative inverse of 2 is ½. It is not an integer.
Lastly, multiplication also distributes over addition, that is 2(3+4)=2x3+2x4.
Rings do not need to have a multiplicative inverse.

Prime numbers
Asymmetric-key cryptography uses prime numbers extensively. A prime is divisible only by
itself and 1.

Example 1:
What is the smallest prime?
The smallest prime is 2, which is divisible by 2 (itself) and 1.
Example 2:
List the primes smaller than 10.
There are four primes less than 10: 2, 3, 5, and 7. It is interesting to note that the percentage
of primes in the range 1 to 10 is 40%. The percentage decreases as the range increases.
Cardinality of Primes
We can use infinite Number of Primes.
Number of Primes
π(x) is the number of primes less than or equal to x. π is not similar to mathematics π.
The primes under 25 are 2, 3, 5, 7, 11, 13, 17, 19 and 23 so π(3) = 2, π(10) = 4 and π(25)
= 9.

A Table of values of π(x)

Dr. Ram Prasad Reddy Sadi Page 20


UNIT – I – Part - II

Example 1
Find the number of primes less than 1,000,000.
The approximation gives the range 72,383 to 78,543.
The actual number of primes is 78,498.
Checking for Primeness
Given a number n, how can we determine if n is a prime? The answer is that we need to
see if the number is divisible by all primes less than

We know that this method is inefficient, but it is a good start.

Example 1:
Is 97 a prime?
The floor of π(97) = 9. The primes less than 9 are 2, 3, 5, and 7. We need to see if 97 is
divisible by any of these numbers. It is not, so 97 is a prime.
Example 2:
Is 301 a prime?
The floor of π(301) = 17. We need to check 2, 3, 5, 7, 11, 13, and 17. The numbers 2, 3,
and 5 do not divide 301, but 7 does. Therefore 301 is not a prime.
Fermat’s Little Theorem
First Version: if p is prime and a is positive integer, then
ap − 1 ≡ 1 mod p
Second Version:
ap ≡ a mod p
This means that if we divide ap by p then the remainder should be „a‟.
Example 1:
Find the result of 610 mod 11.

Dr. Ram Prasad Reddy Sadi Page 21


UNIT – I – Part - II

We have 610 mod 11 = 1. This is the first version of Fermat‟s


little theorem where p = 11. Example 2
Find the result of 312 mod 11.
Here the exponent (12) and the modulus (11) are not the same. With substitution this
can be solved using Fermat‟s little theorem.

Multiplicative Inverses
a−1 mod p = a p − 2 mod p
Example
The answers to multiplicative inverses modulo a prime can be found without using
the extended Euclidean algorithm:

Example:
How to calculate multiplicative inverse of 5 modulo 23 that is 5-1 mod 23?
Solution:
1. 5-1 mod 23 = 523-2 mod 23 (Ref: a-1 mod p= ap-2 mod p)
2. 523-2 mod 23 = 521 mod 23
3. Calculate following to solve 521 mod 23:
51 mod 23 = 5
52 mod 23=25 mod 23=2
54 mod 23= (52)2 mod 23= (2)2 mod 23=4
58 mod 23= (54)2 mod 23 (4)2 mod 23=16
516 mod 23= (58)2 mod 23 (16)2 mod23=256 mod 23=3
Now binary equivalence of 21 is 10101, so multiply 51 , 54 and 516 values, leave 52 and 58
because these are
0‟s in binary form.
521 mod 23 = (516 x 54 x 51 ) mod 23=(3x4x5) mod 23=60 mod 23= 14 mod 23.
Finally 5-1 mod 23 = 521 mod 23 = 14 mod 23

Euler's totient function


Euler's totient function, also known as phi-function ϕ(n), this function counts the number of
integers that are both smaller than n and relatively prime to n (coprime). Two numbers are
coprime if their greatest common divisor equals 1.
Here are values of ϕ(n) for the first few positive integers:
Dr. Ram Prasad Reddy Sadi Page 22
UNIT – I – Part - II

Example: Find co-primes of 9?


If we check gcd(9,1), gcd(9,2), gcd(9,4), gcd(9,5), gcd(9,7), gcd(9,8) =1,
So, coprimes to 9 are 1,2,4,5,7,8 and their count ϕ(9)=6
Properties
• ϕ(1)=0
• If p is a prime number, ϕ(p)=p−1
• If a and b are relatively prime, then: ϕ(ab)=ϕ(a)⋅ϕ(b).
• If p is a prime, ϕ(pe)=pe - pe-1
Examples:
1) Find ϕ(7)?
ϕ(7)=7-1=6
2) Find ϕ(21)?
ϕ(21)= ϕ(3x7) = ϕ(3)x ϕ(7)=2x6=12
3) Find ϕ(77)?
ϕ(77)= ϕ(7x11) = ϕ(7)x ϕ(11)=6x10=60
4) Find ϕ(32)?
ϕ(32)= (32)- (32-1) = 9-3=6
5) What is the value of ϕ (13)?
Because 13 is a prime, ϕ (13) = (13 −1) = 12.
6) What is the value of ϕ (10)?
We can use the third rule: ϕ (10) = ϕ (2) × ϕ (5) = 1 × 4 = 4,
because 2 and 5 are primes. 7)What is the value of ϕ (240)?
7) We can write 240 = 24 × 31 × 51. Then
i. ϕ (240) = (24 −23) × (31 − 30) × (51 − 50) = 64
8) Can we say that ϕ (49) = ϕ (7) × ϕ (7) = 6 × 6 = 36?
No. The third rule applies when m and n are relatively prime. Here 49 = 72. We need to
use the fourth rule: ϕ
(49) = 72 − 71 = 42.
9) What is the number of elements in Z14*?
The answer is ϕ (14) = ϕ (7) × ϕ (2) = 6 × 1 = 6. The members are 1, 3, 5, 9, 11, and 13.

Note: Interesting point: If n > 2, the value of f(n) is even.

Euler’s Theorem
First Version:For every a and n, they are relatively prime then
Dr. Ram Prasad Reddy Sadi Page 23
UNIT – I – Part - II

a ϕ(n) ≡ 1 (mod n)
Second Version
a k × f(n) + 1 ≡ a (mod n)
Note: The second version of Euler‟s theorem is used in the RSA cryptosystem.

Example 2:
Find the result of 624 mod 35.
Solution
We have 624 mod 35 = 6 ϕ (35) mod 35 = 1.
Example :
Find 34 mod 10 ?
Solution

Example 3:
Find the result of 2062 mod 77. Solution
If we let k = 1 on the second version, we have f(77)= f(7)x f(11)=6x10=60
2062 mod 77 = (20 mod 77) (2060+1 mod 77) mod 77=
(20 mod 77) (20f(77) + 1 mod 77) mod 77
= (20)(20) mod 77 = 15.
Multiplicative Inverses
Euler‟s theorem can be used to find multiplicative inverses modulo a composite.

Example:
The answers to multiplicative inverses modulo a composite can be found without
using the extended Euclidean algorithm if we know the factorization of the composite:

Dr. Ram Prasad Reddy Sadi Page 24

You might also like