CSCI 467 – Assignment Two Jason Detchevery Due: February 11

advertisement
CSCI 467 – Assignment Two Jason Detchevery Due: February 11, 2008 200410029 1. 4.17, Fourth Edition a. Euclidean algorithm: GCD(2152, 764) A B Remainder 2152 764 624 764 624 140 624 140 64 140 64 12 64 12 4 12 4
0 The remainder becomes 0, making the last non‐zero remainder, 4 = GCD(2152, 764) Stein’s Algorithm: Step 1: Let A1 = 2152, B1 = 764, C1 = 1 Step 2: A1 and B1 are both even, therefore A2 = 2152 / 2 = 1076, B2 = 764 / 2 = 382, C2 = 2 Step 3: A2 and B2 are both even, therefore A3 = 1076 / 2 = 538, B3 = 382 / 2 = 191, C3 = 4 Step 4: A3 is even and B3 is odd, therefore A4 = 269, B4 = 191, C4 = 4 Step 5: A4 is odd and B4 is odd, therefore A5 = | 269 – 191 | = 78, B5 = Min(191,269) = 191, C5 = 4 Step 6: A5 is even and B5 is odd, therefore A6 = 78 / 2 = 39, B6 = 191, C6 = 4 Step 7: A6 is odd and B6 is odd, therefore A7 = | 39 – 191 | = 152, B7 = Min(191, 39) = 39, C7 = 4 Step 8: A7 is even and B7 is odd, therefore A8 = 152 / 2 = 76, B8 = 39, C8 = 4 Step 9: A8 is even and B8 is odd, therefore A9 = 76 / 2 = 38, B9 = 39, C9 = 4 Step 10: A9 is even and B9 is odd, therefore A10 = 38 / 2 = 19, B10 = 39, C9 = 4 Step 11: A10 is odd and B10 is odd, therefore A11 = |19 – 39| = 20, B11 = Min(19, 39) = 19, C11 = 4 Step 12: A11 is even and B11 is odd, therefore A12 = 20 / 2 = 10, B12 = 19, C12 = 4 Step 13: A12 is even and B12 is odd, therefore A13 = 10 / 2 = 5, B13 = 19, C13 = 4 Step 14: A13 is odd and B13 is odd, therefore A14 = |5‐19| = 14, B14 = Min(5, 19) = 5, C14 = 4 Step 15: A14 is even, B14 is odd, therefore A15 = 14 / 2 = 7, B15 = 5, C15 = 4 Step 16: A15 is odd and B15 is odd, therefore A16 = | 7 – 5 | = 2, B16 = Min(5, 7) = 5, C16 = 4 Step 17: A16 is even and B16 is odd, therefore A17 = 2 / 2 = 1, B17 = 5, C17 = 4 Step 18: A17 is odd and B17 is odd, therefore A18 = | 1 – 5 | = 4, B18 = Min (1, 5) = 1, C18 = 4 Step 19: A18 is even and B18 is odd, therefore A19 = 4 / 2, B19 = 1, C19 = 4 Step 20: A19 is even and B19 is odd, therefore A20 = 2, B19 = 1, C20 = 4 Step 21: A20 is even and B20 is odd, therefore A21 = 2 / 2 = 1, B19 = 1, C21 = 4 Step 22: A21 is equal to B21 therefore GCD(2152, 764) = A21*C21 = 1 * 4 = 4 b. Despite needing more steps (in this case), the advantage of Stein’s Algorithm over the Euclidean Algorithm is that it doesn’t require and integer divisions, instead relying only on multiplication and division by 2 which can be implemented faster with simple bit shifts which along with subtraction improves over the integer division/mod operation. 2. 4.19, Fourth Edition a. Multiplicative inverse of 1234 mod 4321 via Extended GCD: Q A1 A2 A3 B1 B2 B3 ‐ 1 0 4321 0 1 1234 3 0 1 1234 1 ‐3 619 1 1 ‐3 619 ‐1 4 615 1 ‐1 4 615 2 ‐7 4 153 2 ‐7 4 ‐307 1075 3 1 ‐307 1075 3 309 ‐1082 1 Multiplicative Inverse of 1234 mod 4321 = ‐1082 (‐1082 * 1234) mod 4321 = (‐1 335 188) mod 4321 = 4321 * (‐308) = ‐1330868 and 4321 * (‐309) = ‐1335189 So ‐309 is the greatest multiple less than 1330868, so 4321*‐309 = ‐1335189 and (‐1 335 188) – (‐1335189) = 1, showing it’s a multiplicative inverse. To keep the multiplicative inverse confined to the set GF(4321), we can do clockwork arithmetic saying 4321 – 1082 = 3239. Note that 3239 * 1234 = 3996926 mod 4321 = 1, making 3239 the multiplicative inverse of 1234 in GF(4321). b. Multiplicative inverse of 24140 mod 40902 via Extended GCD: Q A1 A2 A3 B1 B2 B3 ‐ 1 0 40902
0
1 24140
1 0 1 24140 1 ‐1 16762 1 1 ‐1 16762 ‐1 2 7378 2 ‐1 2 7378 3 ‐5 2006 3 3 ‐5 2006 ‐10 17 1360 1 ‐10 17 1360 13 ‐22 646 2 13 ‐22 646 ‐36 61 68 9 ‐36 61 68 337 ‐571 34 2 337 ‐571 34
‐710
1203 0
Since B3 becomes 0, according the to the Extended GCD algorithm, there is no multiplicative 24140 in GF(40902). 40902 isn’t prime, so not all numbers necessary have multiplicative inverses. c. Multiplicative inverse of 550 mod 1769 via Extended GCD: Q ‐ 3 4 1 1 1 1 1 4 A1 1 0 1 ‐4 5 ‐9 14 ‐23 37 A2 0 1 ‐3 13 ‐16 29 ‐45 74 ‐119 A3 1769 550 119 74 45
29 16 13 3 B1 0 1 ‐4 5 ‐9
14 ‐23 37 ‐171 B2 1 ‐3 13 ‐16 29 ‐45 74 ‐119 550 B3 550 119 74 45 29
16 13 3 1 B3 becomes 1, ending the algorithm, giving us a multiplicative inverse of 550 mod 1769 = 550. Note: 550 * 550 = 302500 mod 1769 = 1 3. 4.23, Fourth Edition a. (7x + 2) – (x2 + 5) 7x + 2 2 ‐ x + 5 ‐ x2 + 7x – 3 = 9x2 + 7x + 7 in Z10 b. (6x2 + x + 3) x (5x2 + 2) = 30x4 + 12x2 + 5x3 + 2x + 15x2 + 6 = 30x4 + 5x3 + 27x2 + 2x + 6 = (30 mod 10)x4 + 5x3 + (27 mod 10)x2 + 2x + 6 = 0x4 + 5x3 + 7x2 + 2x + 6 = 5x3 + 7x2 + 2x + 6 in Z10 4. 4.25, Fourth Edition a. GCD(x3 + x + 1, x2 + x + 1) over GF(2) 1) x3 + x + 1 MOD x2 + x + 1 = _x_+ 1 _____ x2 + x + 1 ) x3 + x + 1 ‐( x3 + x2 + x _) x2 + 1 x2 + x + 1 x 2) GCD(x3 + x + 1, x2 + x + 1) = GCD(x2 + x + 1, x) _ x_+ 1__ x ) x2 + x + 1 ‐( x2______) x + 1 x___ 1 Therefore, GCD(x3 + x + 1, x2 + x + 1) = 1 b. GCD(x3 + x + 1, x2 + 1) over GF(3) 1. x3 + x + 1 MOD x2 + 1) _x_ x2 + 1 ) x3 + x + 1 ‐ (x3+ x _) 1 Therefore, GCD(x3 + x + 1, x2 + 1) = 1 c. GCD(x5 + x4 + x3 – x2 – x + 1, x3 + x2 +x + 1) over GF(3) 1. x5 + x4 + x3 – x2 – x + 1 MOD x3 + x2 +x + 1 _x2 _______________ x3 + x2 +x + 1 ) x5 + x4 + x3 – x2 – x + 1 ‐(x5 + x4 + x3 + x2_____) x2 ‐ x + 1 2. GCD(x5 + x4 + x3 – x2 – x + 1, x3 + x2 +x + 1) = GCD(x3 + x2 +x + 1, x2 ‐ x + 1) x3 + x2 +x + 1 MOD ‐x + 1 _x_+ 2___ x2 ‐ x + 1) x3 + x2 + x + 1 ‐(x3 ‐ x2 + x ) 2x2 + 1 ‐( 2x2 ‐2x + 2 ) 2x + 2 3. GCD(x3 + x2 +x + 1, x2 ‐ x + 1) = GCD(x2 ‐ x + 1, 2x + 2) _x + x 2x + 2 ) x2 ‐ x + 1 ‐(2x2 +2x) 2x2 + 1 ‐(2x2 +2x) x + 1 _2___ 4. x + 1 ) 2x + 2 ‐ 2x + 2_ 0 Therefore, GCD(x5 + x4 + x3 – x2 – x + 1, x3 + x2 +x + 1) = x + 1 d. GCD(x5 + 88x4 + 73x3 + 83x2 + 51x + 67, x3 + 97x2 + 40x + 38) in GF(101) 1. x5 + 88x4 + 73x3 + 83x2 + 51x + 67 MOD x3 + 97x2 + 40x + 38 x2_+ 92x + 98______________________ 2
x + 97x + 40x + 38 ) x5 + 88x4 + 73x3 + 83x2 + 51x + 67 ‐( x5 + 97x4 + 40x3 + 38x2 ) 92x4 + 33x3 + 45x2 + 51x + 67 ‐ ( 92x4 + 36x3 + 44x2 + 62x ) 98x3 + x2 + 90x + 67 ‐ ( 98x3+ 12x2 + 82x + 88) 90x2 + 8x + 80 3
2. GCD(x5 + 88x4 + 73x3 + 83x2 + 51x + 67, x3 + 97x2 + 40x + 38) = GCD(x3 + 97x2 + 40x + 38, 90x2 – 82x + 80) _55x + 22 90x2 + 8x + 80 ) x3 + 97x2 + 40x + 38 ‐(x3 + 36x2 + 57x ) 61x2 + 84x + 38 ‐ (61x2 + 75x + 43) 9x + 96 Note: x3 / 90x2 = (1/90)x = 90‐1x. Multiplicative inverse of 90 (90‐1) in GF(101) is 55. 3. GCD(x3 + 97x2 + 40x + 38, 90x2 – 82x + 80) = GCD(90x2 + 8x + 80, 9x + 96) _ 10x_+ 85 9x + 96 ) 90x2 + 8x + 80 ‐(90x2 + 51x ) 58x + 80 ‐ (58x + 80) 0 Remainder is 0, thus GCD(x5 + 88x4 + 73x3 + 83x2 + 51x + 67, x3 + 97x2 + 40x + 38) in GF(101) = 9x+96 5. 4.27, Fourth Edition Q A1(x) A2(x) A3(x) B1(x) B2(x) B3(x) ‐ 1 0 x4 + x + 1 0 1 x3 + x + 1 x 0 1 x3 + x + 1 1 ‐x x2 + 1 x 1 ‐x x2 + 1
‐x
1 + x2 1
Via the Extended Euclidian Algorithm, we see that the multiplicative inverse of x3 + x + 1 in GF(24), with m(x) = x4 + x + 1 is 1 + x2 Indeed: (x2 + 1)*( x3 + x + 1) = x5 + x3 + x2 + x3 + x + 1 = x5 + 2x3 + x2 + x + 1 = x5 + x2 + x + 1 _x_________ x4 + x + 1 ) x5 + x2 + x + 1 ‐(x5 + x2 + x ) 1 6. f(x) = 10011110 = x7 + x4 + x3 + x2 + x g(x) = 00100110 = x5 + x2 + x m(x) = 100011010 = x8 + x4 + x3 + x f(x) * g(x) = x5(f(x)) + x2(f(x)) + x(f(x)) x5*f(x) = 01010100 1. x*f(x) = x * (10011110) = 00111100 (+) x2*f(x) = 01001100 (+) 00011010 00100110 00011000 (+) x*f(x) = 00100110 00111110 2. x2*f(x) = 01001100 3. x3*f(x) = 10011000 4. x4*f(x) = 00110000 Thus, f(x)*g(x) mod m(x) is 00111110 or: (+) 00011010 5 4 3 2
00101010 x +x +x +x +x 5
5. x *f(x) = 01010100 
Download