Gcd Number Theory and Algebra I GCD CSCI
Gcd Number Theory and Algebra – I GCD CSCI 284/162 Spring 2007 GWU CS 284 -162/Spring 07/GWU/Vora/GCD
Zm Definition: a b (mod m) m divides a-b Zm is the “ring” of integers modulo m: 0, 1, 2, …m-1 with normal addition and multiplication, performed modulo m We define a mod m to be the unique remainder of a when divided by m, i. e. a mod m Zm 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 2
Example: Additive Inverses • Examples for -1 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 3
Properties of Zm (definition of a ring) • Closed under addition and multiplication If a, b Zm then a+b, ab Zm • Addition and multiplication are commutative and associative If a, b Zm then a+b = b+a ab = ba (a+b)+c = a +(b+c) and (ab)c = a(bc) 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 4
Properties of Zm – contd. • Additive and multiplicative identities in Zm Additive identity is 0 mod m Multiplicative identity is 1 mod m • Distributive property holds For a, b, c Zm (a+b)c = ac + bc and a(b+c) = ab + ac 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 5
Properties of Zm – contd. • Additive inverse? Needs to exist in a ring A number y such that x + y = 0 for all x in Zm • Multiplicative inverse? Need not exist in a ring A number y such that x*y = 1 for all x in Zm 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 6
Examples: multiplicative inverses • Inverse of -1 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 7
Affine Cipher P=C=R K R R e. K(x) = ax + b d. K(x) = a-1 (x – b) Key may be written as: (a, b) or a=; b= Example How many keys when R = Z 4 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 8
Example encryption and decryption 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 9
Example cryptanalysis BE JP find K 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 10
To know if a is invertible, need definition of GCD The gcd (Greatest Common Divisor) of two integers m and n denoted gcd(m, n) is the largest non-negative integer that divides both m and n. 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 11
Multiplicative inverse of a in Zm The multiplicative inverse of a mod m Zm, denoted a-1, exists if and only if gcd(m, a) = 1 Need show: i. a-1 exists gcd(m, a) = 1 ii. gcd(m, a) = 1 a-1 exists 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 12
Proof: (i) a-1 exists gcd(m, a) = 1 Suppose a-1 exists, call it t at 1 (mod m) at + ms = 1 for some integer s gcd(m, a) = 1 (because the gcd divides both sides of above equation, and only 1 can divide the rhs) 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 13
Proof: ii. gcd(m, a) = 1 a-1 exists This is a bit complicated. First, we show that, A. gcd(m, a) = 1 s, t, such that ms + at = 1 And then, B. s, t, such that ms + at = 1 a-1 exists 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 14
Proof of ii A: gcd(m, a) = 1 s, t, such that ms + at = 1 Suppose gcd(m, a) = 1 Let x be any integer of the form Sm + Ta for integers S and T Let g be the smallest non-negative integer of this form (want to show g = 1) Then x = Cg + r, 0 r < g 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 15
Proof of ii A contd. : gcd(m, a) = 1 s, t, such that ms + at = 1 x = Cg + r, 0 r < g where r = Sm+Ta – Cg = Sm + Ta – C(S’m +T’a) = S’’m + T’’a =0 (as g was smallest such non-negative integer and r < g) 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 16
Proof of ii A contd: gcd(m, a) = 1 s, t, such that ms + at = 1 x = Cg + r; r = 0 Hence g divides all integers of the form Sm + Ta, in particular, g divides a (S = 0) and m (T = 0) g=1 S=s, T=t, such that ms + at = 1 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 17
Proof of ii B: s, t, such that ms + at = 1 a-1 exists s, t, such that ms + at =1 at mpd m = 1 t = a-1 A and B imply ii. gcd(m, a) = 1 a-1 exists 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 18
Z m* Zm* is the set of all elements in Zm that have multiplicative inverses (m) is the size of Zm* That is, it is the number of invertible elements mod m It is known as the Euler Phi Function or the Euler Totient Function Example: m=8, 15 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 19
Examples: Inverses and gcd Some inverses Number of affine ciphers for m = 30 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 20
How do we generate an encryption key for an affine cipher? 2/1/2022 CS 284 -162/Spring 07/GWU/Vora/GCD 21
- Slides: 21