2. mathemetics of cryptography

Preview:

Citation preview

Mathematics of Cryptography

Prepared By: Shaikh Amrin

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.

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

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

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

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

(15*1+9*1)

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

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)

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

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.

q r1 r2 r s1 s2 s t1 t2 t

1 0 0 1

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

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

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

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

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

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

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}

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

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)

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)..}

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

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

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

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}

Matrix Inverse

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

Recommended