Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cryptography Inverses and GCD Piotr Faliszewski. GCD(a,b) gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) a = b*q + r Here: q =  a / b  r = a mod b (a –

Similar presentations


Presentation on theme: "Cryptography Inverses and GCD Piotr Faliszewski. GCD(a,b) gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) a = b*q + r Here: q =  a / b  r = a mod b (a –"— Presentation transcript:

1 Cryptography Inverses and GCD Piotr Faliszewski

2 GCD(a,b) gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) a = b*q + r Here: q =  a / b  r = a mod b (a – b*q) Key idea  express the first argument in terms of the second

3 Multiplicative Inverse Let a, n – two integers A number a -1 s.t.  a*a -1 = 1 (mod n) is called a multiplicative inverse of a Theorem if gcd(a,b) = d then there are integers x and y s.t., ax + by = d

4 Multiplicative Inverse Let a, n – two integers If gcd( a, n ) = 1 then  there are integers x,y: ax + ny = 1  then, x is a -1 Note ax + ny = 1 (mod n) ax = 1 (mod n) Theorem if gcd(a,b) = d then there are integers x and y s.t., ax + by = d

5 Computing x,y via GCD gcd(a,b), r 0 =a, r 1 = b  gcd( r 0, r 1 )  r 0 = q 1 r 1 + r 2  r 1 = q 2 r 2 + r 3  r 2 = q 3 r 3 + r 4 ...  r k-1 = q k r k + r k+1  r k = q k+1 r k+1 +0 Idea:  sequences (x i ) and (y i )  r i = ax i + by i  build as you go

6 Computing x,y via GCD gcd(a,b), r 0 =a, r 1 = b  gcd( r 0, r 1 )  r 0 = q 1 r 1 + r 2  r 1 = q 2 r 2 + r 3  r 2 = q 3 r 3 + r 4 ...  r k-1 = q k r k + r k+1  r k = q k+1 r k+1 +0 x 0 = 1,y 0 = 0 x 1 = 0,y 1 = 1 x 2 = x 0 - q 1 x 1,y 2 = y 0 - q 1 y 1 x 3 = x 1 - q 2 x 2,y 3 = y 1 - q 2 y 2 x 4 = x 2 - q 3 x 3,y 4 = y 2 - q 3 y 3... r k+1 = ax k+1 + by k+1 x j+1 = x j-1 – q j x j y j+1 = y j-1 – q j y j

7 Example: GCD(45, 20) gcd(a,b), r 0 =45, r 1 = 20  gcd( 45, 20 )  r 0 = q 1  r 1 + r 2  45 = 2  20 + 5  r 1 = q 2  r 2 + r 3  20 = 4  5 + 0 x 0 = 1,y 0 = 0 x 1 = 0,y 1 = 1 x 2 = x 0 - q 1 x 1,y 2 = y 0 - q 1 y 1 x 2 = 1 – 2  0,y 2 = 0 – 2  1 x 2 = 1,y 2 = -2 r 3 = 0  computation ended gcd(45, 20) = 5 = 45  1 – 2  20

8 Example: GCD(19, 7) gcd(a,b), r 0 =19, r 1 = 7  gcd( 19, 7 )  19 = 2  7 + 5  7 = 1  5 + 2  5 = 2  2 + 1  2 = 2  1 + 0 x 0 = 1,y 0 = 0 x 1 = 0,y 1 = 1 x 2 = 1 – 2  0 = 1 y 2 = 0 – 2  1 = -2 x 3 = 0 – 1  1 = -1 y 3 = 1 – 1  (-2) = 3 x 4 = 1 – 2  (-1) = 3 y 4 = -2 – 2  (3) = -8 19  3 + 7  (-8) = 57 - 56 = 1

9 Solving Linear Congruences Problem:  Solve 7x = 10 (mod 19) 11  7 = 1 (mod 19) Thus (11  7)x = 11  10 (mod 19) x = 110 (mod 19) x = 15 (mod 19) Getting the inverse  via GCD  we know that gcd(19, 7) = 1 7*(-8) + 19*3 = 1  -8 is the multiplicative inverse of 7 (mod 19)  -8 = 19 - 8 = 11 (mod 19)


Download ppt "Cryptography Inverses and GCD Piotr Faliszewski. GCD(a,b) gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) a = b*q + r Here: q =  a / b  r = a mod b (a –"

Similar presentations


Ads by Google