11.07.2015 Views

Cryptography - Sage

Cryptography - Sage

Cryptography - Sage

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

is 624499148328708779 — pretty much a random number of size q. On the other hand,if we reduce modulo p, the result is 1. This follows from Fermat’s little theorem, since2.powermod(p − 1, pq) mod p is equal to the result 2.powermod(p − 1, p).Exercise 7.3 Let g(x) = x 17 + x 5 + 1, and use the function powermod to verify the polynomialanalogue of Fermat’s little theorem for the polynomials x, x 2 + x + 1, etc.Solution. For the polynomial g(x) = x 17 + x 5 + 1, we should use exponent e = 2 17 − 1,which we note is prime. We verify that each of the results x.powermod(e, g) and (x 2 + x +1)powermod(e, g) is 1. Since e is prime, this proves that g(x) is not only irreducible, butalso primitive.Exercise 7.4 Let h(x) = x 17 + x 15 + x 10 + x 5 + 1 and compute a(x) 217 −1 mod g(x)h(x) forvarious a(x). What is the result reduced modulo g(x)? Why does the same not hold truefor a(x) 217 −1 mod g(x)h(x), reduced modulo h(x)?Solution. With g(x) as above and h(x) = x 17 + x 15 + x 10 + x 5 + 1, the resultsx.powermod(e,gh).mod(g) equals 1 holds as expected, exactly as in the previous exercise.In this case, if h(x) is also irreducible, then the result:x.powermod(e, gh) mod h = x 16 + x 15 + x 14 + x 11 + x 10 + x 8 + x 6 + x 3 + 1would also have been 1. The fact that this result does not give 1 is a consequence of thereducibility of h:h = (x 3 + x 2 + 1)(x 14 + x 13 + x 11 + x 8 + x 5 + x 4 + x 3 + x 2 + 1).Public Key <strong>Cryptography</strong>The RSA cryptosystem is based on the difficulty of factoring large integers into its compositeprimes.Based on Fermat’s little theorem, we know that a m ≡ 1 mod p exactly when p−1 dividesm. Therefore we recover the identity a u ≡ a mod p where u is of the form 1 + (p − 1)r.Now given any e such that e and p − 1 have no common divisors, there exists a d such thated ≡ 1 mod p − 1. In other words, u = ed is of the form 1 + (p − 1)r. This means that themapa ↦→ a e mod pfollowed bya e mod p ↦→ (a e mod p) d mod p ≡ a ed mod p = a mod pare inverse maps. This only works for a prime p.123

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!