29
Mathematics of Cryptography Prepared By: Shaikh Amrin

2. mathemetics of cryptography

Embed Size (px)

Citation preview

Page 1: 2. mathemetics of cryptography

Mathematics of Cryptography

Prepared By: Shaikh Amrin

Page 2: 2. mathemetics of cryptography

2.1 Integer arithmeticSet of integers

Z={….,-2,-1,0,1,2,…}In cryptography we are working in binary operations applied to set of integers like addition, subtraction, multiplication, division.

Page 3: 2. mathemetics of cryptography

Integer division

n(divisor) 23 q(quotient)11 255 a(divident) 22 35 33 2 r(remainder)

Restrictions:1. Divisor be a positive number2. Reminder be a positive number

255=(11*23)+2-255=(11*-23)+-2Here in 2nd example r=-2How can we make it positive?

Add(-1) to q and add the value n to r.

-255=(11*-24)+9

Page 4: 2. mathemetics of cryptography

divisibilityIf a is not zero and r=0 in division

relationSo, we can say that

n divides a or n is divisor of a ora is divisible by n.Denoted by n|aEx: 13|78,7|98,-6|24

Page 5: 2. mathemetics of cryptography

Properties of divisibility

1. If a|1, then a=+-12. If a|b and b|c, then a=+-b3. If a|b and b|c, then a|c4. If a|b and a|c, then a|(m*b+n*c)

where m and n are arbitrary integers

Page 6: 2. mathemetics of cryptography

If 3|15 and 15|45 then 3|45If 3|15 and 3|9 then 3|

(15*1+9*1)

Page 7: 2. mathemetics of cryptography

Greatest Common Divisor

Euclidean AlgorithmGcd(a,0)=aGcd(a,b)=gcd(b,r) where r=a%b

Ex:1 Ex:2Gcd(36,12) Gcd(50,3)=Gcd(12,0) =Gcd(3,2)=12 =Gcd(2,1)

=1

Page 8: 2. mathemetics of cryptography

Find GCD(2740,1760)

q r1 r2 r

1 2740 1760 980

1 1760 980 780

1 980 780 200

3 780 200 180

1 200 180 20

9 180 20 0

20 0

Find GCD(25,60)

Page 9: 2. mathemetics of cryptography

Calculate GCD(17,0),GCD(0,45)

Page 10: 2. mathemetics of cryptography

Extended Euclidean AlgorithmGiven two integers a and b we

often need to find s & t such that(s*a)+(t*b)=gcd(a,b)

It is useful when a and b are co-prime.

compute multiplicative inverse.

Page 11: 2. mathemetics of cryptography

q r1 r2 r s1 s2 s t1 t2 t

1 0 0 1

s=s1-(q*s2)t=t1-(q*t2)

Page 12: 2. mathemetics of cryptography

q r1 r2 r s1 s2

s t1 t2 t

5 161

28

21

1 0 1-(5*0)=1

0 1 0-(5*1)=-5

Find gcd(161,28) and also calculate s and t

Page 13: 2. mathemetics of cryptography

q r1 r2 r s1 s2

s t1 t2 t

5 161

28

21

1 0 1-(5*0)=1

0 1 0-(5*1)=-5

28 21

0 1 1 -5

Find gcd(161,28) and also calculate s and t

Page 14: 2. mathemetics of cryptography

q r1 r2 r s1 s2

s t1 t2 t

5 161

28

21

1 0 1-(5*0)=1

0 1 0-(5*1)=-5

1 28 21

7 0 1 0-(1*1)=-1

1 -5 1-(1*-5)=6

Find gcd(161,28) and also calculate s and t

Page 15: 2. mathemetics of cryptography

q r1 r2 r s1 s2

s t1 t2 t

5 161

28

21

1 0 1-(5*0)=1

0 1 0-(5*1)=-5

1 28 21

7 0 1 0-(1*1)=-1

1 -5 1-(1*-5)=6

3 21 7 0 1 -1 1-(3*-1)=4

-5 6 -5-(3*6)=-23

Find gcd(161,28) and also calculate s and t

Page 16: 2. mathemetics of cryptography

q r1 r2 r s1 s2

s t1 t2 t

5 161

28

21

1 0 1-(5*0)=1

0 1 0-(5*1)=-5

1 28 21

7 0 1 0-(1*1)=-1

1 -5 1-(1*-5)=6

3 21 7 0 1 -1 1-(3*-1)=4

-5 6 -5-(3*6)=-23

7 0 -1 4 6 -23

Find gcd(161,28) and also calculate s and t

gcd(161,28)=r1=7 and also s=-1 and t=6

(s*a)+(t*b)=gcd(a,b)=> (-1*161)+(6*28)=gcd(161,28)=7

Page 17: 2. mathemetics of cryptography

Modular Arithmetic

a=q*n+rn is called modulusr is called as residuezn is called as set of residues {0,1…n-1}

Ex:n=11,a=3535=3*11+2Z11={0,1,2,3,4,5,6,7,8,9,10}

Page 18: 2. mathemetics of cryptography

CongruenceMapping from Z to Zn is not one-one.

For ex: 2%10=2,12%10=2…

so,{2,12,22} are called congruent to n.

is called as congruent operator.

a is congruent to b mod m if m divides b-a.

a b mod m

-2 19 mod 21

Page 19: 2. mathemetics of cryptography

Any integer is congruent to itself modulo m (reflexivity) a a mod m.

a b mod m implies that b a mod m (Symmetry)

a b mod m and b c mod m implies that a c mod m (transitivity)

Page 20: 2. mathemetics of cryptography

Residue classes of a%m m=4 1 % 4={1,1+-4,1+-(2*4),1+-

(3*4)..}2 % 4={2,2+-4,2+-(2*4),2+-

(3*4)..}3 % 4={3,3+-4,3+-(2*4),3+-

(3*4)..}0 % 4={0,0+-4,0+-(2*4),0+-

(3*4)..}

Page 21: 2. mathemetics of cryptography

Inverse

Additive inverse:

In Zn two numbers a,b are additive inverse of each other if a+b 0 mod n

Ex: additive inverse of 4 in Z10 =10-4=6

Page 22: 2. mathemetics of cryptography

Multiplicative InverseIn Zn two numbers a,b are multiplicative inverse of each other if a*b 1 mod n

Ex: multiplicative inverse of 3 in Z10

=3*7%10=1

Page 23: 2. mathemetics of cryptography

q r1 r2 r t1 t2 t

3 10 3 1 0 1 -3

3 3 1 0 1 -3 10

1 0 -3=7 10=0

Page 24: 2. mathemetics of cryptography

Z26={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}

Z26*={1,3,5,7,9,11,15,17,19,21,23}

Page 25: 2. mathemetics of cryptography

Matrix Inverse

Page 26: 2. mathemetics of cryptography
Page 27: 2. mathemetics of cryptography
Page 28: 2. mathemetics of cryptography
Page 29: 2. mathemetics of cryptography

M-1 = 1/det(M)*MT