Module 1
Module 1
Guidelines to be followed
BCSE309L
Cryptography and Network Security 1. Be on time for class.
2. Be attentive and clarify your doubts immediately.
3. Don’t indulge in other actives when the class is in progress.
By,
Dr.Swetha.N.G., 4. Complete the Assignments/Quiz within the deadline provided.
Assistant Professor Senior, 5. Maintain a dedicated notebook in class.
Department of Analytics,
School of Computer Science and Engineering,
Vellore Institute of Technology, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 1 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Modules Books
Module 1: Fundamentals of Number Theory Recommended Text Book
Module 2: Symmetric Encryption Algorithms 1. Cryptography and Network Security-Principles and Practice, 8th
Module 3: Asymmetric Encryption Algorithm and Key Exchange Edition, by Stallings William, published by Pearson, 2020.
Module 4: Message Digest and Hash Functions Reference Books
Module 5: Digital Signature and Authentication Protocols 1. Cryptography and Network Security, 3rd Edition, by Behrouz A
Forouzan and Depdeep Mukhopadhyay, published by McGrawHill,
Module 6: Transport Layer Security and IP Security 2015.
Module 7: E-mail, Web and System Security
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 2 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 3 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
a=q×n+r
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 4 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
-
+
-
-
-
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 5 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Integer Division
Integer Division
• Assume that a = -255 and n = 11.
• We can find q = -23 and r = -2 using the division algorithm.
- Conversion:
q = q-1
- r = r+n
+
-
q=-23 -23-1 = -24
- r= -2 -2+11 = 9
a = (q x n) + r
-
-255 = (-24 x 11) + 9
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 6 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 7 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
eg GCD(60,24) = 12
• Mathematical Definition
• gcd(a, b) = max[k, such that k|a and k|b]
• We define gcd(0, 0) = 0
• we require that the greatest common divisor be positive,
• We define gcd(a,0) = |a| • gcd(a,b) = gcd(a,-b) = gcd(-a,b) = gcd(-a,-b)
• When gcd(a,b)=1, it implies that there are no common divisor except 1. • In general, gcd(a,b) = gcd(|a|,|b|)
• So, a and b are said to be relatively prime to each other. • Eg: gcd(60,-24) = gcd(60,24) = 12
• Eg: gcd(8,15)=1 • gcd (a, b) = gcd (b, r), where r is the remainder of dividing a by b
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
q r1 r2 r
Divide 25/60 = 0.4166
0 25 60 25
q=0
r = 25 (0.416*60)
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 8 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
q r1 r2 r q r1 r2 r
Divide 60/25 = 2.4 Divide 25/10 = 2.5
0 25 60 25 0 25 60 25
q=2 q=2
2 60 25 10 2 60 25 10
r = 10 (0.4*25) r = 5 (0.5*10)
2 25 10 5
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
q r1 r2 r q r1 r2 r
Divide 10/5 = 2 When r2=0
0 25 60 25 0 25 60 25
q=2 Stop
2 60 25 10 2 60 25 10
r=0
2 25 10 5 2 25 10 5
2 10 5 0 2 10 5 0
5 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 9 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
q r1 r2 r
0 25 60 25
2 60 25 10 GCD(25,60)=5
2 25 10 5
2 10 5 0
5 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Euclidean Algorithm
Euclidean Algorithm
• gcd(1160718174, 316258250)=?
• Find the greatest common divisor of 2740 and 1760.
q r1 r2 r
1 2740 1760 980
1 1760 980 780 GCD(2740,1760)=20
1 980 780 200
3 780 200 180
1 200 180 20
9 180 20 0
20 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 10 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
q r1 r2 r
Homework
3 1160718174 316258250 211943424
1 316258250 211943424 104314826
• GCD(1970,1066) = ? Answer: 2
2 211943424 104314826 3313772
31 104314826 3313772 1587894
2 3313772 1587894 137984
11 1587894 137984 70070
1 137984 70070 67914
1 70070 67914 2156
31 67914 2156 1078
2 2156 1078 0
1078 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 11 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
q r1 r2 r s1 s2 s t1 t2 t a=161 b=28
------------------------------------
5 161 28 21 1 0 1 0 1 -5 161/28 = 5.75
q= 5
r= 21
------------------------------------
s=s1-(q*s2)
s=1-(5*0)
s=1
-------------------------------------
t=t1-(q*t2)
t=0-(5*1)
t=-5
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 12 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 13 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
s=0
t=1
-------------------------------------
s*a + t*b = GCD(a,b)
(0*0)+(1*45) = 45
0+45 = 45
45 = 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 14 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 15 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 16 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Some Zn sets
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 17 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
• The three binary operations that we discussed for the set Z can also Perform the following operations (the inputs come from Zn):
be defined for the set Zn. • Add 7 to 14 in Z15
• The result may need to be mapped to Zn using the mod operator.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
Perform the following operations (the inputs come from Zn): Perform the following operations (the inputs come from Zn):
• Add 7 to 14 in Z15 • Add 7 to 14 in Z15
• (7+14) mod 15 = 21 mod 15 = 6 • (7+14) mod 15 = 21 mod 15 = 6
• Subtract 11 from 7 in Z13
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 18 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
Perform the following operations (the inputs come from Zn): Perform the following operations (the inputs come from Zn):
• Add 7 to 14 in Z15 • Add 7 to 14 in Z15
• (7+14) mod 15 = 21 mod 15 = 6 • (7+14) mod 15 = 21 mod 15 = 6
• Subtract 11 from 7 in Z13 • Subtract 11 from 7 in Z13
• (7-11) mod 13 = -4 mod 13 = 9 mod 13 = 9 • (7-11) mod 13 = -4 mod 13 = 9 mod 13 = 9
• Multiply 11 by 7 in Z20
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
Perform the following operations (the inputs come from Zn): Properties
1. [(a mod n) + (b mod n)] mod n = (a + b) mod n
• Add 7 to 14 in Z15
• (7+14) mod 15 = 21 mod 15 = 6 2. [(a mod n) – (b mod n)] mod n = (a – b) mod n
3. [(a mod n) x (b mod n)] mod n = (a x b) mod n
• Subtract 11 from 7 in Z13
• (7-11) mod 13 = -4 mod 13 = 9 mod 13 = 9
Example
• Multiply 11 by 7 in Z20 1. [(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2 ; (11 + 15) mod 8 = 26 mod 8 = 2
• (11*7) mod 20 = 77 mod 20 = 17 2. [(11 mod 8) – (15 mod 8)] mod 8 = –4 mod 8 = 4 ; (11 – 15) mod 8 = –4 mod 8 = 4
3. [(11 mod 8) x (15 mod 8)] mod 8 = 21 mod 8 = 5 ; (11 x 15) mod 8 = 165 mod 8 = 5
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 19 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Operation in Zn Inverses
• In arithmetic, we often need to find the remainder of powers of 10 • When we are working in modular arithmetic, we often need to find
when divided by an integer. the inverse of a number relative to an operation.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Solution:
• Z10 = {0,1,2,3,4,5,6,7,8,9}
• Consider ‘0’ the additive inverse is itself ‘0’ [0+0] ≡ 0 mod 10
In modular arithmetic, each integer has an additive inverse.
The sum of an integer and its additive inverse is congruent to • ‘1’ additive inverse is ‘9’, [1+9] ≡ 0 mod 10
0 modulo n. • 2 additive inverse is 8, [2+8] ≡ 0 mod 10
• The six pairs of additive inverses are
(0, 0), (1, 9), (2, 8), (3, 7), (4, 6), and (5, 5).
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 20 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Inverses: Multiplicative
Inverses: Multiplicative • Find all multiplicative inverses in Z10.
• In Zn, two numbers a and b are the multiplicative inverse of each Solution
other if • Z10 = {0,1,2,3,4,5,6,7,8,9}
• 0 * NA ≡ 1 mod 10
• 0 has no multiplicative inverse under modulo 10.
• 1*? ≡ 1 mod 10
• 1*1 ≡ 1 mod 10
In modular arithmetic, an integer may or may not • The multiplicative inverse of 1 is 1 under modulo 10.
have a multiplicative inverse. • 2*? ≡ 1 mod 10
• 2 has no multiplicative inverse under modulo 10.
When it does, the product of the integer and its
• 3*? ≡ 1 mod 10
multiplicative inverse is congruent to • 3*7 ≡ 1 mod 10
1 modulo n. • The multiplicative inverse of 3 is 7 under modulo 10.
• There are only three pairs: (1, 1), (3, 7) and (9, 9).
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of • The numbers 0, 2, 4, 5, 6, and 8by:do
Prepared not have
Dr.Swetha.N.G., a Senior,
Asst Prof multiplicative
Dept of inverse.
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 21 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
• The gcd (100, 23) is 1; the inverse of 23 is -13 or 87. • The gcd (26, 12) is 2; the inverse does not exist.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 22 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 23 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
• Let us define a set G = < {a, b, c, d}, •> and the operation as shown in • Eg: <Z,+> Infinite Group
Table below. • Eg: <Z10,+> Finite Group
This user defined
operation • Forms an
Abelian Group.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 24 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
• If the group is finite, the order is finite. • If G=<S, •> is a group, H=<T, •> is a group under the same operation
., and T is a non empty subset of S.
• This implies that, H=<T, •> is a sub group of G.
• Eg: G= <Z10,+>
• |G| = 10
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 25 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 26 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Ring Ring
• A ring, R = <{…}, •, >, is an algebraic structure with two operations. • The set Z with two operations, addition and multiplication, is a
commutative ring.
• We show it by R = <Z, +, ×>.
• Addition satisfies all of the five properties
• Multiplication satisfies only three properties.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Field
• A set of numbers Group, Ring, Field
• with two operations which form:
• abelian group for addition
• abelian group for multiplication (ignoring 0)
• A field, denoted by F = <{…}, •, > is a commutative ring in which the
second operation satisfies all five properties defined for the first
operation except that the identity of the first operation has no
inverse.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 27 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
A Galois field, GF(pn), is a finite field with pn • Hence arithmetic is “well-behaved” and can do addition, subtraction,
multiplication, and division without leaving the field GF(p)
elements.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Finite (Galois) Fields: GF(p) Fields Finite (Galois) Fields: GF(p) Fields
• When n = 1, we have GF(p) field. Example:
• This field can be the set Zp, {0, 1, …, p − 1}, with two arithmetic • We can define GF(5) on the set Z5 (5 is a prime) with addition and
operations. multiplication operators
Example:
• A very common field in this category is GF(2) with the set {0, 1} and
two operations, addition and multiplication.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
XOR Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 28 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 29 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 30 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 31 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 32 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
[(x5) ⊗ Prepared
(x5 + xby:
4 + x3 + x)] mod (x8 + x4 + x3 + x + 1)=1
Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 33 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 34 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
• Is 301 a prime?
Solution
• 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.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 35 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 36 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 37 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
(2^2)*(5^2)
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 38 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 39 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
• we find x = 276.
• We can check that 276 = 3 mod 7, 276 = 3 mod 13 and 276 is divisible by 12
(the quotient is 23 and the remainder is zero).
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 40 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 41 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
1<= a <= n-1 a takes the values [1,2,3,4] 1<= a <= n-1 a takes the values [1,2,3,4,5,6]
a=1 1(5-1) mod 5 = 14 mod 5 = 1 Pass a=1 1(7-1) mod 7 = 16 mod 7 = 1 Pass
a=2 2(5-1) mod 5 = 24 mod 5 = 16 mod 5 = 1 Pass a=2 2(7-1) mod 7 = 26 mod 7 = 64 mod 7 = 1 Pass
a=3 3(5-1) mod 5 = 34 mod 5 = 81 mod 5 = 1 Pass a=3 3(7-1) mod 7 = 36 mod 5 = 729 mod 7 = 1 Pass
a=4 4(5-1) mod 5 = 44 mod 5 = 256 mod 5 = 1 Pass a=4 4(7-1) mod 7 = 46 mod 5 = 4096 mod 7 = 1 Pass
a=5 5(7-1) mod 7 = 56 mod 5 = 15625 mod 7 = 1 Pass
a=6 6(7-1) mod 7 = 66 mod 5 = 46656 mod 7 = 1 Pass
5 is a prime number !!!
7 is a prime number !!!
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 42 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
k=4 m=35
Decide on the value of a 1 < a < n-1 a= 2
Initial Computation T = am mod n T = 235 mod 561
= 263
T is not equal to +1 or -1
Loop Count: 1 to k-1 1 to 3
1 T = T2 mod n T = 2632 mod 561
= 166
2 T = T2 mod n T = 1662 mod 561
= 67
3 T = T2 mod n T = 672 mod 561
=1
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of 561by:
Prepared is Dr.Swetha.N.G.,
a composite AsstNumber
Prof Senior, !!!
Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 43 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 44 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 45 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 46 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 47 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Modular Exponentiation
• If the base and the modulus are closer to each other, convert the base
into a negative number.
• Choose whichever is the smallest to operate on.
Additional Input • If the exponent is greater, then divide the exponent into smaller
numbers and get the result. Finally combine all the answers obtained.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 48 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 49 of 50
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore.
5117 mod 19
Fast Modular Exponentiation Binary Equivalent of 117= 1 1 1 0 1 0 1
26 25 24 22 20
• ab mod m
5 mod 19= 5 * 5 * 5 * 532 * 564 (mod 19)
117 1 4 16
• Find the binary equivalent of b.
= 5 * 17 * 16 * 9 * 5 (mod 19)
• Replace each 1 in the equivalent with 2Position.
=1
• Raise a to the power of each 2Position.
• Solve it to get the answer.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Analytics, SCOPE, VIT, Vellore. Page 50 of 50