AN INTRODUCTION TO Number Theory with Cryptography James S Kraft Gilman School Baltimore, Maryland, USA Lawrence C Washington University of Maryland College Park, Maryland, USA CRC Press Taylor & Francis Group Boca Raton London New York CRC Press is an imprint of the Taylor & Francis Croup, an informa business A CHAPMAN & HALL BOOK
Contents Preface xv 0 Introduction 1 01 Diophantine Equations 2 02 Modular Arithmetic 4 03 Primes and the Distribution of Primes 5 04 Cryptography 7 1 Divisibility 9 11 Divisibility 9 12 Euclid's Theorem 11 13 Euclid's Original Proof 13 14 The Sieve of Eratosthenes 15 15 The Division Algorithm 17 151 A Cryptographic Application 19 16 The Greatest Common Divisor 20 17 The Euclidean Algorithm 22 171 The Extended Euclidean Algorithm 25 18 Other Bases 30 19 Linear Diophantine Equations 32 110 The Postage Stamp Problem 38 111 Fermat and Mersenne Numbers 41 112 Chapter Highlights 46 113 Problems 46 1131 Exercises 46 1132 Projects 53 1133 Computer Explorations 55 vii
viii Contents 1134 Answers to "Check Your Understanding" 57 2 Unique Factorization 59 21 Preliminary Results 59 22 The Fundamental Theorem of Arithmetic 61 23 Euclid and the Fundamental Theorem of Arithmetic 66 24 Chapter Highlights 67 25 Problems 67 251 Exercises 67 252 Projects 68 253 Answers to "Check Your Understanding" 70 3 Applications of Unique Factorization 71 31 A Puzzle 71 32 Irrationality Proofs 73 321 Four More Proofs That y/2 Is Irrational 75 33 The Rational Root Theorem 77 34 Pythagorean Triples 80 35 Differences of Squares 86 36 Prime Factorization of Factorials 88 37 The Riemann Zeta Function 90 38 Chapter Highlights 96 39 Problems 96 391 Exercises 96 392 Projects 100 393 Computer Explorations 104 394 Answers to "Check Your Understanding" 105 4 Congruences 107 41 Definitions and Examples 107 42 Modular Exponentiation 115 43 Divisibility Tests 116 44 Linear Congruences 120 45 The Chinese Remainder Theorem 127
ix 46 Fractions mod m 132 47 Fermat's Theorem 134 48 Euler's Theorem 139 49 Wilson's Theorem 147 410 Queens on a Chessboard 149 411 Chapter Highlights 151 412 Problems 151 4121 Exercises 151 4122 Projects 159 4123 Computer Explorations 163 4124 Answers to "Check Your Understanding" 164 5 Cryptographic Applications 167 51 Introduction 167 52 Shift and Affine Ciphers 170 53 Secret Sharing 175 54 RSA 177 55 Chapter Highlights 184 56 Problems 184 561 Exercises 184 562 Projects 188 563 Computer Explorations 191 564 Answers to "Check Your Understanding" 192 6 Polynomial Congruences 193 61 Polynomials Mod Primes 193 62 Solutions Modulo Prime Powers 196 63 Composite Moduli 202 64 Chapter Highlights 203 65 Problems 203 651 Exercises 203 652 Projects 204 653 Computer Explorations 205
x Contents 654 Answers to "Check Your Understanding" 206 7 Order and Primitive Roots 207 71 Orders of Elements 207 711 Fermat Numbers 209 712 Mersenne Numbers 211 72 Primitive Roots 211 73 Decimals 217 731 Midy's Theorem 220 74 Card Shuffling 222 75 The Discrete Log Problem 224 751 Baby Step-Giant Step Method 226 752 The Index Calculus 228 76 Existence of Primitive Roots 231 77 Chapter Highlights 233 78 Problems 234 781 Exercises 234 782 Projects 238 783 Computer Explorations 239 784 Answers to "Check Your Understanding" 240 8 More Cryptographic Applications 241 81 Diffie-Hellman Key Exchange 241 82 Coin Flipping over the Telephone 243 83 Mental Poker 246 84 The ElGamal Public Key Cryptosystem 250 85 Digital Signatures 253 86 Chapter Highlights 255 87 Problems 255 871 Exercises 255 872 Projects 259 873 Computer Explorations 260 874 Answers to "Check Your Understanding" 260
- 1 xi 9 Quadratic Reciprocity 263 91 Squares and Square Roots Mod Primes 263 92 Computing Square Roots Mod p 270 93 Quadratic Equations 272 94 The Jacobi Symbol 274 95 Proof of Quadratic Reciprocity 278 96 Chapter Highlights 285 97 Problems 286 971 Exercises 286 972 Projects 291 973 Answers to "Check Your Understanding" 293 10 Primality and Factorization 295 101 Trial Division and Fermat Factorization 295 102 Primality Testing 299 1021 Pseudoprimes 299 1022 The Pocklington-Lehmer Primality Test 304 1023 The AKS Primality Test 307 1024 Fermat Numbers 309 1025 Mersenne Numbers 311 103 Factorization 312 1031 x2 = y2 312 1032 Factoring Pseudoprimes and Factoring Us ing RSA Exponents 315 1033 Pollard's p Method 316 1034 The Quadratic Sieve 318 104 Coin Flipping over the Telephone 326 105 Chapter Highlights 328 106 Problems 329 1061 Exercises 329 1062 Projects 332 1063 Computer Explorations 333 1064 Answers to "Check Your Understanding" 334
xii Contents 11 Geometry of Numbers 337 111 Volumes and Minkowski's Theorem 337 112 Sums of Two Squares 342 1121 Algorithm for Writing p = 1 (mod 4) as a Sum of Two Squares 345 113 Sums of Four Squares 347 114 Pell's Equation 349 1141 Bhaskara's Chakravala Method 353 115 Chapter Highlights 355 116 Problems 356 1161 Exercises 356 1162 Projects 359 1163 Answers to "Check Your Understanding" 365 12 Arithmetic Functions 367 121 Perfect Numbers 367 122 Multiplicative Functions 371 123 Chapter Highlights 378 124 Problems 378 1241 Exercises 378 1242 Projects 381 1243 Computer Explorations 381 1244 Answers to "Check Your Understanding" 382 13 Continued Fractions 383 131 Rational Approximations; Pell's Equation 384 1311 Evaluating Continued Fractions 387 1312 Pell's Equation 389 132 Basic Theory 392 133 Rational Numbers 400 134 Periodic Continued Fractions 402 1341 Purely Periodic Continued Fractions 404 1342 Eventually Periodic Continued Fractions 409
xiii 135 Square Roots of Integers 411 136 Some Irrational Numbers 414 137 Chapter Highlights 420 138 Problems 421 1381 Exercises 421 1382 Projects 422 1383 Computer Explorations 425 1384 Answers to "Check Your Understanding" 425 14 Gaussian Integers 427 141 Complex Arithmetic 427 142 Gaussian Irreducibles 429 143 The Division Algorithm 433 144 Unique Factorization 436 145 Applications 442 1451 Sums of Two Squares 442 1452 Pythagorean Triples 445 1453 y2 = x3-1 447 146 Chapter Highlights 448 147 Problems 449 1471 Exercises 449 1472 Projects 450 1473 Computer Explorations 450 1474 Answers to "Check Your Understanding" 450 15 Algebraic Integers 453 151 Quadratic Fields and Algebraic Integers 453 152 Units 458 153 Z[y^2] 462 154 Z[y/3] 466 1541 The Lucas-Lehmer Test 469 155 Non-unique Factorization 472 156 Chapter Highlights 474
xiv Contents 157 Problems 475 1571 Exercises 475 1572 Projects 476 1573 Answers to "Check Your Understanding" 478 16 Analytic Methods 479 161 Y, l/p Diverges 479 162 Bertrand's Postulate 485 163 Chebyshev's Approximate Prime Number Theorem 493 164 Chapter Highlights 499 165 Problems 499 1651 Exercises 499 1652 Projects 500 1653 Computer Explorations 501 17 Epilogue: Fermat's Last Theorem 503 171 Introduction 503 172 Elliptic Curves 506 173 Modularity 510 A Supplementary Topics 513 Al Geometric Series 513 A2 Mathematical Induction 515 A3 Pascal's Triangle and the Binomial Theorem 521 A4 Fibonacci Numbers 526 A5 Problems 530 A51 Exercises 530 A52 Answers to "Check Your Understanding" 532 B Answers and Hints for Odd-Numbered Exercises 535 Index 549