Solved Numericals

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Multiplicative Inverse:

In Zn, two numbers a & b are multiplicative inverse of each other if


a x b 1 mod n
In modular arithmetic, an integer may or may not have multiplicative inverse. When it does the
product of the integer & its multiplicative inverse is congruent to 1 mod n.
We have to use Extended Euclidean algorithm to find out multiplicative inverses
Q.1 Find all multiplicative inverse in Z10
Soln: As n = 10, modulus is 10 & the pairs are (1,1), (3,7), (9,9)
(1 x 1) mod 10 = 1
(3 x 7) mod 10 = 1
(9 x 9) mod 10 = 1
Q.2 Find the multiplicative inverse of 11 in Z26
Soln: For solving this we have to use Extended Euclidean algorithm.
Here, n = 26.
So r1 = 26 & r2 = 11 (Always take modulus as r1 & other number as r2)
q
2
2
1
3

r1
26
11
4
3
1

r2
11
4
3
1
0

R
4
3
1
0

t1
0
1
-2
5
-7

t2
1
-2
5
-7
26

t
-2
5
-7
26

Here gcd(26,11) is 1. So multiplicative inverse exists, i.e t = -7


Add modulus and make it positive. -7+26 = 19
So 11 & 19 are inverses of each other in Z26
(11x19) mod 26 = 209 mod 26 = 1
Q.3 Find the multiplicative inverse of 23 in Z100
Soln: For solving this we have to use Extended Euclidean algorithm.
Here, n = 100.
So r1 = 100 & r2 = 23 (Always take modulus as r1 & other number as r2)
q
4
2
1
7

r1
100
23
8
7
1

r2
23
8
7
1
0

r
8
7
1
0

t1
0
1
-4
19
-131

t2
1
-4
19
-13
100

T
-4
13
-13
100

Here gcd(100,23) is 1. So multiplicative inverse exists, i.e t = -13


Add modulus and make it positive. -13+100 = 87
So 23 & 87 are inverses of each other in Z100
(23x87) mod 100 = 2001 mod 100 = 1

Chinese Reminder Theorem:


It is used to solve set of congruent equations with one variable but different modulus, which are
relatively prime.
x a1 mod m1
x a2 mod m2
x a3 mod m3

x ak mod mk
Q. 1 Use the Chinese remainder theorem to find a solution to each of the following linear systems:
x 2 mod 3
x 3 mod 5
x 2 mod 7
Soln: Find M = m1 x m2 x m3. This is common modulus
M =3 x 5 x 7 = 105
Find M1 = M/m1 = 105/3 = 35
M2 = M/m2 = 105/5 = 21
M3 = M/m3 = 105/7 = 15
Find M1-1
To find this we have to solve gcd(m1,M1). After solving, use the value of t.
So We need to solve gcd(3,35) and after solving we need to use value of t.
Do not use value of gcd
q
0
11
1

r1
3
35
3

r2
35
3
2

r
3
2
1

t1
0
1
0

t2
1
0
1

T
0
1
-1

Value for t is multiplicative inverse. i.e M1-1 = -1. Make it positive by adding corresponding modulus.
i.e. Here we will add m1. So M1-1 = -1 + 3 = 2
M1-1 = 2
Similarly we can find M2-1 & M3-1
So we got M1-1 = 2, M2-1 = 1, M3-1 = 1
Finally to get the value of X, we need to put all the values in formula,

X = (a1 x M1 x M1-1 + a2 x M2 x M2-1 + a3 x M3 x M3-1 ) mod M


X = (2 x 35 x 2 + 3 x 21 x 1 + 2 x 15 x 1)mod 105
X = 23
So the final answer is 23.
Q. 2 Find the integer that has a reminder of 3 when divided by 7 & 13, but is divisible by 12.
Soln:
x 3 mod 7
reminder 3 when divided by 7
x 3 mod 13
reminder 3 when divided by 13
x 0 mod 12
divisible by 12
M= 1092
M1 = 156, M2 = 84, M1 = 91
M1-1 = 4, M2-1 = 7, M3-1 = 11
X = 276
Q.3 Determine the value of x using Chinese remainder theorem
X = 1 (mod 5)
X = 6 (mod 7)
X = 8 (mod 11)
Soln:
a1 = 1; a2 = 6; a3 = 8;
m1 = 5; m2 = 7; m3 = 11
M = m1*m2*m3 = 5*7*11 = 385
M1 = M/m1 = 385/5 = 77
M2 = M/m2 = 385/7 = 55
M3 = M/m3 = 385/11 = 35
M1-1 = 3
M2-1 = 6
M3-1 = 6
X= (a1*M1* M1-1 + a2*M2* M2-1 + a3*M3* M3-1) mod M = 41
X=41
Q.4 Determine the value of x using Chinese remainder theorem
X = 1 (mod 2)
X = 2 (mod 3)
X = 3 (mod 5)
X = 4 (mod 7)
Soln:

M = 2*3*5*7 = 210
M1 = M/m1 = 210/2 = 105
M2 = M/m2 = 210/3 = 70
M3 = M/m3 = 210/5 = 42
M4 = M/m4 = 210/7 = 30
M1-1 = 1
M2-1 = 1
M3-1 = 3
M4-1 = 4
X= (a1*M1* M1-1 + a2*M2* M2-1 + a3*M3* M3-1 + a4*M4* M4-1) mod M = 53
X=53
Q.5 Determine the value of x using Chinese remainder theorem
X = 1 (mod 2)
X = 2 (mod 3)
X = 3 (mod 5)
X = 4 (mod 11)
Soln:
M = 2*3*5*11 = 330
M1 = M/m1 = 330/2 = 165
M2 = M/m2 = 330/3 = 110
M3 = M/m3 = 330/5 = 66
M4 = M/m4 = 330/11 = 30
M1-1 = 1
M2-1 = 2
M3-1 = 1
M4-1 = 7
X= (a1*M1* M1-1 + a2*M2* M2-1 + a3*M3* M3-1 + a4*M4* M4-1) mod M = 323
X=323
Q.6 Determine the value of x using Chinese remainder theorem
X = 4 (mod 5)
X = 6 (mod 8)
X = 8 (mod 9)
Soln:
M = 5*8*9 = 360

M1 = M/m1 = 360/5 = 72
M2 = M/m2 = 360/8 = 45
M3 = M/m3 = 360/9 = 40
M1-1 = 3
M2-1 = 5
M3-1 = 7
X= (a1*M1* M1-1 + a2*M2* M2-1 + a3*M3* M3-1) mod M = 134
X=134
Q.6 Determine the value of x using Chinese remainder theorem
X = 1 (mod 13)
X = 11 (mod 23)
Soln: X=287
Q.7 In Chinese remainder theorem, Let N= 210 & let n1 = 5, n2 =6, n3 = 7.
Compute f-1(3,5,2).
Soln:
X = 3 (mod 5)
X = 5 (mod 6)
X = 2 (mod 7)
N = 210
N1= 210/5=42
N2= 210/6=35
N3= 210/7=30
N1-1 = 3
N2-1 = 5
N3-1 = 4
X=23

RSA Algorithm:
Q.1 In RSA cryptosystem consider the given data,
P = 3, Q = 11, M = 2. Find out private key & the cipher text values
Soln:
Given p = 3 and q = 11
Compute n = p * q = 3 * 11 = 33
Compute (n) = (p - 1) * (q - 1) = 2 * 10 = 20
Choose e such that 1 < e < (n) and e and n are coprime. Let e = 3
Public key is (e, n) => (7, 33)

Compute a value for d. If we solve gcd((n),e) and take the value of t, then we will get the
value of d. (If the value of t is negative then add (n) to it)
Solving it by Extended Euclidean algorithm
Q
6
1

r1
20
3

r2
3
2

r
2
1

t1
0
1

t2
1
-6

T
-6
7

Private key is (d, n) => (7, 33)


The encryption of M = 2 is C = 23 mod 33 = 8
The decryption of C = 8 is M = 87 mod 33 = 2
Q.2 In RSA cryptosystem consider the given data,
P = 7, Q = 13, M = 10. Find out private key & the cipher text values
Soln:
Given p = 7 and q = 13
Compute n = p * q = 7 * 13 = 91
Compute (n) = (p - 1) * (q - 1) = 6 * 12 = 72
Choose e such that 1 < e < (n) and e and n are coprime.
Choose e. Lets look among the primes.
Try e = 2. gcd(2, 72) = 2 (does not work)
Try e = 3. gcd(3, 72) = 3 (does not work)
Try e = 5. gcd(5, 72) = 1 (it works)
We choose e = 5.
Public key is (e, n) => (5, 33)
Compute a value for d. If we solve gcd((n),e) and take the value of t, then we will get the
value of d. (If the value of t is negative then add (n) to it)
Solving it by Extended Euclidean algorithm, d=29
Private key is (d, n) => (29, 33)
The encryption of M = 10 is C = 105 mod 91 = 82
The decryption of C = 82 is M = 8229 mod 91 = 10
Q.3 Let the given data be - Prime numbers p = 11, q = 19 and the plain text to be sent is 40. Assume
public key e as 23. Using RSA algorithm determine the cipher text for the given plain text. Also
perform the reverse process of finding the plain text from the cipher text.
Soln:
P = 11, Q = 19, M = 40, e = 23, C = ?, d = ?

n = P*Q = 209
(n) = (p-1)(q-1) = 180
We choose e = 23, We know that gcd((n), e)=1
To get the Cipher text,
C=Me mod n
C=4023mod 209
C=13
To get the plaintext we need to find d.
If we solve gcd((n), e) using Extended Euclidian Algorithm, we will get d = 47.
So to get plaintext,
M = Cd mod n
M = 1347 mod 209
M = 40
Q. 4 In a public-key system using RSA, you intercept the ciphertext C =10 sent to a user whose
public key is e=5, n=35. What is the plaintext M?
Soln:
We know that the cipher text C = 10, and the public key PU = {e, n} = {5, 35}.
Based on Eulers Totient function, (n) is defined as the number of positive integers less than n and
relatively prime to n.
We could find that (n) = 24.
Now, we guess two prime numbers p and q. Let p be 5 and q be 7. All the following conditions will
be satisfied based on the guess:
(1) n = p*q = 5*7=35
(2) (n) = (p-1)(q-1)=(5-1)(7-1)=4*6=24
(3) gcd((n), e) = gcd(24, 5) =1, 1< e < (n)
We calculate d in the next step. Based on RSA key generation algorithm,
d e-1 mod (n) which is equivalent to
ed 1 mod (n) or ed mod (n) =1.
We have e = 5, (n) = 24. So, 5d mod 24 =1, and d = 5.
Now, we find the private key PR = {d, n} = {5, 35}.
Based on RSA decryption algorithm,
M = Cd mod n
= 105 mod 35
=5

We also can verify the correctness by the RSA encryption algorithm as the following:
C = Me mod n = 55 mod 35 = 10
Therefore, we conclude that the plaintext M is 5.

Extended Euclidean Algorithm:


Q. 1 Find the value of x & y using extended Euclidean algorithm.
gcd(161,28)
Soln:
a.x +b.y = gcd(a,b)
a=161; b=28
q
5
1
3

r1
161
28
21
7

r2
28
21
7
0

r
21
7
0

s1
1
0
1
-1

s2
0
1
-1
4

x= -1 & y =6
gcd(161,28)=7 & 161(-1) + 28(6) = 7

Fermats little theorem & Eulers Theorem

s
1
-1
4

t1
0
1
-5
6

t2
1
-5
6
-23

t
-5
6
-23

Q. 1 Explain Fermats little theorem & solve the following using the same
i)
1518 mod 17
ii)
527 mod 13
Soln:
i) According to Fermats Theorem,

ap =p mod p
i.e. (15(17)mod 17) (151mod 17) = 15 * 15 (mod 17) = 225 mod 17 = 4
ii) According to Eulers Theorem,

a(n) 1 mod n

i.e. 527 mod 13 can be written as


((512 mod 13) (512 mod 13) (53 mod 13))mod 13
as per Eulers theorem (512 mod 13)=1, So the above equation becomes,
(1.1.125) mod 13 = 8

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy