Primality Proving with Cyclotomy
Total Page:16
File Type:pdf, Size:1020Kb
@ PRIMALITY PROVING WITH CYCLOTOMY PRIMALITY PROVING WITH CYCLOTOMY ACADEMISCH PROEFSCHRIFT ter verkrijging van de graad van doctor aan de Universiteit van Amsterdam, op gezag van de Rector Magnificus prof. dr. S. K. Thoden van Velzen in het openbaar te verdedigen in de Aula der Universiteit (Oude Lutherse Kerk, ingang Singel 411, hoek Spui), op donderdag 20 december 1990 te 16.30 uur en te 17.30 uur door WIEBREN BOSMA geboren te Den Burg (Texel) en MARCUS PAULUS MARIA VAN DER HULST geboren te Amsterdam promotores: prof. dr. H. W. Lenstra, Jr. dr. P. van Emde Boas copromotor: dr. A. K. Lenstra promotiecommissie: prof. dr. G. B. M. van der Geer prof. dr. H. Jager dr. R. J. Schoof prof. dr. P. M. B. Vit´anyi Faculteit Wiskunde en Informatica iv Mais ne trouvez vous pas que c'est presque faire trop d'honneur aux nombres premiers que d'y r´epandre tant de richesses, et ne doit-on aucun ´egard au gout^ raffin´e de notre si`ecle? Daniel Bernoulli, Letter to L. Euler, 18 March 1778. v vi CONTENTS. Preface. ix I. History. 1 1. Terminology. 2 2. Complexity. 5 3. Trial division. 10 4. Difference of squares. 12 5. Quadratic forms. 14 6. The converse of Fermat's theorem. 18 7. Tests of Lucas-Lehmer type. 24 8. Pseudoprimes. 34 9. The Gauss sum test. 38 10. Abelian varieties. 42 11. Miscellaneous results. 49 II. Theory. 53 1. Compositeness testing. 54 2. Cyclotomic constellations. 57 3. Characters and Gauss sums. 64 4. Constructing cyclotomic constellations. 70 5. Lucas-Lehmer type tests. 80 6. The Jacobi sum test. 84 7. Combining Jacobi sum and Lucas-Lehmer type tests. 93 8. Jacobi sums. 98 9. The final stage. 106 III. Optimization. 109 1. Introduction. 110 2. Finding an optimal matching. 114 3. Choosing s. 123 4. Choosing t. 130 5. Choosing v. 133 6. Factoring time. 136 IV. Algorithm. 141 1. Outline of the algorithm. 142 2. Preparation of tables. 145 3. Initializations. 154 4. Optimization. 157 5. Lucas-Lehmer and Jacobi sum tests. 170 6. Final trial divisions. 181 vii V. Analysis. 185 1. Preliminaries. 186 2. Size of the parameters. 188 3. Analysis of the preparation of the tables. 198 4. Analysis of the Jacobi sum part of the algorithm. 209 5. Generated proof. 216 6. Inverting an integer matrix. 219 VI. Performance. 225 1. Introduction. 226 2. Approximate functions for basic operations. 227 3. Performance of the test. 241 4. A large example. 247 5. Comparison. 259 VII. Instructions for use. 265 1. Introduction. 266 2. Setting up. 269 3. Running a primality test. 274 4. Helping your primality test. 281 5. Restarting or parallelizing the primality test. 283 Tables. 287 1. Values of t and e(t). 288 2. Extensions (minimum polynomials, discriminants, matrices). 301 3. Gauss sums as products of Jacobi sums. 312 Bibliography. 317 List of symbols. 328 Index. 333 Samenvatting. 336 viii PREFACE. This thesis consists of seven chapters, and five appendices. In the first chapter the history of the primality testing problem is outlined. The second chapter comprises a mathematical description of the primality test that is the main subject of this thesis. In particular, it is proved in this chapter that the conditions that an integer n must satisfy in order to pass the test are sufficient to prove the primality of n. In the third chapter some problems (and their solutions) are discussed that regard the optimal choice of the parameters in the test. A detailed description of the primality test is given in the fourth chapter. In the fifth chapter the complexity bounds of the algorithm are given and some heuristics necessary to obtain these bounds are presented. In the sixth chapter an overview is given of the performance of the primality test, and the seventh chapter is intended to be a guideline for those people interested in installing and using the computer program that accompanies this thesis. Finally, the appendices consist of some tables that are part of the computer program, a bibliography, a list of symbols, an index, and a Dutch summary. The primality testing algorithm, as described in Chapter IV, is a modified version of the so- called Jacobi sum test (cf. [29], [30]). The main theoretical improvements are the following. First of all, it turned out to be possible, and very fruitful, to combine the Jacobi sum test with Lucas-Lehmer type tests (which are classically used for primes of a special form), by putting everything in the same mathematical framework; see Sections II.5 and II.7. The second improvement makes the new algorithm faster: a Jacobi sum test, which consists of the verification of an identity (involving Jacobi sums), will in general be done in a smaller ring. The construction of the rings necessary for this is explained in Section II.4. Thirdly, it has been possible to reduce the amount of work involved, by doing several of such Jacobi sum tests simultaneously; this is explained in Section II.8. To find good combinations of tests, and to determine good values for all parameters in the improved primality test, an intricate optimization stage had to be built into the algorithm (see Chapter III). The effect of these changes on the performance of the algorithm (both in a theoretical and a practical sense), is explained in Chapters V and VI. An important conclusion is, that in practice the improved algorithm performs better than any other general purpose primality proving algorithm that is currently known, in two respects: it is faster, and it is capable of coping with larger primes. ix This thesis is the product of joint work. Wieb Bosma is primarily responsible for the first three chapters, containing a description of the theoretical aspects of the subject, while the last three chapters, devoted to the algorithmical aspects, are mainly the responsibility of Marc-Paul van der Hulst. Chapter IV combines both theoretical and algorithmical aspects and the responsibility is therefore shared by the authors. Most of the research for this thesis has been done between June 1985 and July 1989 at the Faculteit Wiskunde en Informatica of the Universiteit van Amsterdam. Part of it has been carried out while the authors visited the University of California at Berkeley1, the Department of Computer Science of the University of Chicago, and while Marc-Paul van der Hulst visited Bell Communications Research in Morristown, New Jersey. The authors thank all of the above institutions for their hospitality, and for providing the facilities to generate and test the computer programs. This thesis could not have been written without the support of many. Here, the authors take the opportunity to express their gratitude to the following persons for contributions to their scientific well-being. We owe many thanks to Peter van Emde Boas for his continuing support and en- couragement. We wish to convey special thanks to Arjen Lenstra, for his contributions, his energy, and his inspiration. Finally, it is a pleasure to express very special thanks to Hendrik Lenstra, for pointing it all out with endless patience and good humour. October 1990, Wieb Bosma2 Marc-Paul van der Hulst3 Department of Pure Mathematics Faculteit Wiskunde en Informatica University of Sydney Universiteit van Amsterdam Sydney Amsterdam 1 Made possible by teaching assistantships at the Department of Mathematics and a research assis- tantship at the Department of Electrical Engineering and Computer Science (supported by the National Science Foundation under Grant No. DMS-8706176). 2 Supported by the Nederlandse organisatie voor wetenschappelijk onderzoek NWO (formerly ZWO) via the Stichting Mathematisch Centrum SMC. 3 Supported by the Nederlandse organisatie voor wetenschappelijk onderzoek NWO (formerly ZWO) via the Stichting Informatica Onderzoek in Nederland SION. x I. HISTORY. 1. Terminology. 2 2. Complexity. 5 3. Trial division. 10 4. Difference of squares. 12 5. Quadratic forms. 14 6. The converse of Fermat's theorem. 18 7. Tests of Lucas-Lehmer type. 24 8. Pseudoprimes. 34 9. The Gauss sum test. 38 10. Abelian varieties. 42 11. Miscellaneous results. 49 I. History 1. Terminology 1. TERMINOLOGY. The fundamental theorem of arithmetic states that every positive integer n has a unique prime factor decomposition: n = pk(p): p Yprime This thesis is concerned with a problem that arises when one tries to find prime factor decompositions. In finding such factorizations, three steps can be recognized; these steps are applied recursively if necessary. Loosely speaking they are the following. (i) Find out whether n is prime or composite. (ii) If n is prime, prove its primality. (iii) If n is composite, find n1 and n2 in Z 2 such that n = n1n2. ≥ The second step, called primality testing, covers the field we will concern ourselves with. In this first section, we will present motivation for interest in the problem, and we will introduce the basic terminology. The rest of this chapter describes some of the historic attempts to conquer the problem, in particular in relation to the algorithm presented in the next chapters. A primality testing algorithm, or primality test for short, is an algorithm that, on input a prime number n, outputs a proof for the primality of n; if the input n is a composite number however, the algorithm need not terminate, but if it does, a proof for the compositeness of n is supplied. Thus, as was suggested in the formulation of step (ii) above, a primality test is a primality prover. This raises several questions; first of all: what is a primality proof? This is closely related to the question: what is an algorithm? We do not want to go into (interesting but distracting) details here, but content ourselves with the following.