Lecture Notes in Computer Science Commenced Publication in 1973 Founding and Former Series Editors: Gerhard Goos, Juris Hartmanis, and Jan van Leeuwen
Editorial Board David Hutchison Lancaster University, UK Takeo Kanade Carnegie Mellon University, Pittsburgh, PA, USA Josef Kittler University of Surrey, Guildford, UK Jon M. Kleinberg Cornell University, Ithaca, NY, USA Alfred Kobsa University of California, Irvine, CA, USA Friedemann Mattern ETH Zurich, Switzerland John C. Mitchell Stanford University, CA, USA Moni Naor Weizmann Institute of Science, Rehovot, Israel Oscar Nierstrasz University of Bern, Switzerland C. Pandu Rangan Indian Institute of Technology, Madras, India Bernhard Steffen TU Dortmund University, Germany Madhu Sudan Microsoft Research, Cambridge, MA, USA Demetri Terzopoulos University of California, Los Angeles, CA, USA Doug Tygar University of California, Berkeley, CA, USA Gerhard Weikum Max-Planck Institute of Computer Science, Saarbruecken, Germany
6197
Guillaume Hanrot François Morain Emmanuel Thomé (Eds.)
Algorithmic Number Theory 9th International Symposium, ANTS-IX Nancy, France, July 19-23, 2010 Proceedings
13
Volume Editors Guillaume Hanrot LIP/ENS-Lyon, 46, allée d’Italie 69364 Lyon Cedex 07, France E-mail:
[email protected] François Morain LIX/École polytechnique 91128 Palaiseau Cedex, France E-mail:
[email protected] Emmanuel Thomé INRIA Nancy, projet CARAMEL 615 rue du jardin botanique 54602 Villers-lès-Nancy Cedex, France E-mail:
[email protected]
Library of Congress Control Number: 2010930653 CR Subject Classification (1998): F.2, G.2, E.3, I.1 LNCS Sublibrary: SL 1 – Theoretical Computer Science and General Issues ISSN ISBN-10 ISBN-13
0302-9743 3-642-14517-5 Springer Berlin Heidelberg New York 978-3-642-14517-9 Springer Berlin Heidelberg New York
This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, re-use of illustrations, recitation, broadcasting, reproduction on microfilms or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. springer.com © Springer-Verlag Berlin Heidelberg 2010 Printed in Germany Typesetting: Camera-ready by author, data conversion by Scientific Publishing Services, Chennai, India Printed on acid-free paper 06/3180
Preface
ANTS-IX was the ninth edition of the biennial International Symposium on Algorithmic Number Theory. The first edition of this symposium was held at Cornell University in 1994. ANTS-IX was held July 19-23, 2010 at INRIA in Nancy, France. The ANTS-IX Program Committee consisted of 12 members whose names are listed on the next page. The selection of the accepted papers among the submissions was made from mid-January to end of March 2010. Each paper was thoroughly reviewed by at least two experts, including a Program Committee member. The Program Committee selected 25 high-quality articles, which are excellent representatives of the current state of the art in various areas of algorithmic number theory. The Selfridge Prize in computational number theory was awarded to the authors of the best contributed paper presented at the conference. We gratefully thank the authors of all submitted papers for their hard work which made the selection of a varied program possible. We also thank the authors of the accepted papers for their cooperation in the timely production of the revised versions. Each submitted paper was presented by one of its co-authors at the conference. Besides contributed papers, the conference included five invited talks by Henri Darmon (McGill University), Jean-Fran¸cois Mestre (Universit´e Paris 7), Gabriele Nebe (RWTH Aachen), Carl Pomerance (Dartmouth College), and Oded Regev (Tel-Aviv University). We thank the invited speakers for having been able to provide abstracts of their talk, which are reproduced in this volume. This list of invited speakers originally included Fritz Grunewald (HHU D¨ usseldorf), who unfortunately passed away on March 21, 2010, four months before the conference. A special lecture was held to honor his memory. The conference organizers wish to thank all the people who made the conference possible. In particular, we gratefully acknowledge the support of the funding institutions. May 2010
Guillaume Hanrot Fran¸cois Morain Emmanuel Thom´e
Organization
Organizing Committee Anne-Lise Charbonnier J´er´emie Detrey Pierrick Gaudry (Chair) Emmanuel Thom´e Paul Zimmermann
INRIA, Nancy, France INRIA, Nancy, France CNRS, Nancy, France INRIA, Nancy, France INRIA, Nancy, France
Program Committee Nigel Boston University of Wisconsin, USA John Cremona Warwick Mathematics Institute, UK Claus Fieker University of Sydney, Australia ´ Guillaume Hanrot (PC Chair) Ecole Normale Sup´erieure, Lyon, France Kevin Hare University of Waterloo, Canada ´ Thorsten Kleinjung Ecole Polytechnique F´ed´erale de Lausanne, Switzerland Kamal Khuri-Makdisi American University of Beirut, Lebanon ´ Fran¸cois Morain (PC Chair) Ecole Polytechnique, France Takakazu Satoh Tokyo Institute of Technology, Japan Igor Shparlinski Macquarie University, Australia Alice Silverberg University of California at Irvine, USA Frederik Vercauteren Katholieke Universiteit Leuven, Belgium
Poster Session Benjamin Smith
´ INRIA Saclay, Ecole Polytechnique, France
Sponsoring Institutions Institut National de Recherche en Informatique et Automatique (INRIA) Laboratoire Lorrain de Recherche en Informatique et Applications (LORIA) ´ Ecole Polytechnique Centre National de la Recherche Scientifique (CNRS) Microsoft Research, USA Nancy Universit´e Groupement de Recherches en Informatique Math´ematique (GDR IM) Communaut´e Urbaine du Grand Nancy Conseil R´egional de Lorraine
VIII
Organization
Conference Website The names of the winners of the Selfridge Prize, material supplementing the contributed papers, and errata for the proceedings (if relevant), as well as the abstracts of the posters and the posters presented at ANTS-IX, can be found at http://ants9.org/.
Table of Contents
Invited papers Putting the Hodge and Tate Conjectures to the Test . . . . . . . . . . . . . . . . . Henri Darmon Curves of Genus 3 With a Group of Automorphisms Isomorphic to S3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jean-Fran¸cois Mestre
1
2
Learning with Errors over Rings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Oded Regev
3
Lattices and Spherical Designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Gabriele Nebe
4
Fixed Points for Discrete Logarithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mariana Levin, Carl Pomerance, and K. Soundararajan
6
Contributed papers Explicit Coleman Integration for Hyperelliptic Curves . . . . . . . . . . . . . . . . Jennifer S. Balakrishnan, Robert W. Bradshaw, and Kiran S. Kedlaya
16
Smallest Reduction Matrix of Binary Quadratic Forms: And Cryptographic Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Aurore Bernard and Nicolas Gama
32
Practical Improvements to Class Group and Regulator Computation of Real Quadratic Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jean-Fran¸cois Biasse and Michael J. Jacobson Jr.
50
On the Use of the Negation Map in the Pollard Rho Method . . . . . . . . . . Joppe W. Bos, Thorsten Kleinjung, and Arjen K. Lenstra
66
An O(M (n) log n) Algorithm for the Jacobi Symbol . . . . . . . . . . . . . . . . . . Richard P. Brent and Paul Zimmermann
83
New Families of ECM Curves for Cunningham Numbers . . . . . . . . . . . . . . ´ Eric Brier and Christophe Clavier
96
Visualizing Elements of Sha[3] in Genus 2 Jacobians . . . . . . . . . . . . . . . . . . Nils Bruin and Sander R. Dahmen
110
X
Table of Contents
On Weil polynomials of K3 surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Andreas-Stephan Elsenhans and J¨ org Jahnel
126
Class Invariants by the CRT Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Andreas Enge and Andrew V. Sutherland
142
Short Bases of Lattices over Number Fields . . . . . . . . . . . . . . . . . . . . . . . . . Claus Fieker and Damien Stehl´e
157
On the Complexity of the Montes Ideal Factorization Algorithm . . . . . . . David Ford and Olga Veres
174
Congruent Number Theta Coefficients to 1012 . . . . . . . . . . . . . . . . . . . . . . . William B. Hart, Gonzalo Tornar´ıa, and Mark Watkins
186
Pairing the Volcano . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sorina Ionica and Antoine Joux
201
A Subexponential Algorithm for Evaluating Large Degree Isogenies . . . . David Jao and Vladimir Soukharev
219
Huff’s Model for Elliptic Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Marc Joye, Mehdi Tibouchi, and Damien Vergnaud
234
Efficient Pairing Computation With Theta Functions . . . . . . . . . . . . . . . . . David Lubicz and Damien Robert
251
Small-Span Characteristic Polynomials of Integer Symmetric Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . James McKee
270
Decomposition Attack for the Jacobian of a Hyperelliptic Curve over an Extension Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Koh-ichi Nagao
285
Factoring Polynomials over Local Fields II . . . . . . . . . . . . . . . . . . . . . . . . . . Sebastian Pauli
301
On a Problem of Hajdu and Tengely . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Samir Siksek and Michael Stoll
316
Sieving for Pseudosquares and Pseudocubes in Parallel Using Doubly-Focused Enumeration and Wheel Datastructures . . . . . . . . . . . . . . Jonathan P. Sorenson On the Extremality of an 80-Dimensional Lattice . . . . . . . . . . . . . . . . . . . . Damien Stehl´e and Mark Watkins
331
340
Table of Contents
Computing Automorphic Forms on Shimura Curves over Fields with Arbitrary Class Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . John Voight
XI
357
Improved Primality Proving with Eisenstein Pseudocubes . . . . . . . . . . . . . Kjell Wooding and H.C. Williams
372
Hyperbolic Tessellations Associated to Bianchi Groups . . . . . . . . . . . . . . . . Dan Yasaki
385
Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
397
Putting the Hodge and Tate Conjectures to the Test Henri Darmon Department of Mathematics, McGill University, Burnside Hall, Montreal, QC, Canada
[email protected]
The Hodge conjecture asserts that the presence of algebraic cycles on a (smooth, projective) variety over the complex numbers can be detected in its Betti cohomology equipped with the Hodge structure arising from its relation with complex deRham cohomology. The Tate conjecture makes a similar assertion with -adic cohomology replacing Betti cohomology. One of the difficulties with these conjectures is that the predictions that they make are often hard to test numerically, even in specific concrete instances. Unlike closely related parts of number theory (a case in point being the Birch and Swinnerton-Dyer conjecture) the study of algebraic cycles has therefore not been as strongly affected by the growth of the experimental and computational community as it perhaps could be. In this lecture, I will describe some numerical experiments that are designed to “test” the Hodge and Tate conjectures for certain varieties (of arbitrarily large dimension) which arise from elliptic curves with complex multiplication and theta series of CM Hecke characters.
G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, p. 1, 2010. c Springer-Verlag Berlin Heidelberg 2010
Curves of Genus 3 with a Group of Automorphisms Isomorphic to S3 Jean-Fran¸cois Mestre Centre de Math´ematiques de Jussieu Projet Th´eorie des Nombres
[email protected]
In this talk, we construct curves of genus 3 with automorphism group equal to S3 ; we give some applications of this construction to the problem of optimal curves, i.e. of curves over a finite field Fq having a number of points equal to the Serre-Weil bound Mq ; in particular, we prove that there exists infinitely many fields F3n having optimal curves; we prove also that there exists an integer C such that, for any finite field F7n , there exists a curve of genus 3 defined over having at least Mq − C points.
G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, p. 2, 2010. c Springer-Verlag Berlin Heidelberg 2010
Learning with Errors over Rings Oded Regev Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv 69978, Israel
[email protected]
The “learning with errors” (LWE) problem is to distinguish random linear equations, which have been perturbed by a small amount of noise, from truly uniform ones. The problem has been shown to be as hard as worst-case lattice problems, and in recent years it has served as the foundation for a plethora of cryptographic applications. Unfortunately, these applications are rather inefficient due to an inherent quadratic overhead in the use of LWE. After a short introduction to the area, we will discuss recent work on making LWE and its applications truly efficient by exploiting extra algebraic structure. Namely, we will define the ring-LWE problem, and prove that it too enjoys very strong hardness guarantees. Based on joint work with Vadim Lyubashevsky and Chris Peikert.
G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, p. 3, 2010. c Springer-Verlag Berlin Heidelberg 2010
Lattices and Spherical Designs Gabriele Nebe Lehrstuhl D f¨ ur Mathematik, RWTH Aachen University, Germany
[email protected]
A lattice is a finitely generated discrete subgroup of Euclidean space. Lattices are an important algorithmic tool in number theory, integral representation theory, geometry, information theory, cryptography, crystallography and have various other applications within mathematics and beyond. Any lattice has only finitely many vectors of a given length, they form the layers of the lattice, which are finite subsets of spheres in the underlying Euclidean space. A spherical design of strength t is a finite set X = ∅ in the Euclidean 1 sphere for which the mean value |X| x∈X f (x) equals the integral of f over the sphere for all polynomials f of degree up to t. This condition is equivalent to x∈X f (x) = 0 for all non-constant harmonic polynomials of degree ≤ t. Spherical designs hence consist of well distributed points on a sphere and are relevant for numerical integration, in information theory, geometry, statistics and have applications for instance in medicine. Boris Venkov combined these two concepts in a very fruitful way that allows to use lattices to classify spherical designs and to use designs for finding good lattices. An introduction to this subject as well as some applications are given in “R´eseaux euclidiens, designs sph´eriques et formes modulaires”, Enseignement Math., Geneva, 2001. There Venkov introduces the notion of a strongly perfect lattice, which is a lattice whose minimal vectors form a spherical 4-design. Using the characterization by Korkine, Voronoi and Zolotarev one shows that strongly perfect lattices realise local maxima of the sphere packing density function on the space of all similarity classes of n-dimensional lattices (in fact in the space of all periodic packings as proved by Sch¨ urmann). All local maxima of this function are known up to dimension 8. In dimension 8 Dutour, Sch¨ urmann, Vallentin and Riener proved that there are 2408 local maxima. The densest lattice sphere packings are known up to dimension 8 and, thanks to recent results by Elkies and Kumar, in dimension 24, where the Leech lattice is the densest lattice. Combining number theory and geometry with combinatorial methods allows classify strongly perfect lattices, where a full classification up to dimension 12 is obtained in joined work with Venkov. With one exception all known strongly perfect lattices Λ have the additional property that also the dual lattice Λ∗ is strongly perfect. Such lattices are called dual strongly perfect, the classification of dual strongly perfect lattices in small dimension has been completed in dimension 14 and is an ongoing PhD project by Elisabeth Nossek in Aachen. There are two general approaches to study and construct strongly perfect lattices: by modular forms and by invariant theory of finite groups. Both concepts usually allow to show that all non-empty layers of the lattice form spherical G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 4–5, 2010. c Springer-Verlag Berlin Heidelberg 2010
Lattices and Spherical Designs
5
4-designs. Such lattices are called universally perfect and play a role in Riemannian geometry. If Λ is a universally perfect lattice then the torus Rn /Λ∗ defined by the dual lattice Λ∗ provides a strict local minimum of the height function on the set of all n-dimensional flat tori. R. Coulangeon also shows that universally perfect lattices Λ achieve local minima of Epstein’s zeta function, they are so called ζ-extreme lattices. The question to find ζ-extreme lattices has a long history going back to Sobolev’s work on numerical integration and to work of Delon´e. Universally perfect lattices are dual strongly perfect. The relation with modular forms arises, because the condition that the minimal vectors of the lattice form a 4-design means the annihilation of certain coefficients in its theta series with harmonic coefficients. In this way one can prove the strong perfectness of many extremal lattices of small level. For example there are more than 106 even unimodular lattices without roots in dimension 32 (by work of Oliver King) and the theory of modular forms shows that all of them are universally perfect; this is the only known method to prove that all these lattices are locally densest lattices. If a lattice Λ has a big automorphism group G := Aut(Λ) which has no invariant harmonic polynomials of degree 2 and 4, a condition easily expressed in terms of the character of G ≤ O(n), then Λ is universally perfect. There are many interesting lattices such as the Barnes-Wall lattices, the 248-dimensional Thompson-Smith lattice and others which are strongly perfect by this reason. Tiep and others used representation theory to classify certain matrix groups G for which all orbits form spherical 4-designs. On the other hand lattices are an important tool to find and classify good spherical designs. Fixing the strength t and the dimension n, one tries to find spherical t-designs X ⊂ S n−1 of minimal possible cardinality. If t = 2m is even, then n−1+m n−2+m |X| ≥ + m m−1 and if t = 2m + 1 is odd then n−1+m |X| ≥ 2 . m A t-design X for which equality holds is called a tight t-design. Tight t-designs in Rn with n ≥ 3 are very rare. Bannai has shown that such tight designs only exist if t ≤ 5 and t = 7, 11. The tight t-designs with t = 1, 2, 3 as well as t = 11 are completely classified whereas their classification for t = 4, 5, 7 is still an open problem. It is conjectured that there are just seven tight t-designs of dimension n ≥ 3 and strength 4, 5, 7, namely in dimensions 6,22 (t=4), 3,7,23 (t=5) respectively 8,23 (t=7); each of these is known to be unique. One possible approach to prove that there are no further tight designs X is to investigate the Euclidean lattice Λ generated by X and to obtain properties of Λ (such as its determinant or its minimum) from the design properties of X and then prove the non existence of such a lattice Λ. This strategy has been successfully applied by Bannai, Munemasa and Venkov to show that there are no further tight designs up to dimension 103.
Fixed Points for Discrete Logarithms Mariana Levin1 , Carl Pomerance2, and K. Soundararajan3 1
Graduate Group in Science and Mathematics Education University of California Berkeley, CA 94720, USA
[email protected] 2 Department of Mathematics Dartmouth College Hanover, NH 03755, USA
[email protected] 3 Department of Mathematics Stanford University Stanford, CA 94305, USA
[email protected]
Abstract. We establish a conjecture of Brizolis that for every prime p > 3 there is a primitive root g and an integer x in the interval [1, p − 1] with logg x = x. Here, log g is the discrete logarithm function to the base g for the cyclic group (Z/pZ)× . Tools include a numerically explicit “smoothed” version of the P´ olya–Vinogradov inequality for the sum of values of a Dirichlet character on an interval, a simple lower bound sieve, and an exhaustive search over small cases.
1
Introduction
If g is an element in a group G and t ∈ g, there is some integer n with g n = t. Finding a valid choice for n is known as the discrete logarithm problem. Note that if g has finite order m, then n is actually a residue class modulo m. We write logg t = n (or logg t ≡ n (mod m)) in analogy to usual logarithmic notation. Thus, the problem in the title of this paper does not seem to make good sense, since if logg x = x, then the first x is a member of the group g and the second x is either an integer or a residue class modulo m. However, sense is made of the equation through the traditional conflation of members of the ring Z/kZ with least nonnegative members of residue classes.
The work for this paper was begun at Bell Laboratories in 2001 while the first author was a summer student working with the second author. A version of this work was presented as the 2003 Master’s Thesis of the first author at U. C. Berkeley, see [3]. The second author was supported in part by NSF grant DMS-0703850. The third author was supported in part by NSF grant DMS-0500711.
G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 6–15, 2010. c Springer-Verlag Berlin Heidelberg 2010
Fixed Points for Discrete Logarithms
7
In particular, suppose G = (Z/pZ)× , where p is a prime number. This is known to be a cyclic group of order p − 1. Suppose g is a cyclic generator of this group, known as a primitive root for p. A fixed point for the discrete logarithm modulo p to the base g is then an integer x in the interval [1, p − 1] such that logg x = x, that is, g x ≡ x (mod p). (Note that if x is not restricted to the interval [1, p − 1] it is easy to find fixed points. Namely, if x is a solution to the Chinese remainder problem x ≡ 1 (mod p − 1), x ≡ g (mod p), then g x ≡ x (mod p).) Brizolis (see Guy [6, Section F9]) made the conjecture that for every prime p > 3 there is a primitive root g and an integer x in [1, p − 1] with logg x = x, that is, g x ≡ x (mod p). In this paper we prove this conjecture in a somewhat stronger form. Brizolis had noticed that if there is a primitive root x for p with x in [1, p − 1] and gcd(x, p − 1) = 1, then with y the multiplicative inverse of x modulo p − 1 and g = xy , we would have that g is a primitive root for p as well, and g x ≡ xxy ≡ x (mod p), that is, there is a solution to the fixed point problem. We shall prove then the stronger result that for each prime p > 3 there is a primitive root x for p in [1, p − 1] that is coprime to p − 1. Several authors have shown that the Brizolis property holds for all sufficiently large primes p. In particular, Zhang [12] showed the strong conjecture holds for all sufficiently large primes p, but did not give an estimate of what “sufficiently large” is. Cobeli and Zaharescu [4] also showed that the strong conjecture holds for sufficiently large primes p, and gave the details that it holds for all p > 102070 , but they indicated that their method would support a bound around 1050 . Our method is similar to that of Zhang, who used the P´ olya–Vinogradov inequality for character sums on an interval. Here we introduce a numerically explicit “smoothed” version of this inequality, see §2. In addition, we combine the traditional character-sum approach with a simple lower bound sieve. There is still some need for direct calculation for smaller values of p, which are easily handled by a short Mathematica program. In particular, we directly verified the strong conjecture for each prime p < 1.25 · 109 . We mention the article by Holden and Moree [8], which considers some related problems. The total number of solutions to g x ≡ x (mod p) as p runs up to some high bound N , where either g is restricted to be a primitive root, and where it is not so restricted, is considered in Bourgain, Konyagin, and Shparlinski [2]. The smoothed version of the P´ olya–Vinogradov inequality that we introduce in the next section is quite simple and the proof is routine, so it may be known to others. We have found it to be quite useful numerically; we hope it will find applications in “closing the gap” in other problems where character sums arise. Some notation: ω(n) denotes the number of distinct prime divisors of n.
8
2
M. Levin, C. Pomerance, and K. Soundararajan
A “Smoothed” P´ olya–Vinogradov Inequality
Let χ be a non-principal Dirichlet character to the modulus q. The P´ olya– Vinogradov inequality (independently discovered by P´ olya and Vinogradov in 1918) asserts that there is a universal constant c such that ≤ c√q log q χ(a) (1) M≤a≤M+N for any choice of numbers M, N . Let N (p) denote the numer of primitive roots g for p with g ∈ [1, p − 1] and gcd(g, p − 1) = 1. Using (1) one can show (see Zhang [12] and Campbell [3]) that N (p) =
ϕ(p − 1)2 + O(p1/2+ ), p−1
for every fixed > 0, and so N (p) > 0 for all sufficiently large p. The aim of this paper is to close the gap and find the complete set of primes p with N (p) > 0. Towards this end it would be useful to have a numerically explicit version of (1). In [3], the theorem of Bachman and Rachakonda [1] was used (plus a small unpublished improvement on a secondary term in their inequality due to the second author of the present paper). Recently, elaborating on the work in an early paper of Landau [10], plus an idea of Bateman as mentioned in Hildebrand [7], the second author in [11] proved a stronger numerically explicit version of (1). Using this simplifies the approach in [3]. However, we have found a way to simplify even further by using a “smoothed” version of (1). In this section we prove the following theorem. Theorem 1. Let χ be a primitive Dirichlet character to the modulus q > 1 and let M, N be real numbers with 0 < N ≤ q. Then √ a − M N − 1 ≤ q − √ . χ(a) 1 − N q M≤a≤M+2N Proof. We use Poisson summation, see [9, §4.3]. Let H(t) = max{0, 1 − |t|}. We wish to estimate |S|, where S :=
χ(a)H
a∈Z
a−M −1 . N
Towards this end we use the identity 1 χ(a) = χ(j)e(aj/q), ¯ τ (χ) ¯ j=0 q−1
Fixed Points for Discrete Logarithms
9
where τ (χ) ¯ is the Gauss sum for χ ¯ and e(x) := e2πix . Thus, 1 χ(j) ¯ e(aj/q)H τ (χ) ¯ j=0 q−1
S=
a∈Z
a−M −1 . N
The Fourier transform of H is ∞ 1 − cos 2πs ˆ ˆ H(s) = H(t)e(−st) dt = when s = 0, H(0) = 1, 2π 2 s2 −∞ which is nonnegative for s real. By a change of variables in the integral, we see that the Fourier transform of e(jt/q)H((t − M )/N − 1) is ˆ (s − j/q)N . N e − (M + N )(s − j/q) H Hence, by Poisson summation, we have q−1 N ˆ (n − j/q)N . χ(j) ¯ e − (M + N )(n − j/q) H S= τ (χ) ¯ j=0 n∈Z
Estimating trivially (that is, taking the absolute value of each term) and using ˆ nonnegative and χ(0) = 0, we have H q−1 N ˆ N ˆ kN |S| ≤ √ H (n − j/q)N = √ H . q j=1 q q n∈Z
k∈Z\qZ
ˆ Since (N/q)H(sN/q) is the Fourier transform of H(qt/N ), from the last calculation we have
N kN N ˆ √ N ˆ kN √ ˆ H H |S| ≤ q ≤ q − H(0) + q q q q q k∈Z k∈Z\qZ
ql √ N √ N √ N H = q − + = − √ + qH(0) = q − √ , q N q q l∈Z
by another appeal to Poisson summation and the definition of H. This completes the proof of the theorem. In our application we will need a version of Theorem 1 with the variable a satisfying a coprimality condition. We deduce such a result below. Corollary 2. Let k be a square-free integer and let χ be a primitive character to the modulus q > 1. For 0 < N ≤ q, we have √ a always 2ω(k) q χ(a) 1 − − 1 ≤ ω(k)−1 √ N q if k is even. 2 0≤a≤2N (a,k)=1
10
M. Levin, C. Pomerance, and K. Soundararajan
Proof. Since d|(k,a) μ(d) gives 1 if (a, k) = 1 and 0 otherwise, the sum in question equals ad − 1 μ(d)χ(d) χ(a) 1 − N d|k
a≤2N/d
√ and using Theorem 1 this is bounded in size by 2ω(k) q as desired. If (k, q) is even, then χ(d) = 0 for even divisors d of k, so that we achieve the bound √ 2ω(k)−1 q, again as desired. Suppose now that k is even and q is odd. For each odd divisor d of k, we group together the contribution from d and 2d, and so we may write the sum in question as ad − 1 . μ(d)χ(d) χ(a) 1 − N d|k/2
a≤2N/d a odd
We replace a in the inner sum by q + a, and since q is now odd, the condition that a is odd may be replaced with the condition that q + a = 2b is even. Thus, the above sum becomes 2d(b − q/2) μ(d)χ(d)χ(2) χ(b) 1 − − 1 , N d|k/2
q/2≤b≤q/2+N/d
and appealing again to Theorem 1 we obtain the Corollary in this case. Though we will not need it for our proof, we record the following corollary of Theorem 1. Corollary 3. Let χ be a primitive Dirichlet character to the modulus q > 1 and let M, N be real numbers with N > 0. Then, with θ the fractional part of N/q, q 3/2 a − M − 1 ≤ θ(1 − θ). χ(a) 1 − N N M≤a≤M+2N
3
A Criterion for the Brizolis Property
Let us write the largest square-free divisor of p − 1 as uv where u and v will be chosen later. We shall assume that u is even, and have in mind the situation that u is composed of the small prime factors of p − 1, and that v is composed of the large prime factors; we also allow for the possibility that v = 1. For the rest of the paper, the letter will denote a prime number. Let S denote the set of primitive roots in [1, p − 1] that are coprime to p − 1. Thus, an integer g ∈ [1, p − 1] is in S if and only if for each prime | p − 1 we have both g and g is not an -th power (mod p). Let S1 denote the set of integers in [1, p − 1] that are coprime to u and which are not equal to an -th power (mod p) for any prime dividing u. Let S2 denote the set of integers in S1 which are divisible by some prime which divides v. Let S3 denote the set
Fixed Points for Discrete Logarithms
11
of integers in S1 which equal an -th power (mod p) for some prime dividing v. Now S ⊂ S1 , and the elements in S1 that are not in S are precisely those that, for some prime | v, are either divisible by or are an -th power (mod p). Thus, S = S1 \(S2 ∪ S3 ). We seek a positive lower bound for N :=
g∈S
2g 1− − 1 , p−1
since if N > 0, then S = ∅. By our observation above we have N ≥ N1 − N2 − N3 , where, for j = 1, 2, 3, Nj =
g∈Sj
2g 1− − 1 . p−1
If d is a square-free divisor of p − 1 and g is an integer in [1, p − 1], let Cd (g) be 1 if g is a d-th power (mod p) and 0 otherwise. Thus, Cd (g) =
C (g) =
|d
⎛ 1 ⎝ = 1+ d |d
1 |d
χ of order
Note that
χ(g)
χ =χ0
⎞
1 χ(g)⎠ = d
χ(g).
m|d χ of order m
μ(d)Cd (g)
d|u
is 1 if, for each | u, g is not an -th power (mod p), and is 0 otherwise. By the above calculation, this expression is μ(d) d|u
d
χ(g) =
m|d χ of order m
χ(g)
m|u χ of order m
μ(nm) . nm
n|u/m
The inner sum here is (ϕ(u)/u)μ(m)/ϕ(m), so that N1 =
ϕ(u) u
1≤g≤p−1 (g,u)=1
2g μ(m) 1− − 1 p−1 ϕ(m) m|u
χ(g).
(2)
χ of order m
Let m | u with m > 1. Using Corollary 2, the terms above contribute an amount bounded in magnitude by ϕ(u) ω(u)−1 √ 2 p, u
12
M. Levin, C. Pomerance, and K. Soundararajan
so the total contribution over all m | u with m > 1 has magnitude at most √ ϕ(u) ω(u) 2 − 1 2ω(u)−1 p. u The sum over g in (2) with m = 1 (and so χ = χ0 ) is ϕ(u) u
1≤g≤p−1 (g,u)=1
2g ϕ(u) 1− − 1 = μ(d) p−1 u d|u
h≤(p−1)/d
2dh 1− − 1 . p−1
The inner sum over h can be evaluated explicitly: it equals (p−1)/(2d) if (p−1)/d is even, and it equals (p − 1)/(2d) − d/(2(p − 1)) if (p − 1)/d is odd. It follows that the contribution when m = 1 is 2 ϕ(u) 1 p − 1 ϕ(u) − dμ(d) u 2 u 2(p − 1) ≥
ϕ(u) u
We conclude that 2 ϕ(u) N1 ≥ u 2 ϕ(u) > u
2
d|u (p−1)/d odd
ϕ(u)2 p−1 − ≥ 2 u(p − 1)
ϕ(u) u
2
p ϕ(u) − . 2 u
p ϕ(u) ϕ(u) ω(u) √ − − 2 − 1 2ω(u)−1 p 2 u u p ϕ(u) ω(u) √ − 4 p. 2 2u
Next we turn to N2 . Since an element in S2 must be divisible by some prime |v we have that 2h ϕ(u) μ(m) 1− − 1 N2 ≤ χ(h ). p−1 u ϕ(m) |v h≤(p−1)/ (h,u)=1
χ of order m
m|u
If v = 1, then N2 = 0, so assume v > 1. The terms with m > 1 contribute, using Corollary 2, an amount bounded in size by ϕ(u) √ ω(v) 2ω(u) − 1 2ω(u)−1 p. u The main term m = 1 above contributes (arguing as in our evaluation of the main term for N1 above) ϕ(u) u
|v h≤(p−1)/ (h,u)=1
2h ϕ(u) 2 p − 1 1− − 1 ≤ + . p−1 u 2 v |v
Fixed Points for Discrete Logarithms
Since
|v
N2 ≤ ≤
13
≤ v, and using v > 1, we conclude that
ϕ(u) u ϕ(u) u
2 2
p−1 1 + 2
|v
p1 2
|v
+
ϕ(u) u
2 +
ϕ(u) √ ω(v) 2ω(u) − 1 2ω(u)−1 p u
ϕ(u) ω(u) √ 4 ω(v) p. 2u
Lastly we consider N3 . An element g of S3 must be an -th power for some prime |v, and the indicator function for this condition is 1 ψ =χ0 ψ(g), as seen above. Therefore we have that N3 is at most |v g≤p−1 (g,u)=1
2g ϕ(u) μ(m) 1− − 1 p−1 u ϕ(m) m|u
χ of order m
1 χ(g) ψ(g) . ψ =χ0
Appealing to Corollary 2 for the terms above with χψ = χ0 we find that the contribution of such terms is bounded in magnitude by √ ϕ(u) 2ω(u)−1 2 ω(v) p. u The main term χ = ψ = χ0 gives 2g ϕ(u) ϕ(u) p − 1 ϕ(u) 1 ϕ(u) 1 1− − 1 ≤ + u p−1 u u 2 p−1 |v
g≤p−1 (g,u)=1
=
|v
ϕ(u) u
Thus,
2
N3 ≤
p−1 1 + 2 v
ϕ(u) u
2
|v
1 ≤
ϕ(u) u
2
p1 . 2 |v
p 1 ϕ(u) ω(u) √ + 4 ω(v) p. 2 2u |v
Combining these bounds for N1 , N2 and N3 we obtain that N≥
ϕ(u) u
2 1 ϕ(u) p √ 1−2 − 4ω(u) (1 + 2ω(v)) p. 2 2u |v
We may conclude as follows: The Brizolis property holds for the prime p ≥ 5, if we may write the largest square-free divisor of p − 1 as uv with u even, |v 1/ < 1/2, and with √ 1 + 2ω(v) 4ω(u) u · . p> ϕ(u) 1 − 2 |v 1/
(3)
14
4
M. Levin, C. Pomerance, and K. Soundararajan
Completing the Proof
Our criterion (3) can be used in a straightforward way with v = 1 to get an upper bound for possible counterexamples to the Brizolis conjecture. Indeed, after a small calculation (using 4ω(n) < 1404n1/3 and n/ϕ(n) < 2 log log n for n larger than the product of the first eleven primes), it is seen that the Brizolis property holds for all p > 1025 . It is not pleasant to contemplate checking each prime to this point, so instead we use (3) with v > 1. Suppose ω(p − 1) = k ≥ 10, and take v to be the product of the six largest primes dividing p − 1, and u to be the product of the other smaller primes. Since ω(p − 1) ≥ 10, the primes dividing v are all at least 11, and we have that 1−2
1 |v
≥1−2
1 1 1 1 1 1 + + + + + > 0.28. 11 13 17 19 23 29
If pj denotes the j-th prime, then 4ω(u) u/ϕ(u) ≤ k−6 j=1 (4pj /(pj − 1)), and p > k p − 1 ≥ j=1 pj . So from our criterion (3), if we have k k−6 13 4pj √ , pj ≥ 0.28 j=1 pj − 1 j=1
then the Brizolis property holds for all p with ω(p − 1) = k. We verified that the inequality above holds for k = 10. If k is increased by 1 then the LHS of our √ inequality is increased by a factor of at least 31 > 5, but the RHS is increased only by a factor of at most 4 × (11/10) = 4.4. Thus, the inequality holds for all k ≥ 10. Suppose now that k = ω(p − 1) ≤ 9. If k ≥ 4, we take u to be the product of the four smallest primes dividing p − 1, and otherwise, we take u to be the product ofall the primes dividing p − 1. Then v has at most 5 prime factors, and 1 − 2 |v 1/ ≥ 1 − 2(1/11 + 1/13 + 1/17 + 1/19 + 1/23) ≥ 0.35. Further 4 p|u 4p/(p − 1) ≤ j=1 4pj /(pj − 1) = 1120. Our criterion (3) shows that if 11 2 p ≥ 1120 × = 1,239,040,000, 0.35 then p satisfies the Brizolis property. Using the functions Prime[ ] and PrimitiveRoot[ ] in Mathematica, we were able to directly exhibit a primitive root g for each prime 3 < p < 1.25 · 109 with g in [1, p − 1] and coprime to p − 1. Our program runs as follows. The function Prime[ ] allows us to sequentially step through the primes up to our bound. For each prime p returned by Prime[ ], we invoke PrimitiveRoot[p] to find the least positive primitive root r for p. We then sequentially check r2k−1 mod p for k = 1, 2, . . . until we find a value coprime to p − 1 with 2k − 1 also coprime to p − 1. The exponent being coprime to p − 1 guarantees that the power is a primitive root, and the residue being coprime to p − 1 then guarantees that we
Fixed Points for Discrete Logarithms
15
have found a member of S. If no such primitive root exists, this algorithm would not terminate, but it did, thus verifying the Brizolis property for the given range. There are various small speed-ups that one can use to augment the program. For example, if r = 2 is a primitive root and p ≡ 1 (mod 4), then note that p − 2 is a primitive root coprime to p − 1, and so work with this prime p is complete. The augmented program ran in about 90 minutes on a Dell workstation. This completes our proof of the Brizolis conjecture. Acknowledgment. We thank Richard Crandall for some technical assistance with the Mathematica program and the referees for some helpful comments.
References 1. Bachman, G., Rachakonda, L.: On a problem of Dobrowolski and Williams and the P´ olya–Vinogradov inequality. Ramanujan J. 5, 65–71 (2001) 2. Bourgain, J., Konyagin, S.V., Shparlinski, I.E.: Product sets of rationals, multiplicative translates of subgroups in residue rings, and fixed points of the discrete logarithm. Int. Math. Res. Notices, art. ID rnn090, 29 (2008) (Corrigendum: ibid. 2009, No. 16, 3146–3147) 3. Campbell, M.E.: On fixed points for discrete logarithms, Master’s Thesis, U. C. Berkeley Department of Mathematics (2003) 4. Cobeli, C., Zaharescu, A.: An exponential congruence with solutions in primitive roots. Rev. Romaine Math. Pures Appl. 44, 15–22 (1999) 5. Crandall, R., Pomerance, C.: Prime numbers: a computational perspective, 2nd edn. Springer, New York (2005) 6. Guy, R.K.: Unsolved problems in number theory. Springer, Berlin (1984) 7. Hildebrand, A.: On the constant in the P´ olya–Vinogradov inequality. Canad. Math. Bull. 31, 347–352 (1988) 8. Holden, J., Moree, P.: Some heuristics and results for small cycles of the discrete logarithm. Math. Comp. 75, 419–449 (2006) 9. Iwaniec, H., Kowalski, E.: Analytic number theory. American Math. Soc., Providence (2004) 10. Landau, E.: Absch¨ atzungen von Charaktersummen, Einheiten und Klassenzahlen. Nachrichten K¨ onigl. Ges. Wiss. G¨ ottingen, 79–97 (1918) 11. Pomerance, C.: Remarks on the P´ olya–Vinogradov inequality (submitted for publication 2010) 12. Zhang, W.-P.: On a problem of Brizolis. Pure Appl. Math. 11(Suppl.), 1–3 (1995) (Chinese. English, Chinese summary)
Explicit Coleman Integration for Hyperelliptic Curves Jennifer S. Balakrishnan1, Robert W. Bradshaw2, and Kiran S. Kedlaya1 1
Massachusetts Institute of Technology, Cambridge, MA 02139, USA
[email protected],
[email protected] 2 University of Washington, Seattle, WA 98195, USA
[email protected]
Abstract. Coleman’s theory of p-adic integration figures prominently in several number-theoretic applications, such as finding torsion and rational points on curves, and computing p-adic regulators in K-theory (including p-adic heights on elliptic curves). We describe an algorithm for computing Coleman integrals on hyperelliptic curves, and its implementation in Sage.
1
Introduction
One of the fundamental difficulties of p-adic analysis is that the totally disconnected topology of p-adic spaces makes it hard to introduce a meaningful form of antidifferentiation. It was originally discovered by Coleman that this problem can be circumvented using the principle of Frobenius equivariance. Using this idea, Coleman introduced a p-adic integration theory first on the projective line [9], then (partly jointly with de Shalit) on curves and abelian varieties [10], [8]. Alternative treatments have been given by Besser [3] using methods of p-adic cohomology, and by Berkovich [2] using the nonarchimedean Gel’fand transform. Although Coleman’s construction is in principle quite suitable for machine computation, this had only been implemented previously in the genus 0 case [5]. The purpose of this paper is to present an algorithm for computing single Coleman integrals on hyperelliptic curves of good reduction over Cp for p > 2, based on the third author’s algorithm for computing the Frobenius action on the de Rham cohomology of such curves [17]. We also describe an implementation of this algorithm in the Sage computer algebra system. For context, we indicate some of the many potential applications of explicit Coleman integration. Some of these will be treated, with additional numerical examples, in the first author’s upcoming PhD thesis. (Some of these applications will require additional refinements of our implementation; see Section 5.) – Torsion points on curves. Coleman’s original application of p-adic integration was to find torsion points on curves of genus greater than 1. This could potentially be made effective and automatic. – p-adic heights on curves. Investigations into p-adic analogues of the conjecture of Birch and Swinnerton-Dyer for Jacobians of hyperelliptic curves G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 16–31, 2010. c Springer-Verlag Berlin Heidelberg 2010
Explicit Coleman Integration for Hyperelliptic Curves
17
require computation of the Coleman-Gross height pairing [11]. This global p-adic height pairing can, in turn, be decomposed into a sum of local height pairings at each prime. In particular, for C a hyperelliptic curve over Qp with p a prime of good reduction and for D1 , D2 ∈ Div0 (C) with disjoint support, the Coleman-Gross p-adic height pairing at p is given in terms of the Coleman integral [10] ωD1 , hp (D1 , D2 ) = D2
–
–
–
–
for an appropriately constructed differential ωD1 associated to the divisor D1 . This pairing is effectively computable by work of the first author [1]. Using this work, it should be possible (using ideas of Besser [4]) to add in local heights away from p, and thus compute the Coleman-Gross height pairing on Jacobians of hyperelliptic curves. (In genus 1, one can then compare to an alternate computation based on work of Mazur-Stein-Tate [22] and Harvey [16].) p-adic regulators. A related topic to the previous one is the computation of p-adic regulators in higher K-theory of arithmetic schemes, which are expected to relate to special values of L-functions. Some computations in genus 0 have been made by Besser and de Jeu [5]. Rational points on curves: Chabauty’s method. For C a smooth proper curve over Z[ N1 ], the Chabauty condition on C is that rank J(C) Z N1 < dim J(C), where J(C) denotes the Jacobian of the curve. When the Chabauty condiP tion holds, there exists a 1-form ω on J(C)an with 0 ω = 0 for all points 1 P ∈ J(C) Z N . We might be able to compute C(Z[ N1 ]) if we can find all P points P ∈ C an such that 0 ω = 0. This method has already been used in many cases, by Coleman and many others; see [23] for a survey (circa 2007). To apply Chabauty’s method in a typical case, one needs the integral of ω at some point in a residue disc, with which one can find all zeroes of the integral in the residue disc. Several methods are suggested in [23, Remark 8.3] for doing this, including Coleman integration. However, no serious attempt has been made to use numerical Coleman integration in Chabauty’s method; it seems likely that it can handle cases where the other methods suggested in [23, Remark 8.3] for finding constants of integration prove to be impractical. Rational points on curves: nonabelian Chabauty. It may be possible to use (iterated) Coleman integration to find rational points on curves failing the Chabauty condition, using Kim’s nonabelian Chabauty method [18]. As a demonstration of the method, Kim [19] gives an explicit double integral which vanishes on the integral points of the minimal regular model of a genus 1 curve over Q of Mordell-Weil rank 1. The erratum to [19] includes a corrected formula, together with some numerical examples computed using the methods of this paper. p-adic polylogarithms and multiple zeta values. These have been introduced recently by Furusho [13], but little numerical data exists so far.
18
J.S. Balakrishnan, R.W. Bradshaw, and K.S. Kedlaya
2
Coleman’s Theory of p-adic Integration
In this section, we recall Coleman’s p-adic integration theory (for single integrals only) in the case of curves with good reduction. This theory involves some concepts from rigid analytic geometry which it would be hopeless to introduce in such limited space; some standard references are [6] and [12]. (See also [10, §1].) Let Cp be a completed algebraic closure of Qp , and let O be the valuation subring of Cp . Choose once and for all a branch of the p-adic logarithm, i.e., a homomorphism Log : C× to the disc {x ∈ Cp : |x − 1| < p → Cp whose restriction ∞ 1} is given by the logarithm series log(x) = i=1 (1−x)i /i. (The choice of branch has no effect on the integrals on differentials of the second kind, i.e., everywhere meromorphic differentials with all residues zero.) We first introduce integrals on discs and annuli within P1 . Definition 1. Let I be an open subinterval A(I) denote the of [0, +∞). Let 1 annulus (or disc) {t ∈ A1Cp : |t| ∈ I}. For i∈Z ci ti dt ∈ ΩA(I)/C and P, Q ∈ p A(I), define Q ci (Qi+1 − P i+1 ). ci ti dt = c−1 Log(Q/P ) + i+1 P i∈Z
i=−1
This is easily shown not to depend on the choice of the coordinate t. Remark 2. Note that because of the division by i + 1 in the formula for the integral, we are unable to integrate on closed discs or annuli. We next turn to curves of good reduction. Definition 3. By a curve over O, we will mean a smooth proper connected scheme X over O of relative dimension 1. Equip the function field K(X) with the p-adic absolute value, so that the elements of K(X) of norm at most 1 constitute the local ring in X of the generic point of the special fibre X of X. Let XQ denote the generic fibre of X as a rigid analytic space. There is a natural specialization map from XQ to X; the inverse image of any point of X is a subspace of XQ isomorphic to an open unit disc. We call such a disc a residue disc of X. Definition 4. Let X be a curve over O. By a wide open subspace of XQ , we will mean a rigid analytic subspace of XQ of the form {x ∈ XQ : |f (x)| < λ} for some f ∈ K(X) of absolute value 1 and some λ > 1. Coleman made the surprising discovery that there is a well-behaved integration theory on wide open subspaces of curves over O, exhibiting no phenomena of path dependence. (Note that one needs to consider wide open subspaces even to integrate differentials which are holomorphic or meromorphic on the entire curve.) In the case of hyperelliptic curves, Coleman’s construction of these integrals using Frobenius lifts will be reflected in our technique for computing the integrals. For the general case, see [10, §2], [3, §4], or [2, Theorem 1.6.1].
Explicit Coleman Integration for Hyperelliptic Curves
19
Theorem 5 (Coleman). We may assign to each curve X over O and each 1 wide open subspace W of XQ a map μW : Div0 (W ) × ΩW/C → Cp , subject to p the following conditions. (Here Div(W ) denotes the free group on the elements of W , and Div0 (W ) denotes the kernel of the degree map deg : Div(W ) → Z taking each element of W to 1.) 1 . (a) (Linearity) The map μW is linear on Div0 (W ) and Cp -linear on ΩW/C p (b) (Compatibility) For any residue disc D of X and any isomorphism ψ : W ∩ 1 D → A(I) for some interval I, the restriction of μW to Div0 (W ∩D)×ΩW/C p is compatible with Definition 1 via ψ. (c) (Change of variables) Let X be another curve over O, let W be a wide open subspace of X , and let ψ : W → W be any morphism of rigid spaces relative to an automorphism of Cp . Then
(1) μW (ψ(·), ·) = μW (·, ψ ∗ (·)). (d) (Fundamental theorem of calculus) For any Q = i ci (Pi ) ∈ Div0 (W ) and any f ∈ O(W ), μW (Q, df ) = i ci f (Pi ). Remark 6. One cannot expect path independence in the case of bad reduction. For instance, an elliptic curve over Cp with bad reduction admits a Tate uniformization, so its logarithm map has nonzero periods in general. In Berkovich’s theory of integration, this occurs because the nonarchimedean analytic space associated to this curve X has nontrivial first homology.
3
Explicit Integrals for Hyperelliptic Curves
We now specialize to the situation where p > 2 and X is a genus g hyperelliptic curve over an unramified extension K of Qp having good reduction. We will assume in addition that we have been given a model of X of the form y 2 = f (x) such that deg f (x) = 2g + 1 and f has no repeated roots modulo p. (This restriction is inherited from [17], where it is used to simplify the reduction procedure. One could reduce to this case after possibly replacing K by a larger unramified extension of Qp , by performing a linear fractional transformation in x to put one root at infinity, thus reducing the degree from 2g + 2 to 2g + 1.) We will distinguish between Weierstrass and non-Weierstrass residue discs of X, which respectively correspond to Weierstrass and non-Weierstrass points of X. To discuss the differentials we will be integrating, we review a core definition from [17]. Let X be the affine curve obtained by deleting the Weierstrass points from X, and let A = K[x, y, z]/(y 2 − f (x), yz − 1) be the coordinate ring of X . Definition 7. The Monsky-Washnitzer (MW) weak completion of A is the ring A† consisting of infinite sums of the form
∞ Bi (x) , Bi (x) ∈ K[x], deg Bi ≤ 2g , yi i=−∞
20
J.S. Balakrishnan, R.W. Bradshaw, and K.S. Kedlaya
further subject to the condition that vp (Bi (x)) grows faster than a linear function of i as i → ±∞. We make a ring out of these using the relation y 2 = f (x). These functions are holomorphic on wide opens, so we will integrate 1-forms ω = g(x, y)
dx , 2y
g(x, y) ∈ A† .
(2)
Note that we only consider 1-forms which are odd, i.e., which are negated by the hyperelliptic involution. Even 1-forms can be written in terms of x alone, and so can be integrated directly as in Definition 1. (This last statement would fail if we had taken A† to be the full p-adic completion of A, rather than the weak completion. This observation is the basis for Monsky-Washnitzer’s formal cohomology, which is used in [17].) Note that the class of allowed forms includes those meromorphic differentials on X whose poles all belong to Weierstrass residue discs. For some applications (e.g., p-adic canonical heights), it is necessary to integrate meromorphic differentials with poles in non-Weierstrass residue discs. These will be discussed in [1]. Note also that for ease of exposition, we describe all of our algorithms as if it were possible to compute exactly in A† . This is not possible for two reasons: the elements of A† correspond to infinite series, and the coefficients of these series are polynomials with p-adic coefficients. In practice, each computation will be made with suitable p-adic approximations of the truly desired quantities, so one must keep track of how much p-adic precision is needed in these estimates in order for the answers to bear a certain level of p-adic accuracy. We postpone this discussion to § 4.1. 3.1
A Basis for de Rham Cohomology
We first note that any odd differential ω as in (2) can be written uniquely as ω = df + c0 ω0 + · · · + c2g−1 ω2g−1
(3)
with f ∈ A† , ci ∈ K, and ωi =
xi dx 2y
(i = 0, . . . , 2g − 1).
(4)
That is, the ωi form a basis of the odd part of the de Rham cohomology of A† . The process of putting ω in the form (3), using the relations y 2 = f (x), dx , d(xi y j ) = 2ixi−1 y j+1 + jxi f (x)y j−1 2y can be made algorithmic; see [17, §3]. (Briefly, one uses the first relation to reduce high powers of x, and the second to reduce large positive and negative powers of y.) Using properties from Theorem 5 (linearity and the fundamental
Explicit Coleman Integration for Hyperelliptic Curves
21
theorem of calculus), the integration of ω reduces effectively to the integration of the ωi . It may be convenient for some purposes to use a different basis of de Rham cohomology. For instance, the basis xi dx/2y 3 (i = 0, . . . , 2g − 1) is crystalline (see the erratum to [17]), so Frobenius will act via a matrix with p-adically integral entries. 3.2
Tiny Integrals
Q We refer to any Coleman integral of the form P ω in which P, Q lie in the same residue disc (Weierstrass or not) as a tiny integral. As an easy first case, we give an algorithm to compute tiny integrals of basis differentials. Algorithm 8 (Tiny Coleman integrals). Input: Points P, Q ∈ X(Cp ) in the same residue disc (neither equal to the point at infinity) and a basis differential ωi . Q Output: The integral P ωi . 1. Construct a linear interpolation from P to Q. For instance, in a nonWeierstrass residue disc, we may take x(t) = (1 − t)x(P ) + tx(Q) y(t) = f (x(t)), where y(t) is expanded as a formal power series in t. 2. Formally integrate the power series in t:
Q
Q
ωi = P
xi P
dx = 2y
0
1
x(t)i dx(t) dt. 2y(t) dt
Remark 9. One can similarly integrate any ω holomorphic in the residue disc containing P and Q. If ω is only meromorphic in the disc, but has no pole at P or Q, we can first make a polar decomposition, i.e., write ω as a holomorphic differential on the disc plus some terms of the form c/(t − r)i , and integrate the latter terms directly. (If ω is everywhere meromorphic, this is achieved by a partial fractions decomposition.) 3.3
Non-Weierstrass Discs
Q We next compute integrals of the form P ωi in which P, Q ∈ X(Cp ) lie in distinct non-Weierstrass residue discs. The method of tiny integrals is not available; we instead employ Dwork’s principle of analytic continuation along Frobenius, in the form of Kedlaya’s algorithm [17] for calculating the action of Frobenius Q on de Rham cohomology. Note that we calculate the integrals P ωi for all i simultaneously. (We modify the presentation in [17] by keeping track of exact differentials, which are irrelevant for computing zeta functions.)
22
J.S. Balakrishnan, R.W. Bradshaw, and K.S. Kedlaya
Algorithm 10 (Kedlaya’s algorithm). Input: The basis differentials {ωi }2g−1 i=0 . Output: Functions fi ∈ A† and a 2g × 2g matrix M over K such that φ∗ (ωi ) = 2g−1 dfi + j=0 Mij ωj for a p-power lift of Frobenius φ. 1. Since K is an unramified extension of Qp , it carries a unique automorphism φK lifting the Frobenius automorphism x → xp on its residue field. Extend φK to a Frobenius lift on A† by setting φ(x) = xp ,
1/2 φK (f )(xp ) − f (x)p φ(y) = y p 1 + f (x)p
∞ 1/2 (φK (f )(xp ) − f (x)p )i = yp , i y 2pi i=0 noting the series converges in A† because φK (f )(xp ) − f (x)p has positive valuation. (This choice of φ(y) ensures that φ(y)2 = φ(f (x)), so that the action on A† is well-defined. 2. Use a Newton iteration to compute y/φ(y). Then for i = 0, . . . , 2g−1, proceed as in § 3.1 to write φ∗ (ωi ) = pxpi+p−1
2g−1 y dx = dfi + Mij ωj φ(y) 2y j=0
(5)
for some fi ∈ A† and some 2g × 2g matrix M over K. We may use Algorithm 10 to compute Coleman integrals between endpoints in non-Weierstrass residue discs, as follows. (Note that our recipe is essentially Coleman’s construction of the integrals in this case.) Algorithm 11 (Coleman integration in non-Weierstrass discs). Input: The basis differentials {ωi }2g−1 i=0 , points P, Q ∈ X(Cp ) in non-Weierstrass residue discs, and a positive integer m such that the residue fields of P, Q are contained in Fpm . Q Output: The integrals { P ωi }2g−1 i=0 . 1. Calculate the action of the m-th power of Frobenius on each basis element (see Remark 12): 2g−1 (φm )∗ ωi = dfi + Mij ωj . (6) j=0
2. By change of variables (see Remark 13), we obtain 2g−1 j=0
Q
(M − I)ij
ωj = fi (P ) − fi (Q) − P
φm (P )
ωi − P
Q
φm (Q)
ωi
(7)
Explicit Coleman Integration for Hyperelliptic Curves
23
(the fundamental linear system). As the eigenvalues of the matrix M are algebraic integers of Cp -norm pm/2 = 1 (see [17, §2]), the matrix M − I is Q invertible, and we may solve (7) to obtain the integrals P ωi . Remark 12. To compute the action of φm , first perform Algorithm 10 to write φ∗ ωi = dgi +
2g−1
Bij ωj .
j=0
If we view f, g as column vectors and M, B as matrices, we then have (B)g f = φm−1 (g) + Bφm−2 (g) + · · · + BφK (B) · · · φm−2 K M = BφK (B) · · · φm−1 (B). K Remark 13. We obtain (7) as follows. By change of variables, Q φm (Q) ωi = (φm )∗ ωi φm (P )
P
Q
=
(dfi + P
2g−1
Mij ωj )
j=0
= fi (Q) − fi (P ) +
2g−1 j=0
Adding
φm (P ) P
ωi +
Q
Q φm (Q)
P
ωi +
P
Q
ωj . P
ωi to both sides of this equation yields
φm (P )
ωi =
Mij
Q
φm (Q)
ωi + fi (Q) − fi (P ) +
2g−1 j=0
Q
Mij
ωj , P
which is equivalent to (7). Definition 14. A Teichm¨ uller point of XQ is a point fixed by some power of φ. Each non-Weierstrass residue disc contains a unique such point: if (x, y) ∈ X is a non-Weierstrass point, the Teichm¨ uller point in its residue disc has xcoordinate equal to the usual Teichm¨ uller lift of x. This leaves two choices for the y-coordinate, exactly one of which has the correct reduction modulo p. Note that Teichm¨ uller points are always defined over finite unramified extensions of Qp . Remark 15. A variant of Algorithm 11 is to first find the Teichm¨ uller points P , Q in the residue discs of P, Q, then note that from the fundamental linear system (7), we have Q 2g−1 (M − I)ij ωj = fi (P ) − fi (Q ). (8) j=0
P
Q Q Q From (8), we obtain the integrals P ωi . Finally, write P ωi − P ωi as the Q P sum P ωi + Q ωi of tiny integrals.
24
3.4
J.S. Balakrishnan, R.W. Bradshaw, and K.S. Kedlaya
Weierstrass Endpoints of Integration
Suppose now that P, Q lie in different residue discs, at least one of which is Weierstrass. Since a differential ω of the form (2) is not meromorphic over Weierstrass Q residue discs, we cannot always even define P ω, let alone compute it. We will thus assume (to cover most cases arising in applications) that ω is everywhere meromorphic, with no pole at either P or Q. We then make the following observation. Lemma 16. Let ω be an odd, everywhere meromorphic differential on X. Choose P, Q ∈ X(Cp ) which are not poles of ω, with P Weierstrass. Then for ι the hyQ Q perelliptic involution, P ω = 12 ι(Q) ω. In particular, if Q is also a Weierstrass Q point, then P ω = 0. Proof. Let I := points, we have
Q
ι(Q) P (−ω) = ι(Q) ω. Then by additivity P ω = P Q ι(Q) ω = 2I, from which the result follows.
in the end-
If P belongs to a Weierstrass residue disc while Q does not, we find the Weierstrass point P in the disc of P , then apply Lemma 16 to write
Q
P
ω= P
P
1 ω+ 2
Q
ω.
(9)
ι(Q)
The first integral on the right side of (9) is tiny, while the second integral involves two points in non-Weierstrass residue discs, and so may be computed as in the previous section. The situation is even better if P, Q both belong to residue discs Q containing respective Weierstrass points P , Q : in this case, by Lemma 16, P ω P Q equals the sum P ω + Q ω of tiny integrals. Remark 17. Beware that Lemma 16 does not generalize to iterated integrals. For instance, for double integrals, if both integrands are odd, the total integrand is even, so the argument of Lemma 16 tells us nothing. It is thus worth considering alternate approaches for dealing with Weierstrass discs, which may generalize better to the iterated case. We concentrate on the case where P lies in a Weierstrass residue disc but Q does not, as we may reduce to this case by splitting R Q Q ω = P ω + R ω for some auxiliary point R in a non-Weierstrass residue P disc. In Algorithm 11, the form fi belongs to A† and so need not converge at P . However, it does converge at any point R near the boundary of the disc, i.e., in the complement of a certain smaller disc which can be bounded explicitly. We R Q Q may thus write P ωi = P ωi + R ωi for suitable R in the disc of P , to obtain an analogue of the fundamental linear system (7). Similarly, when we write
Explicit Coleman Integration for Hyperelliptic Curves
25
ω as in (3), we can find R close enough to the boundary of the disc of P so that f Q R converges at R, use (3) to evaluate R ω, then compute P ω as a tiny integral. One defect of this approach is that forcing R to be close to the boundary of the residue disc of P forces R to be defined over a highly ramified extension of Qp , over which computations are more expensive. An alternate approach exploits the fact that for P in the infinite residue disc Q but distinct from the point at infinity, we may compute P ω directly using Algorithm 11. This works because both the Frobenius lift and the reduction process respect the subring of A† consisting of functions which are meromorphic at infinity. When P lies in a finite Weierstrass residue disc, we may reduce to the previous case using a change of variables on the x-line to move P to the infinite disc. However, one still must use the approach of the previous paragraph Q Q to reduce evaluation of P ω to evaluation of the P ωi .
4
Implementation Notes and Precision
We have implemented the above algorithms in Sage [24] for curves defined over Qp . In doing so, we made the following observations. 4.1
Precision Estimates
For a tiny integral, the precision of the result depends on the truncation of the power series computed. Here is the analysis for a non-Weierstrass disc; the analysis for a Weierstrass disc, using a different local interpolation, is similar. (For points over ramified extensions, one must also account for the ramification index in the bound, but it should be clear from the proof how this is done.) Q Proposition 18. Let P ω be a tiny integral in a non-Weierstrass residue disc, with P, Q defined over an unramified extension of K and accurate to n digits of precision. Let (x(t), y(t)) be the local interpolation between P and Q defined by x(t) = x(P )(1 − t) + x(Q)t = x(P ) + t(x(Q) − x(P )) y(t) = f (x(t)). Let ω = g(x, y)dx be a differential of the second kind such that h(t) = g(x(t), y(t)) belongs to O[[t]]. If we truncate h(t) modulo tm , then the computed value of the Q integral P ω will be correct to min{n, m + 1 − logp (m + 1) } digits of (absolute) precision. Proof. Let t = t(x(Q) − x(P )). As P, Q are in the same residue disc and are defined over an unramified ∞extension of K, we have vp (x(Q) − x(P )) ≥ 1. If we expand g(x(t ), y(t )) = i=0 ci (t )i , then by hypothesis ci ∈ O. Thus
26
J.S. Balakrishnan, R.W. Bradshaw, and K.S. Kedlaya
Q
Q
ω= P
g(x, y)dx P 1
g(x(t), y(t))dx(t)
= 0
=
0
=
0
x(Q)−x(P )
g(x(t ), y(t ))dt
∞ x(Q)−x(P )
ci (t )i dt
i=0
∞ ci (x(Q) − x(P ))i+1 . = i + 1 i=0
The effect of omitting ci (t )i from the expansion of g(x(t ), y(t )) for some i ≥ m is to change the final sum by a quantity of valuation at least i+1− logp (i+1) ≥ m+1− logp (m+1) . The effect of the ambiguity in P and Q is that the computed value of (x(Q) − x(P ))i+1 differs from the true value by a quantity of valuation at least i + 1 − logp (i + 1) + n − 1 ≥ n. For Coleman integrals between different residue discs, which we may assume are non-Weierstrass thanks to § 3.4, one must first account for the precision loss in Algorithm 10. According to [17, Lemmas 2,3] and the erratum to [17] (or [15]), working to precision pN in Algorithm 10 produces the fi , Mij accurately modulo pN −n for n = 1 + logp max{N, 2g + 1} . We must then take into account the objects involved in the linear system (7), as follows. Q Proposition 19. Let P ω be a Coleman integral, with ω a differential of the second kind and with P, Q in non-Weierstrass residue discs, defined over an unramified extension of Qp , and accurate to n digits of precision. Let Frob be the matrix of the action of Frobenius on the basis differentials. Set B = Frobt −I, Q and let m = vp (det(B)). Then the computed value of the integral P ω will be accurate to n − max{m, logp n } digits of precision. Proof. By the linear system (7), the Coleman integral is expressed in terms of tiny integrals, integrals of exact forms evaluated at points, and a matrix inversion. Suppose that the entries of B = Frobt −I are computed to precision n. Then taking B −1 , we have to divide by det(B), which lowers the precision by m = vp (det(B)). By Proposition 18, computing tiny integrals (with the series expansions truncated modulo tn−1 ) gives a result precise up to n− logp n digits. Q Thus the value of the integral P ω will be correct to n−max{m, logp n } digits of precision. 4.2
Complexity Analysis
We assume that asymptotically fast integer and polynomial multiplication algorithms are used; specifically addition, subtraction, multiplication, and divi sion take O(log N ) bit operations in Z/N Z and O(n) basering operations in
Explicit Coleman Integration for Hyperelliptic Curves
27
R[x]/xnR[x]. In particular, this allows arithmetic operations in Qp to n (rela log p). Using tive) digits of precision, hereafter called field operations, in time O(n Newton iteration, both square roots and the Teichm¨ uller character can be com puted to n digits of precision using O(log n) arithmetic operations. (We again consider only points in non-Weierstrass discs defined over unramified fields.) Q Proposition 20. Let P ω be a Coleman integral on a curve of genus g over Qp , 2g−i with ω = dfω + i=1 ci ωi a differential of the second kind and with P, Q in nonWeierstrass residue discs, defined over Qp , and accurate to n digits of precision. Let Frob be the matrix of the action of Frobenius on the basis differentials, and let m = vp (det(Frobt −I)). Let F (n) be the running time of evaluating fω at P Q and Q to n digits of precision. The value of the integral P ω can be computed 2 2 g + g 3 n log p). to n − max{m, logp n } digits of precision in time F (n) + O(pn (Over a degree N unramified extension of Qp , the analysis is the same with the runtime multiplied by a factor of N .) Proof. An essential input to the algorithm is the matrix of the action of Frobenius, which can be computed by Kedlaya’s algorithm to n digits of precision 2 2 in running time O(pn g ). Inverting the resulting matrix can be (na¨ıvely) done 3 with O(g ) arithmetic operations in Qp . It remains to be shown that no other step exceeds these running times. For the tiny integral on the first basis differential, the power series x(t)/y(t) = x(t)f (x(t))−1/2 can be computed modulo tn−1 log n) field operations. Each other basis using Newton iteration, requiring O(n differential can be computed from the first by multiplication by the linear poly nomial x(t) and the definite integral evaluated with O(n) field operations, for a 2 total of O(gn ) bit operations. Computing φ(P ) and φ(Q) to n digits of preci + log p) field sion is cheap; directly using the formula in Algorithm 10 uses O(g operations. The last potentially significant step is computing and evaluating the fi at each P and/or Q. The coefficients of the fi can be read off in the reduction phase of Kedlaya’s algorithm, and have O(png) terms each. Evaluating (or even 2 2 2 ) field operations, or O(pn g ) bit recording) all g of these forms takes O(png operations, which is proportional to the cost of doing the reduction. 4.3
Numerical Examples
Here are some sample computations made using our Sage implementation. Additional examples will appear in the first author’s upcoming PhD thesis. Example 21. Lepr´evost [21] showed that the divisor (1, −1) − ∞+ on the genus 2 curve y 2 = (2x − 1)(2x5 − x4 − 4x2 + 8x − 4) over Q is torsion of order 29. Consequently, the integrals of holomorphic differentials against this divisor must vanish. We may observe this vanishing numerically, as follows. Let C : y 2 = x5 +
1 33 4 3 3 3 2 1 x + x + x − x+ 16 4 8 4 16
28
J.S. Balakrishnan, R.W. Bradshaw, and K.S. Kedlaya
be the pullback of Lepr´evost’s curve by the linear fractional transformation x → (1 − 2x)/(2x) taking ∞ to 1/2. The original points (1, −1), ∞+ correspond to the points P = (−1, 1), Q = (0, 14 ) on C. The curve C has good reduction at p = 11, and we compute
Q
P
Q
ω0 =
Q
ω1 = O(116 ), P
ω2 = 7·11+6·112 +3·113 +114 +5·115 +O(116 ), P
consistent with the fact that Q − P is torsion and ω0 , ω1 are holomorphic but ω2 is not. Example 22. We give an example arising from the Chabauty method, taken from [23, § 8.1]. Let X be the curve y 2 = x(x − 1)(x − 2)(x − 5)(x − 6), whose Jacobian has Mordell-Weil rank 1. The curve X has good reduction at 7, and X(F7 ) = {(0, 0), (1, 0), (2, 0), (5, 0), (6, 0), (3, 6), (3, −6), ∞}. By [23, Theorem 5.3(2)], we know |X(Q)| ≤ 10. However, we can find 10 rational points on X: the six rational Weierstrass points, and the points (3, ±6), (10, ±120). Hence |X(Q)| = 10. Since the Chabauty condition holds, there must exist a holomorphic differQ ential ω for which ∞ ω = 0 for all Q ∈ X(Q). We can find such a differential by taking Q to be one of the rational non-Weierstrass points, then computing Q Q a := ∞ ω0 , b := ∞ ω1 and setting ω = bω0 − aω1 . For Q = (3, 6), we obtain a = 6 · 7 + 6 · 72 + 3 · 73 + 3 · 74 + 2 · 75 + O(76 ) b = 4 · 7 + 2 · 72 + 6 · 73 + 4 · 75 + O(76 ). We then verify that
R Q
ω vanishes for each of the other rational points R.
Remark 23. It is worth pointing out some facts not exposed by Example 22. For instance, since ω is already determined by a single rational non-Weierstrass point, we could have used it instead of a brute-force search to find other rational points. More seriously, in other examples, the integral ω may vanish at a point defined over a number field which has a rational multiple in the Jacobian. Such points may be difficult to find by brute-force search; it may be ∗ easier to reconstruct them from p-adic approximations, obtained by writing ∞ ω as a function of a linear parameter of a residue disc, then finding the zeroes of that function.
5
Future Directions
Here are some potential extensions of our computation of Coleman integrals.
Explicit Coleman Integration for Hyperelliptic Curves
5.1
29
Iterated Integrals
Coleman’s theory of integration is not limited to single integrals; it gives rise to an entire class of locally analytic functions, the Coleman functions, on which antidifferentiation is well-defined. In other words, one can define integrals Q ωn · · · ω1 P
which behave formally like iterated path integrals tn−1 1 t1 ··· fn (tn ) · · · f1 (t1 ) dtn · · · dt1 . 0
0
0
These appear in several applications of Coleman integration, e.g., p-adic regulators in K-theory, and the nonabelian Chabauty method. As in the case of a single integral, one can use Frobenius equivariance to compute iterated Coleman integrals on hyperelliptic curves. One obtains a linear system expressing all n-fold integrals of basis differentials in terms of lower order integrals. Note that the number of such n-fold integrals is (2g)n , so this is only feasible for small n. The cases n ≤ 4 are already useful for applications, but ideas for reducing the combinatorial explosion for larger n would also be of interest. (One must be slightly careful in dealing with Weierstrass residue discs; see Remark 17.) We have made some limited experiments with double Coleman integrals in Sage. The Fubini identity Q
Q
ω2 ω1 + P
Q
ω1 ω2 = P
Q
ω1 P
ω2 P
turns out to be a useful consistency check for both single and double integrals. 5.2
Beyond Hyperelliptic Curves
It should be possible to convert other algorithms for computing Frobenius actions on de Rham cohomology, for various classes of curves, into algorithms for computing Coleman integrals on such curves. Candidate algorithms include the adaptation of Kedlaya’s algorithm to superelliptic curves by Gaudry and G¨ urel [14], or the general algorithm for nondegenerate curves due to Castryck, Denef, and Vercauteren [7]. It should also be possible to compute Coleman integrals using Frobenius structures on Picard-Fuchs (Gauss-Manin) connections, extending Lauder’s deformation method for computing Frobenius matrices [20]. 5.3
Heights After Harvey
We noted earlier that our algorithms for Coleman integration over Qp have linear runtime dependence on the prime p, arising from the corresponding dependence
30
J.S. Balakrishnan, R.W. Bradshaw, and K.S. Kedlaya
in Kedlaya’s algorithm. In [15], Harvey gives a variant of Kedlaya’s algorithm with only square-root dependence on p (but somewhat worse dependence on other parameters), by reorganizing the computation so that the dominant step is finding the p-th term of a linear matrix recurrence whose coefficients are polynomials in the sequence index. Harvey demonstrates the practicality of his algorithm for primes greater than 250 , which may have some relevance in cryptography for finding curves of low genus with nearly prime Jacobian orders. It should be possible to use similar ideas to obtain square-root dependence on p for Coleman integration, by constructing a recurrence that computes not just the entries of the Frobenius matrix but also the values fi (P ) and fi (Q). However, this is presently a purely theoretical question, as we do not know of any applications of Coleman integration for very large p. Acknowledgments. The authors thank William Stein for access to his computer sage.math.washington.edu (funded by NSF grant DMS-0821725), and Robert Coleman and Bjorn Poonen for helpful conversations. Balakrishnan was supported by a National Defense Science and Engineering Graduate Fellowship and an NSF Graduate Research Fellowship. Bradshaw was supported by NSF grant DMS-0713225. Kedlaya was supported by NSF CAREER grant DMS0545904, the MIT NEC Research Support Fund, and the MIT Cecil and Ida Green Career Development Professorship. Some development work was carried out at the 2006 MSRI Summer Graduate Workshop on computational number theory, and the 2007 Arizona Winter School on p-adic geometry.
References 1. Balakrishnan, J.S.: Local heights on hyperelliptic curves (2010) (in preparation) 2. Berkovich, V.G.: Integration of one-forms on p-adic analytic spaces. Annals of Mathematics Studies, vol. 162. Princeton University Press, Princeton (2007) 3. Besser, A.: Coleman integration using the Tannakian formalism. Math. Ann. 322(1), 19–48 (2002) 4. Besser, A.: On the computation of p-adic height pairings on Jacobians of hyperelliptic curves, Sage Days 5 (2007), http://wiki.sagemath.org/days5/sched 5. Besser, A., de Jeu, R.: Li(p) -service? An algorithm for computing p-adic polylogarithms. Math. Comp. 77(262), 1105–1134 (2008) 6. Bosch, S., G¨ untzer, U., Remmert, R.: Non-Archimedean analysis: A systematic approach to rigid analytic geometry. Springer, Berlin (1984) 7. Castryck, W., Denef, J., Vercauteren, F.: Computing zeta functions of nondegenerate curves. IMRP Int. Math. Res. Pap., Art. ID 72017, 57 (2006) 8. Coleman, R., de Shalit, E.: p-adic regulators on curves and special values of p-adic L-functions. Invent. Math. 93(2), 239–266 (1988) 9. Coleman, R.F.: Dilogarithms, regulators and p-adic L-functions. Invent. Math. 69(2), 171–208 (1982) 10. Coleman, R.F.: Torsion points on curves and p-adic abelian integrals. Ann. of Math. (2) 121(1), 111–168 (1985) 11. Coleman, R.F., Gross, B.H.: p-adic heights on curves. In: Algebraic Number Theory – in honor of K. Iwasawa. Advanced Studies in Pure Mathematics, vol. 17, pp. 73– 81 (1989)
Explicit Coleman Integration for Hyperelliptic Curves
31
12. Fresnel, J., van der Put, M.: Rigid analytic geometry and its applications. In: Progress in Mathematics, vol. 218. Birkh¨ auser Boston Inc., Boston (2004) 13. Furusho, H.: p-adic multiple zeta values. II. Tannakian interpretations. Amer. J. Math. 129(4), 1105–1144 (2007) 14. Gaudry, P., G¨ urel, N.: An extension of Kedlaya’s point-counting algorithm to superelliptic curves. In: Boyd, C. (ed.) ASIACRYPT 2001. LNCS, vol. 2248, pp. 480–494. Springer, Heidelberg (2001) 15. Harvey, D.: Kedlaya’s algorithm in larger characteristic. Int Math Res Notices, Article ID No. rnm095, 2007, 29 (2007) 16. Harvey, D.: Efficient computation of p-adic heights. LMS J. Comput. Math. 11, 40–59 (2008) 17. Kedlaya, K.S.: Counting points on hyperelliptic curves using Monsky-Washnitzer cohomology. J. Ramanujan Math. Soc. 16, 323–338 (2001); erratum ibid 18, 417– 418 (2003) 18. Kim, M.: The unipotent Albanese map and Selmer varieties for curves. Publ. Res. Inst. Math. Sci. 45(1), 89–133 (2009) 19. Kim, M.: Massey products for elliptic curves of rank 1. J. Amer. Math. Soc. 23, 725–747 (2010); Erratum by Balakrishnan, J.S., Kedlaya, K.S., Kim, M., http://www.ucl.ac.uk/~ ucahmki/ 20. Lauder, A.G.B.: Deformation theory and the computation of zeta functions. Proc. London Math. Soc. 88(3), 565–602 (2004) 21. Lepr´evost, F.: Jacobiennes de certaines courbes de genre 2: torsion et simplicit´e. J. Th´eor. Nombres Bordeaux 7(1), 283–306 (1995) 22. Mazur, B., Stein, W., Tate, J.: Computation of p-adic heights and log convergence. Doc. Math. Extra, 577–614 (2006) (electronic) 23. McCallum, W., Poonen, B.: The method of Chabauty and Coleman (2007) (preprint) 24. Stein, W.A., et al.: Sage Mathematics Software (Version 4.3.5), The Sage Development Team (2010), http://www.sagemath.org
Smallest Reduction Matrix of Binary Quadratic Forms And Cryptographic Applications Aurore Bernard1 and Nicolas Gama2 1
XLIM, Limoges, France
[email protected] 2 GREYC Ensicaen, Caen, France
[email protected]
Abstract. We present a variant of the Lagrange-Gauss reduction of quadratic forms designed to minimize the norm of the reduction matrix within a quadratic complexity. The matrix computed by our algorithm 1 4 on the input f has norm O f 1 2 Δf , which is the square root of the best previously known bounds using classical algorithms. This new bound allows us to fully prove the heuristic lattice based attack against NICE Cryptosystems, which consists in factoring a particular subclass of integers of the form pq 2 . In the process, we set up a homogeneous variant of Boneh-Durfee-HowgraveGraham’s algorithm which finds small rational roots of a polynomial modulo unknown divisors. Such algorithm can also be used to speed-up factorization of pq r for large r.
1
Introduction
Binary quadratic forms appeared progressively in the 17-th century, when Descartes and Fermat first introduced the concept of coordinates as a tool to algebraically solve geometric problems. Those forms have wide applications in mathematics and physics, especially in geometry, numerical analysis or algebraic topology. A binary quadratic form is a homogeneous polynomial of degree two in two variables, which can be viewed as the Cartesian equation of a surface f x, y ax2 bxy cy 2 on a given basis of R2 . Of course, this equation varies with the basis of expression, and it is natural to define an equivalence relation to regroup all these possible equations into classes. Over the real field, there are six classes corresponding to the Sylvester’s signatures. They can be distinguished by the sign of the discriminant Δf b2 4ac, and the sign of a c. Forms of strictly negative discriminant (imaginary forms) have a unique zero at the origin, which is also their unique local and global extremum. Forms of strictly positive discriminant (real forms) represent a saddle-shape. Meanwhile, quadratic forms were also used over the integer ring by Fermat, Lagrange and Gauss to solve long standing problems from number theory. This time, binary quadratic forms are equations with integer coefficients of discrete G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 32–49, 2010. c Springer-Verlag Berlin Heidelberg 2010
Smallest Reduction Matrix of Binary Quadratic Forms
33
scatter-plots on a given lattice basis of Z2 . One defines a similar equivalence relation by base change, except that transformation matrices are now unimodular, and that they preserve the value of the discriminant. Problems related to this equivalence are more complicated than on the real field: for instance, in both real and imaginary cases, we do not know any polynomial way to compute the number of equivalence classes of a given discriminant. Deciding the equivalence of two forms is easy in the imaginary case, where each class contains a unique reduced representative computable in polynomial time. However, the problem is hard in the real case, where there are, depending on the notion of reduction, either an exponential number of polynomially computable reduced representatives, or a few representatives computable in exponential time. A reduction algorithm takes as input a quadratic form and outputs a reduced form and the reduction matrix, which is a unimodular base-change matrix used to obtain this form. The most famous polynomial time reduction algorithms are Lagrange algorithm [15] (1773) commonly known as ”Gauss reduction” algorithm [11] (1801). In [14] (1980), Lagarias modified the Gauss reduction algorithm for make it more efficient. This algorithm is the one used in practice, and which we refer as the Gauss reduction algorithm, or Classical Gauss, if we need to differentiate it from new flavors which we propose. The cryptanalysis of [6] shows experimental evidences that the small size of reduction matrices have important applications to the factorization of some large numbers used in public key cryptosystems, especially those of the NICE cryptosystems (see [12,13]). However the best currently known upper-bounds on the size of reduction matrices [14,1] are by an order too large, and keep all these results on the factorization heuristic. In this paper, we specially design an efficient variant of the Gauss reduction algorithm to minimize the size of transformation matrix, and we prove constructive upper-bounds which are tight both in the worst case and in the average case. These bounds, combined with an improvement of the methods of [6], allows us to prove all the above mentioned heuristics of on the factorization of integers from the NICE cryptosystems.
2
Preliminaries and Notation
In this section we recall some definitions and properties concerning binary quadratic forms. For a more detailed account of the theory see [5,4,9]. Then, we summarize some results on the norm of a matrix. Quadratic Forms. A binary quadratic form f is a homogeneous polynomial of degree two in two variables f x, y ax2 bxy cy 2 with a, b, c Z3 which we abbreviate as f a, b, c. Throughout this paper the word form will be used in the sense of binary quadratic form. It is said primitive when gcd a, b, c 1. The discriminant of f is Δf b2 4ac. A discriminant Δf is called fundamental if all the forms of discriminant Δf are necessarily primitive: for example, it is the case of all odd and square-free integers. The set of all primitive forms of discriminant Δf is denoted FΔf . We impose that the discriminant is not a perfect square then a and c are always non-zero. The form f can be factored as
34
A. Bernard and N. Gama
f x, y a x yζf x yζf where ζf and ζf are the complex roots of the univariate polynomial f x, 1 which we call the affine representation of f . When Δf 0, each root of f live in RQ and the form is real. In this case, ζf will denote the smallest root and ζf the largest one. When Δf 0, the roots are in CR and the form is imaginary. We note λ f min f x, y : x, y Z2 0, 0 the first minimum of f . We note Mt the transpose of amatrix M. The a b 2 polar representation of f is the symmetric matrix b of determinant
2 c αβ Δf 4. Let M M2 Z be a 2 2 matrix with integer enγ δ tries which we often abbreviate as α, β; γ, δ . We note Id the identity matrix of M2 Z. The composition action of M on f is defined as the form g x, y f αx βy, γx δy and it is noted g f.M. The coefficients of g are g f α, γ , b αδ γβ 2 aαβ cγδ, f β, δ. We remark that for each Composition Action.
root ζg of g,
αζg β γζg δ
is a root of f . Finally, the polar representation of g is
M f M which implies that Δg t
det M2 Δf .
Group action. Let GL2 Z be the general linear group of matrices in M2 Z which are invertible and its subgroup SL2 Z the special linear group of matrices which have a determinant equal to one. The action defined with either GL2 Z or SL2 Z on the set of primitive forms FΔf of a given discriminant is a (right) group action. Two forms f and g are equivalent if they belong to the same SL2 Z-orbit. In this case we note f g. We define Aut f the group of automorphisms of the form f FΔf as M SL2 Z, trace M 0 and f.M f . The set of all automorphisms of f is Aut f . The group Aut f is known to be cyclic, and we call its generator the fundamental automorphism of f . The largest eigenvalue of the fundamental automorphism of f is the fundamental unit. It only depends on the discriminant Δf , and will be denoted Δf .
1 0 Three specials transformations. We define the symmetry S , the 0 1 01 1h and the translation by an integer T h . They are exchange E 10 01 three (linear) transformations of GL2 Z. All matrices in GL2 Z can be written as a product of powers of these three transformations and SL2 Z is generated by the product ES and T 1. The action of these transformations on f are f.S a, b, c, f.E c, b, a f.T h a, b 2ah, f h. Note the important fact: the roots of f.S are the opposite of the roots of f and the roots of f.E are the inverse of the roots of f , and that T h subtracts h to each roots of f . Norms of matrices and forms. Let M α, β; γ, δ be a matrix in M2 Z. The Euclidean norm is M2 α2 β 2 γ 2 δ 2 , and the maximum norm is M max α, β , γ , δ . The norm M supv2 1 M.v2 is the induced Euclidean norm, which is also the square root of the largest eigenvalue of Mt M. All the norms are equivalent: M M M2 2M.
Smallest Reduction Matrix of Binary Quadratic Forms
35
Additionally, the induced norm is sub-multiplicative: if N M2 Z then MN M N and Id 1, and it is lower-bounded by the spectral radius ρ M, which is the supremum among the absolute values of the eigenvalues of M. By extension, we define the norms f ,f 2 and f of a form as the corresponding norm of its polar representation.
3
A New Reduction Algorithm for Real Quadratic Forms
A form f a, b, c is reduced if it satisfies two conditions simultaneously: a normalization condition, which defines the choice of the representative of b mod 2a, and a reduction condition, which often upper-bounds the size of a (or c). In the imaginary case, these conditions are very natural: a form is normal if and only if b a, a is minimal, and is reduced if additionally, a is the minimum λ f . A single translation is needed to normalize any form. However, the reduction condition takes more steps to be achieved. The classical Gauss reduction reduces a form by successive swaps SE and normalizations T b 2a (see [1]) until f is reduced. The Gauss reduction algorithm operates in quadratic time (see [1,21,18]). For each form f of discriminant Δf 4, there exists a unique reduced form g in each equivalence class, and a unique reduction matrix M SL2 Z such that f.M g. In this case Aut f Id . In the real case (Δf 0), the previous reduction conditions applied on f a, b, c are too restrictive, since the smallest integers α, β 0, 0 such that f α, β λ f are in general exponential in the size of f . No polynomial time algorithm can output an exponential reduction matrix. Thus, according to classical notions, f is classically normalized if and only if b a, a when a Δf and b Δ 2a, Δf when a Δf , and f is classically f reduced if additionally, Δf 2a b Δf . It is known that only a finite subset of forms of discriminant Δf are classically-reduced, and that they form a reduced cycle in each class. The Real-Gauss reduction algorithm, which uses the classical normalization, finds a reduced form equivalent to its input in quadratic time (see [1]). In this paper, given a normalized form f , we will bound the coefficients of the smallest reduction matrix M α, β; γ, δ such that g f.M ag , bg , cg is reduced. The case of imaginary forms is eased by the uniqueness of the reduction a,c . We improve this matrix. Lemma 5.6.1 in [1] give us that M 2 max upper-bound with the following theorem:
Δf
Theorem 1 (Imaginary Bound). Let f a, b, c be a normalized imaginary form of discriminant Δf 0, and M α, β; γ, δ the reduction matrix such that g f.M ag , bg , cg , M satisfies these two upper-bounds: 1) M
2) αβγδ
23
14
c
ag 1 γδ 2
2 31 4
ac Δf
14
.
36
A. Bernard and N. Gama
bounded by fore γδ
α γ b 2 Δf2 , which can be lower2a 4a 4 aag 4 cc 2 γ Δf , and similarly δ 2 Δfg . There-
Proof. One has ag f α, γ aγ 2
Δf γ 2 . It follows that 4a 4 ac . The first inequality comes from 3ag cg 3Δf
Δf ,
because
g is reduced. Unless the transformation is trivial (Id or SE), the normalization condition induces the inequalities α γ and β δ , which proves 1 1 αβγδ 4 γδ 2 . Thus, the norm of the reduction matrix is in fact basically in O
f
Δf
.
In the real case however, this proof would not apply directly, because the Δf b 2 α term
γ 2a 4a2 can be exponentially close to 0. The problem is that in the real case, each reduced cycle contains a large (often exponential) number of equivalent reduced forms, and some of them are exponentially far from f . A constructive approach is needed to build a polynomial reduction matrix. The analysis of the Gauss reduction algorithm in [1,14] basically proves that the norm of the computed reduction matrix is bounded by O f . In this paper, we study a variant of this algorithm which finds a reduction matrix of norm
Δf and we verify that it is tight even in the average case. We define new relaxed notions of reduction and normalization, and express them according to the roots of the forms, which is more intuitive than the classical conditions on the coefficients: O
f
Definition 1. A real binary quadratic form f is: – primary normalized if 0 ζf 1 and primary reduced if also ζf 1 – secondary normalized if 1 ζf 0 and secondary reduced if also 1 ζf . Finally f is largely reduced if it is either primary or secondary reduced. Both primary and secondary notions are exchanged by the action of S, which negates the roots. Furthermore, primary and secondary reductions are exchanged by E, which inverts the roots. As usual, primary and secondary normalization can always be achieved by the action of some T h. Note that a classically normalized form, which has by definition at least one root in the interval 1, 1, is either primary or secondary normalized. Similarly, a classically reduced form a, b, c is a largely-reduced form satisfying b 0, which can again be ensured by the action of S. Our main contribution is to solve the following problems, which are equivalent. Lemma 1. The two problems are equivalent: 1. Smallest SL2 Z matrix Given a classically-normalized real form f , find M SL2 Z such that f.M is classically-reduced and M is minimal. 2. Smallest GL2 Z matrix Given a primary-normalized real form f , find M GL2 Z such that f.M is largely-reduced and M is minimal.
Smallest Reduction Matrix of Binary Quadratic Forms
37
Proof. From a solution M GL2 Z of Problem 2, one deduces a solution of Problem 1 by left-multiplication by Id or S to make the normalization of the input correspond, followed by a right-multiplication by Id or S to force the coefficient b of the reduced form to be positive, followed by a right multiplication by Id or E so that the determinant is 1. The reduction of Problem 2 to Problem 1 is similar. Since Id, S and E are permutation matrices, they do not modify these norms or . Remark that, reducing a problem to the other also preserves the absolute value of the product of the coefficients in each row of the reduction matrices. Lemma 1 motivates the search of a reduction algorithm solving the less restrictive Problem 2, since we can use the above permutation matrices to return to classical notions in SL2 Z. 3.1
Algorithm and Analysis
Let f be a real form. We define the two integers h f and hf as hf hf
ζf
and
ζf . It is easy to show that h f and hf are respectively the unique integers
such that f.T h f is primary-normalized, and f.T hf is secondary-normalized. Among the two integers hf , h f the one of smallest absolute value is noted h f : that is h f hf if hf hf , and h f hf otherwise. In other words, h f is the shortest normalization of f . As a comparison, there is only a single integer νf in the classical case such that f.T νf is classically-normalized, νf being one of the integers hf , h f but not necessarily the one with the smallest absolute value. Our reduction algorithm, is a variant of the Gauss reduction which operates in GL2 Z. It alternates exchange E and the shortest normalization T h f at each loop, and terminates on a largely-reduced form. As we will see later, any kind 1 of normalization by hf or h f would make a reduction algorithm terminate , but the choice of the shortest normalization h f instead of the classical νf (especially during the last steps) is the key element to minimize the reduction matrix. The main result of the section is the following theorem on the quality of the output of our algorithm, which is the real-case analogue of Theorem 1. Algorithm 1. RedGL2 Input: f a, b, c a primary-normalized form Output: f.M a largely-reduced form and M GL2 Z 1: M Id 2: while f not largely-reduced do 3: f f.E and M ME 4: f f.T hf and M MT hf 5: end while 6: return f and M
1
Exchange step Normalization step
The original Gauss algorithm of 1801 used actually the largest normalization at each step. The number of reduction steps is exponential on some entries. Lagarias introduced the classical normalization to obtain a quadratic complexity
38
A. Bernard and N. Gama
Theorem 2 (Real bound). Let f a, b, c be a primary-normalized form oflogdiscriminant Δ 0. Given f as input, RedGL2 terminates after at most
a Δ 4 iterations where ω 15 is the gold number. Its output M 2 log ω 2 α, β; γ, δ and fr
1) M 4
2) αβγδ
14
a
f.M ar , br , cr satisfies:
ar
γδ 2 1
21
a Δ.
Before proving this theorem, we remark that the best known upper-bounds achieved by the classical Gauss algorithm under the conditions same (see theo1 rem 4.4 of [1]) are M a 1 1 Δ and γδ 2 a Δ 1 1 Δ. They are basically the square of the upper-bounds of RedGL2. Figure 1 and 2 illustrate respectively the families of forms Fn n, b, 1 and Gn n, n, 1 with n N and b 2n 3 2 3 , which are families of forms where the Gauss reduction algorithm outputs reduction matrices Δ times larger than our variant RedGL2. Finally, note that a multiplicative triangular inequality on the norms of the polar representations of f fr .M 1 yields f fr 2M, which confirms the optimality of Theorem 2 in average. The analysis of Gauss reduction algo log a Δ rithm in [1] upper-bounds the number of iterations by 2 log 2 2 reduction steps. Our upper-bound on the number of iterations of RedGL2 is tight in the worst case, and is only by a multiplicative factor around 1.4 larger than the maximum number of iterations of the Gauss reduction algorithm. However the primary goal of RedGL2 is the minimization of the reduction matrix. 3.2
Proof of Theorem 2
To prove Theorem 2, we first study the termination cases, characterized by the presence of integers between the roots of f.E, and where the choice of the shortest normalization is of greatest importance. Eventually, we shall treat the general case and the complexity. Termination cases. We first study the two cases where the algorithm terminates in a single step of reduction. The first one deals with normal form f containing exactly one integer between its roots. This is the only case where hf h f , so all notions of normalizations (classical, primary, secondary, shortest) coincide. Lemma 2. Let f a, b, c be a real form satisfying 1 ζf 0 ζf 1, and h h f.E . The form fr f.ET h ar , br , cr is largely-reduced, and its coefficients satisfy ar c, cr a, and h2 ar a. Proof. The reduction matrix from f to fr is ET h 0, 1; 1, h. Consider the parabola p x cx2 bx a which is the affine representation of g f.E. Then we have h h g , and ζg hg 1 1 h g ζg , cr p h g b and p 0 a. By definition of h we have two cases: if 2c 0 then we have h hg 0 b 2c, else we have b 2c 0 h h g . In both cases we
Smallest Reduction Matrix of Binary Quadratic Forms px=cx2 +bx+a
h
px=cx2+bx+a
a
a
h
ζg ζg
0 νg
b
2c
Gauss
ζg
h=hg νg
cr
39
h-1
ζg h =hg
cr
h-1
Red GL2
Fig. 1. Illustration of Lemma 2 This figure illustrates the convexity inequalities of Lemma 2. In this case, the shortest normalization chosen by RedGL2 is hg ζg , which can be O Δ smaller than the classical normalization ν g ζg in Gauss Algorithm. It is clear that cr is in the interval 0, a . Comparison of heights of the two rectangles on the same convex and decreasing branch of the parabola, gives ch2 a .
Fig. 2. Illustration of Lemma 3 This figure is the analogue for Lemma 3. In this case, the shortest normalization chosen by RedGL2 is hg ζg , which can be O Δ smaller than the classical normalization in Gauss algorithm is ν g ζg . Inequality on the slopes of p before and after ζg gives cr a . Comparison of heights of the two rectangles on the same convex and decreasing branch of the parabola, gives ch 12 a .
graphically verify that cr p h p 0 a (see Figure 1). A convexity inequality on p between 0, h and b 2c, b 2c h shows a cr ch2. Since a and cr have the same sign and a is larger, then a ar h2 . Theorem 2 holds in this termination case: the reduction matrix is M 0, 1; 1, h. By Lemma 2, its norm satisfies M h a ar . Since f fr .M 1 , its first coefficient is a ar h2 br h cr , thus br h a cr ar h2 and br h2 4ar cr h2 Δ h2 a2 c2r a2r h4 2acr 2aar h2 2ar cr h2 a cr ar h2 2 9a2 , which proves the second point of Theorem 2. The second case of single-step termination concerns normalized form f such that at least two integers lie between the roots of f.E (namely hf.E h f.E ). We just write a proof for primary-normalized forms, but it can be easily extended to secondary-normalized forms. Lemma 3. Let f a, b, c be a real form satisfying 0 ζf ζf 1, and such that hf.E h f.E . If h h f.E , then fr f.ET h ar , br , cr is secondaryreduced, and its coefficients satisfy ar c, cr a, and h2 ar 4a. Proof. The proof of this lemma is also based on convexity inequalities. Let g f.E, of affine representation p x cx2 bx a. Note that h ζg 2. Again, one has p 0 a, p h cr . It follows from the definition that fr is
40
A. Bernard and N. Gama
secondary-reduced. The reduction matrix is M 0, 1; 1, h, which proves ar c. Application of a convexity inequality (see Figure 2) on p in the two intervals b b 0; h 1 and 2c h 1; 2c of same length yields ar h 12 a p h 1 a, therefore ar h2 4ar h 12 4a. Finally, another convexity inequality centered on ζg gives p
h cr .
p ζg
p 0
0
ζg
p ζg , so a p 0 h ζg
ζg
p h
h ζg
Once again, Theorem 2 holds in this termination case, but this time, M 2 h 2 a ar and Δ h2 a cr ar h2 2 6a .
General case. We now prove the general case of Theorem 2. We call fi ai , bi , ci the successive values of f at the beginning of the while loop of Algorithm 1, and hi h fi .E . We suppose that the primary-normalized form f0 does not have any integer between its roots (otherwise it would either already be reduced or as in Lemma 2). Thus 0 ζf0 ζf0 1. For each iteration i in the loop, if there is at least one integer between the roots of fi .E, then we set m i 1 and the algorithm reaches one of the two termination cases above. Otherwise the shortest normalization hi is the primary one hi h fi .E hfi .E . Thus fi is also primary-normalized and 0 ζfi ζfi 1. Note that the
distance between the roots strictly increases ζfi
ζf
ζf
i1
1
i1
i1
ζf
ζf E ζf E
ζf ζf ζf . Such process can not hold for- ever, otherwise the integer sequence of the first coefficients ai Δ ζf ζf i1
ζf
i1
i
i1
i1
i1
i
i
would be strictly decreasing. This proves the termination of the algorithm. The integer m is the smallest index, such that fm 1 .E contains at least one integer between its roots. The shortest normalization hm 1 hfm1 .E h fm1 E is in this case secondary, and satisfies hm 1 2. We eventually use the following lemma to conclude the proof of Theorem 2. Lemma 4. Let f a, b, c and g ag , bg , cg be two real forms and M α, β; γ, δ GL2 Z such that f.M g. If all the roots of g are positive and γ 0 and δ 1 then ag δ 2 a. Proof. If γ 0, then M is triangular, so α δ 1 and ag a. We now αζ β suppose γ 0. Let ζg be a root of g, then ζf γζgg δ is a root of f . We have 2 α γ ζf 1 γ ζg γδ 1 γδ thanks to the positivity conditions. Since this
bound holds for both roots of f , ag γ 2 a α γ ζf
α γ ζ a δ2 . f
We continue the proof of Theorem 2 by applying this lemma to the main loop of RedGL2. Note that for each i 1; m, the reduction matrix from f0 to fi is Mi
0 1 1 h0
0 1 0 1 ... 1 h1 1 hi 1
αi βi . γi δi
(1)
Smallest Reduction Matrix of Binary Quadratic Forms
41
Their coefficients are all positive, and satisfy these recurrence equalities for i 2: γi1 δi hi 1 δi 1 δi 2 and δ0 , δ1 1, h1 αi1 βi hi 1 βi 1 βi 2 and β0 , β1 0, 1 Since all the hj j 0..i are greater than 1, it follows that αi min βi , γi max βi , γi δi and Mi δi ω i 2 by induction and comparison to the Fibonacci sequence 2 . Applying Lemma 4 on f0 and fm 1 implies that Mm 1 2 a0 am 1 . At iteration m, Lemma 4 can be applied to fm .T 1, which has positive roots and shares its first coefficient am with fm . The transformation matrix Mm T 1 Mm 1 0, 1; 1, hm 1 1 still satisfies the conditions of Lemma 4 because hm 1 2. We obtain Mm T 12 a0 am, and finally Mm 2 4a0 am after a backwards translation by T 1. We already know that fm is secondary-normalized and that the largest root of fm is positive. There are two cases: 1. If the largest root of fm is strictly greater than 1, then r m, fr is secondaryreduced, and the reduction matrix is Mm αm , βm ; γm , δm . One already 2 has Mm 2 4a0 ar . From f0 fr .M 1 , we draw a0 ar δm br δm γm 2 2 2 2 2 2 2 2 2 cr γm , so Δδm γm br δm γm 4ar cr δm γm a0 ar δm cr γm . Since 2 2 2 by construction γm δm 1 Mm 1 and by Lemma 3 applied on fm 1 2 2 and fr , cr am 1 , one finds Δδm γm 6 a0 2 . 2. If the second root of fm is strictly lower than 1, then by Lemma 2, fm1 is αr βr 0 1 Mm , and reduced. The matrix of reduction is M 1 hm γr δr r m 1. Thus M2 Mm 2 1 hm2 4a0 am 4h2m 16a0 ar . One still has Δδr2 γr2 a0 ar δr2 cr γr2 2 21a0 2 , because cr am by Lemma 2. This concludes the proof of items 1 and 2 of Theorem 2. It remains the complexity issue, proved in the following paragraph. Complexity. We now prove the number of iterations performed by RedGL2. Two steps before the end, at iteration r 2 of RedGL2, we know that the form fr 2 ar 2 , br 2 , cr 2 satisfies Δ ar 2 , because the distance between the roots of fm1 is smaller than 1. By Lemma 4 we have ω r 4
a0 ar 2
M r 2
a0 Δ.
It follows that r 4 is upper-bounded by
log a Δ steps where ω 12 5 . 2 log ω The worst case complexity of algorithm RedGL2 is reached when all the normalizations occurring in the algorithm until the index r 2 are by h 1. For instance, we experimentally verify that it is the case on this family of inputs g. T 1E n where g is reduced and n grows. 2
The ith number of the sequence of Fibonacci numbers is bigger than ω i2 .
42
4
A. Bernard and N. Gama
Proof of Heuristic Cryptanalysis of the NICE Cryptosystems
We propose an application of the results of the previous section to the cryptanalyses of the NICE cryptosystems. There are two variants, which are by chronological order NICE Imaginary [12] (with imaginary forms), and NICE Real [13] (with real forms). Their security relies on the intractability of factorization of the public discriminant N . They were designed for a similar level of security as RSA, but with faster decryption, since the decryption process has quadratic complexity. Both are now considered as broken. The first one succumbed by a proved arithmetic attack in [7]. However, the more general attack against both versions of NICE (in [6]) using lattice reduction remains only experimental and relies on two heuristic assumptions. In this paper, we provide an alternative point of view on the lattice attack, which allows to avoid the use of these heuristics and to prove the attack entirely. Both variants of NICE (Real and Imaginary) have originally been described in terms of ideals of quadratic orders, and are based on a morphism between classes of primitive forms of fundamental discriminant p and classes of primitive forms of non-fundamental discriminant N q 2 p. These notions are actually not needed here to understand the lattice attack, therefore we will here give a simple description solely in term of quadratic forms. 4.1
Lifting Quadratic Orders
We summarize some important properties on the relation between the sets Fp and FN of primitives forms of discriminants respectively p and N q 2 p, using the terminology we introduced in the last section. For the cryptographic interest we restrict ourselves to the case where q is an odd prime. The following background theory can be found in [5,4,9]. Integer matrices of determinant q. We define an equivalence relation modulo SL2 Z between two integer matrices A and B M2 Z by A B M SL2 Z, AM B. The 2 2 integer matrices of determinant q correspond to matrices of rank 1 mod q, they fall into q 1 equivalence class, which are characterized by the (projective) direction from 0, 1, ..., q 1, of their image mod q. Each class contains a unique Hermite normal form: qk 10 Qk , k 0, . . . , q 1 or Q . 01 0q Lift. As we can see in [5, section 7], for each form f of discriminant N pq 2 and each M M2 Z of determinant q, there exists a (non-unique) form g Fp such that f g.M. When M Q , we define a particular function ϕ (also called lift ) which computes such g Fp from f a, b, c FN such that 2 gcd a, q 1 as follows: ϕ f a, bq2ah , ah q2bhc where h 1 q, . . . , 0 and h b 2a mod q. Note that all the divisions are exact since f is primitive of discriminant N 0 mod q 2 and q is an odd prime. It must be noted that the
Smallest Reduction Matrix of Binary Quadratic Forms
43
lift preserves the first coefficient a of the form. It is also clear that ϕ preserves primary normalization, because its action on the roots of f is a translation by h 0, q 1 followed by a division by q, which stabilizes the interval 0, 1 of the largest root. Finally, equivalence of forms is stable by lift !f, f FN , f f " ϕ f ϕ f . The converse is in general false. Given a form g Fp and U its fundamental automorphism, there are exactly q p q primitive forms (in FN ) among
g.Q0 , . . . , g.Qq 1 , g.Q where p q denotes the Legendre symbol. These forms split into q p q sq sets of sq equivalent forms (see [5] theorem 7.4), where sq is the order of U modulo q. The fundamental unit N is equal to the power s p q . These q p q sq different classes of equivalence are the only ones to be lifted to the class of g. Reduced cycle. Let g FΔ be a classically-reduced form of discriminant Δ 0, the right neighbour of g is the classical normalization of g.SE. If we note H g the largest normalization of g (by the integer among hg , h g of largest absolute value), then the right neighbour of g is g.SET H g.SE . Successive iterations of the right neighbour enumerates all the reduced forms equivalent to g, and define the reduced cycle of the class of g. The cardinality of such reduced cycle is in O log Δ where Δ is the fundamental unit. Principal cycle, and q-belt. The principal class of a discriminant Δ 0 is the class containing 1, 1, #. The principal form is the classical-normalization of this form, and the principal cycle ½Δ is the reduced cycle of the principal class. Note that the principal class is the only class containing a form of first (or last) coefficient equals to 1. We define the q-belt of a discriminant N pq 2 as the set of all primary normalized forms q 2 , kq, # of the principal class. Necessarily, k p, 2q p. There are exactly sq 1 forms in the q-belt of N : let g0 be the principal form 1, #, # of FN and f ϕ g0 is (necessarily) the principal form of Fp . Let U be the fundamental automorphism of f , we set by induction k0 and ki the unique integer such that U Qki1 Qki for i 1. Note that Qki U i Qk0 , and that the order of U mod q is precisely sq , therefore the sequence ki is periodic and ksq k0 . Finally, the q-belt of N is the set g1 f.Qk1 , . . . , gk f.Qksq 1 . They are indeed primary-normalized and equivalent by construction. A transformation matrix from gi to gi 1 is by construction Qki1 U Qki1 SL2 Z, because U Qki1 Qki . 4.2
Cryptosystem Real NICE
We now describe the NICE Real encryption and decryption. The public key is a composite integer N pq 2 and the secret key p, q with p and q two distinct primes of the same size, satisfies two conditions: – p is a Schinzel prime [19] which is a positive squarefree integer of the form p A2 x2 2Bx C with A, B, C, x Z, A 0 and B 2 4AC dividing 4 gcd A2 , B 2 . Such special primes implies a very low number of reduced
44
A. Bernard and N. Gama
forms in each class, namely there are O log p reduced forms in Fp in each equivalence class ([8] and [22, theorem 5.8, p. 52]). It is therefore practical to enumerate every reduced form equivalent to a given one. With a generic discriminant, the number of reduced forms per cycle would be exponential, around O p) (see [3]). To avoid any confusion, please note that even for a Schinzel prime, the number of classes in Fp remains exponential. – q is such that sq is linear in q. This imply that the number of reduced forms of discriminant N q 2 p in each equivalence class is at least linear in q and upper-bounded by O q log p, which is exponential. The encryption of a message m works as follows: m is embedded into a (usually prime) integer a p 2 which satisfies some low-probability pattern, and such 2 that q p is a square modulo a. This integer is expanded into a quadratic form fs a, b , c of discriminant q 2 p (which is not printed). The ciphertext is a random reduced form fc equivalent to fs (there are exponentially many). It can be generated from fs by successive multiplications by random unimodular matrices and reductions. The decryption algorithm lifts the ciphertext in Fp and enumerate all the reduced forms equivalent to ϕ fc , looking for the pattern. Of course, the knowledge of q is needed to compute ϕ. There are only O log p of them. It will necessarily find it, because the (unknown) lift of fs fc is an equivalent form ϕ fs a, #, #, whose normalization a, #, # is reduced due to the small size of a, and it satisfies the pattern by construction. Due to the small number of reduced forms, it is likely the only one of the small reduced cycle to satisfy the pattern, and the plaintext m is eventually extracted from a. 4.3
Cryptanalysis
The cryptanalysis of NICE Real presented in [6] works as follows. The authors present an algorithm inspired of Coppersmith methods (see [10,17]), which solves in polynomial time the equation au2 buv xv 2 0 mod q 2 in the variables u, v, q where N pq 2 is known and max u, v O N 1 9 . They call this algorithm Homogeneous-Coppersmith in [6]. Their cryptanalysis of NICE Real is: Pick3 a form g of the principal cycle, and try to solve the equation g u, v 0 mod q 2 with Homogeneous-Coppersmith. Repeat this until it finds a solution u, v, q and return the private key q. The proof of the attack of [6] relies on this heuristic assumption: Assumption 1. The cardinality of the set A g 1 O N 9 and g u, v 0 mod q 2 is linear in sq . 3
½N ,
u, v max u, v
The authors of [6] enumerates the forms sequentially, until it finds a solvable one. They need an assumption not only on the large number of such forms, but also on their regular repartition on the principal cycle. Randomizing the enumeration avoids to prove the assumption on regular repartition (Heuristic 2 in [6]), which is feasable using the distance introduced in Theorem 3, but is beyond the scope of this paper.
Smallest Reduction Matrix of Binary Quadratic Forms
45
The authors of [6] experimentally verify this assumption. Namely, if g¯k denotes the reduction of the form gk q 2 , #, # of the q-belt by Classical Gauss reduction. The bottom two coefficients of the reduction matrix satisfy g¯k δ, γ q 2 . Homogeneous-Coppersmith experimentally recovers δ, γ for most of the g¯k and even a few of their direct left or right neighbours on the principal cycle. This indicates that the norm of the reduction matrix is in general upper-bounded by O N 1 9 . However we also found rare cases of g¯k where the norm of reduction matrix was by an order greater than N 1 9 , and on which Homogeneous-Coppersmith algorithm cannot find any solution. We call these particular forms unbalanced, because they have in general an unusually small coefficient. The main three difficulties which prevented the authors of [6] to prove Assumption 1 were to justify that that the proportion of unbalanced forms is negligible among the set of g¯k , that the reduction matrix using Classical Gauss reduction is bounded by O N 1 9 , and that Classical Gauss is injective on a large enough subset of the q-belt, which prevents g¯k from being too small. Our first improvement in their analysis is to replace the Classical Gauss reduction algorithm with RedGL2. This allows to square-root the upper-bounds on the reduction matrix as of Theorem 2. Thus we define gˆk as the reduction by RedGL2 of the q-belt form gk for each k. We ensure that gˆk is classically reduced and that the reduction matrix has determinant 1 using Lemma 1. The first point of Theorem 2 implies that the norm of the reduction matrix is in O N 1 9 as soon as the smallest coefficient of gˆk is greater than N 4 9 . We can either prove that this condition is satisfied by a large proportion of the gk , or we can also circumvent this limitation by using the second point of Theorem 2, which indicates that the size of the product uv is always upper-bounded by O N 1 6 . We therefore improve the Homogeneous-Coppersmith algorithm so that it also finds unbalanced solutions: namely, we design a rational variant of Boneh-DurfeeHowgraveGraham algorithm [2] which in particular solves g u, v au2 buv cv 2 0 mod q 2 on u, v, q as soon as the product uv is in O N 2 9 . Our new polynomial attack on Nice Real is the following: Randomly select a form g on the principal cycle ½N , and try to solve g u, v 0 mod q 2 in u, v, q using Rational-BonehDurfeeHowgraveGraham. Repeat until it finds a solution, and return q. The proof of this attack works in two steps: first, we prove (in Theorem 3) that the above-defined gˆk represent a non-negligible proportion of the principal cycle, and second, we prove (in Section 4.4) that Rational-BonehDurfeeHowgraveGraham finds q from any of the gˆk in polynomial time. Definition 2 (distance). we define a notion of distance between two equivalent forms f g as dist f, g min log M, M SL2 Z and f.M g . Let f, g, h be three equivalent forms in FΔ , the distance function satisfies the following properties: 1. dist f, g dist g, f 0 2. dist f, g 0 f g or f
g.SE
46
A. Bernard and N. Gama
3. dist f, h dist f, g dist g, h 4. if M SL2 Z satisfies f.M g and log M.
M
Δ , then dist f, g
Proof. The first three points follow from basic properties of the induced norm, and the fact that only isometries have a unit norm. To prove the fourth statement, let U be the fundamental automorphism of f , the eigenvalues of U are Δ and Δ1 . Any non-trivial automorphism V of f satisfies V Δ , because V is a non-zero power of U , and its spectral radius is a positive power of Δ . The matrix M of the fourth point is necessarily the smallest transformation matrix from f to g, otherwise any matrix X SL2 Z such that f.X g and X M would produce a non-trivial automorphism MX 1 of f of too small norm MX 1 Δ , which is impossible. One of the greatest advantage of this distance is the fourth statement, which in general indicates that any polynomial transformation matrix is necessarily the smallest one. This allows to efficiently lower-bound a distance. As shown in the proof, it is essential that the group of automorphism is cyclic, the fourth statement would be false on GL2 Z. The authors of [6] used another distance between f, g , which could have been formalized as the smallest k N such that k there exists h1 , . . . , hk such that i1 SET hi transforms f into g or g.SE. Inside the reduced cycle, this corresponds to Shanks distance [20]. Unfortunately, it does not satisfy any equivalent of the fourth point: there is no way to efficiently verify that a given distance, as small as it could be, is correct. All the variants we found of this distance, which aims to approximate this statement, based either on the logarithms of the hi or some maximum norms, break the positive definiteness or the triangular inequality. This explains why we do not base our proof on Shanks distance and introduce our own instead. Theorem 3. Given a NICE modulus N pq 2 , the set A gˆk RedGL2 gk , k 1, . . . sq 1 of the reduced of the q-belt has at least K.sq elements for some constant K 0. Proof. We now call Up the fundamental automorphism of the principal form of Fp . We verify that Upj 2 jp p j and that for all i, j, Qki1 Upj Qkij transforms gi into gij . Its norm is bounded by 1q Qki U j Qkij 4q jp p j . Due to point 4, for all j 1, sq 2 2, the distance dist gi , gij log Qki1 Upj Qkij is greater than j log p log 2q . By Theorem 2, the norm 2 of the reduction matrix from a gi to gˆi is upper-bounded by 2 21q N 42q p, and it follows that dist gˆi , gˆij j log p log 3528q 3 p. For this reason, if j log 3528q 3 p log p , then dist gˆi , gˆij 0 and gˆi gˆij . Using the NICE parameters, one has log 3528q 3p log p 3, thus the forms gˆ1 , gˆ4 , gˆ7 , . . . , gˆ3n1 are distinct (with n sq 6.
Smallest Reduction Matrix of Binary Quadratic Forms
4.4
47
Rational Improvement of the Boneh-Durfee-HowgraveGraham’s Algorithm
In this section, we describe our Rational-BonehDurfeeHowgraveGraham algorithm as a variant of Boneh Durfee Howgrave-Graham algorithm [2] solving rational linear equations u v C 0 mod q in the variables u, v, q when a multiple N pq r is known. The description of Rational-BonehDurfeeHowgraveGraham is summarized in Algorithm 2. Among others, it can be used to solve all the equations gˆk u, v au2 buv cv 2 0 mod q 2 of discriminant pq 2 of the previous section, because they are equivalent to u v b 2a 0 mod q. Since the solution we are looking for satisfies uv O N 1 6 , the following Theorem 4 proves that Rational-BonehDurfeeHowgraveGraham finds all solutions uv O N 2 9 , and concludes the proof of our new attack on Nice Real. More generally, given a polynomial P , the technique due to Boneh Durfee Howgrave-Graham transforms the equation P u v 0 mod q, into a lattice L of dimension m and bounded determinant, and whose short vectors are orthogonal to the integer vector S um , um 1 v, ..., uv m 1 , v m . The solutions u and v can be extracted from any of those short lattice vectors. This lattice is described by a basis B, whose rows contain the coefficients of m 1-degree polynomials having u v as a root modulo a power of q. When u and v have approximately the same size (like in Homogeneous-Coppersmith of [6]), the celebrated LLL reduction algorithm on B outputs directly the desired vector orthogonal to S. Otherwise, when u and v are unbalanced, say for instance that u is 1000 times larger than v, one first needs to re-balance the lattice by multiplying each i-th column by C i , where C is close to 1000, and only then reduce the basis. The original Boneh-Durfee-HowgraveGraham’s algorithm, which interests in integer solutions (arbitrary u and v 1), follows the above rule: the lattice basis which is actually LLL-reduced is the basis of Homogeneous-Coppersmith where each i-th column has been multiplied by X i , where X is a power of 2 just larger than the solution u. More generally, if we don’t know the relative balance between u and v but only know that the size of uv is n-bits, then we can test the n possible powers of two sequentially within a linear-factor overhead. Besides, we remark that instead of multiplying the columns of the input Homogeneous-Coppersmith basis by 1, 2, 4, ..., 2m, we describe the exact same lattice by multiplying the columns of the LLL-reduced basis, and the second one is almost reduced (LLL terminates in a very few steps). Thus after the reduction of the first Homogeneous-Coppersmith basis, one obtains all the other possible balances of u and v for free. Theorem 4. Given any integer N pq r (where p and q are unknown), and a r bound β 14 q log q log N , Algorithm 2 terminates in polynomial time, and finds a solution (if it exists) of the equation uv c mod q where u, v are unknown integers satisfying uv β. u Proof. Let U, V R2 such
that
U and v 1 log qr . ters m N 0 and t mlog
N
V . We use the same parame-
We denote by Rm X, Y the span of homogeneous polynomials of degree m, and we define the isomorphism ϕ : Rm X, Y $ Rm1 which computes
48
A. Bernard and N. Gama
Algorithm 2. Rational Boneh-Durfee-HowgraveGraham Input: An integer N N of the form pq r (p and q are unknown), an integer c logq r log N 0, N 1 and a bound β 14 q Output: u, v N3 such that uv c mod q and u v β if it exists 1: Choose the smallest m such that
m1logq r logN
1
1
1
N 2 8r m 1 2
m11
1.5, and set t
. tk
2: Compute the family Pk X, Y N r X cY k Y mk for k 0..m 3: for l 0 to log2β do 4: U 2l ; V β 2l 5: Express (or update) the family Pk k0..m on the monomial k mk Y X , and form a matrix B Mm1 Z U k V mk k0..m 6: LLL-reduce B, and call α0 , . . . , αm the first vector αk k 7: for each rational root uv of RX m k0 U k V mk X 0 do 8: if uv β and gcdu cv, N is non-trivial return u, v 9: end for 10: end for k
basis
mk
Y the coordinates of a polynomial on the basis X U k V mk k0..m . For instance, k m k k m k U V ek where ek is the k-th canonical basis vector. Let ϕX Y tk Pk k0..m be the family Pk X, Y N r X cY k Y m k Rm X, Y . By m construction, any integer linear combination R k0 Z Pk satisfy R u, v 0 mod q t and R u, v m 1 ϕ R2 (using Cauchy-Schwartz inequality). We now suppose that ϕ R is a short vector of the lattice generated by the (triangular) basis B ϕ Pk k1,m . By that, we mean ϕ R2 1.08m1 det B 1 m1 . Such a vector can be found by running the LLL algorithm on the lattice basis B (see [16]). The remainder of the proof is just a formal verification that when m grows, det B is small enough to guaranty that R u, v q t , and therefore that R u, v 0 (in Z). Since R is homogeneous, this allows to recover u and v.
5
Conclusion
We saw that reduction algorithms are conceptually simpler to study in GL2 Z, because we mostly manipulate only positive matrices, which are easy to bound. The precision of our analysis, in the worst case and also in the average case, allows us to fully prove a lattice-based total-break attack against Nice cryptosystems [12,13], which is unusual in the history of lattice based cryptology. A further lead would be to extend these results on the reduction of the forms in higher dimension. Acknowledgements. We would like to thank Fabien Laguillaumie and Guilhem Castagnos for useful discussions and valuable comments on this paper.
Smallest Reduction Matrix of Binary Quadratic Forms
49
References 1. Biehl, I., Buchmann, J.: An analysis of the reduction algorithms for binary quadratic forms. In: Voronoi’s Impact on Modern Science, pp. 71–98 (1999) 2. Boneh, D., Durfee, G., Howgrave-Graham, N.A.: Factoring n pr q for large r. In: Wiener, M. (ed.) CRYPTO 1999. LNCS, vol. 1666, p. 326. Springer, Heidelberg (1999) 3. Buchmann, J., Thiel, C., Williams, H.: Short representation of quadratic integers. Proc. of CANT 1992, Math. Appl. 325, 159–185 (1995) 4. Buchmann, J., Vollmer, U.: Binary Quadratic Forms An Algorithmic Approach. Springer, Heidelberg (2007) 5. Buell, D.A.: Binary Quadratic Forms Classical Theory and Modern Computations. Springer, Heidelberg (1989) 6. Castagnos, G., Joux, A., Laguillaumie, F., Nguyen, P.Q.: Factoring pq 2 with quadratic forms: Nice cryptanalyses. In: Matsui, M. (ed.) ASIACRYPT 2009. LNCS, vol. 5912, pp. 469–486. Springer, Heidelberg (2009) 7. Castagnos, G., Laguillaumie, F.: On the security of cryptosystems with quadratic decryption: The nicest cryptanalysis. In: Joux, A. (ed.) EUROCRYPT 2009. LNCS, vol. 5479, pp. 260–277. Springer, Heidelberg (2010) 8. Cheng, K.H.F., Williams, H.C.: Some results concerning certain periodic continued fractions. Acta Arith. 117, 247–264 (2005) 9. Cohen, H.: A Course in Computational Algebraic Number Theory, 2nd edn. Springer, Heidelberg (1995) 10. Coppersmith, D.: Small solutions to polynomial equations, and low exponent RSA vulnerabilities. J. of Cryptology 10(4), 233–260 (1997); Revised version of two articles from Eurocrypt 1996 (1996) 11. Gauss, C.F.: Disquisitiones Arithrneticae. PhD thesis (1801) 12. Hartmann, M., Paulus, S., Takagi, T.: NICE - New Ideal Coset Encryption. In: Ko¸c, C.K., ¸ Paar, C. (eds.) CHES 1999. LNCS, vol. 1717, pp. 328–339. Springer, Heidelberg (1999) 13. Jacobson, M.J., Scheidler, R., Weimer, D.: An adaptation of the NICE cryptosystem to real quadratic orders. In: Vaudenay, S. (ed.) AFRICACRYPT 2008. LNCS, vol. 5023, pp. 191–208. Springer, Heidelberg (2008) 14. Lagarias, J.C.: Worst-case complexity bounds for algorithms in the theory of integral quadratic forms. Journal of Algorithm 1, 142–186 (1980) 15. Lagrange, J.L.: Recherches d’arithm´etique. Nouveaux M´emoires de l’Acad´emie de Berlin (1773) 16. Lenstra, A.K., Lenstra Jr., H.W., Lov´ asz, L.: Factoring polynomials with rational coefficients. Mathematische Ann. 261, 513–534 (1982) 17. May, A.: Using LLL-reduction for solving RSA and factorization problems: A survey. In: Nguyen, P., Vallee, B. (eds.) The LLL algorithm, survey and Applications, Information Security and Cryptography, pp. 315–348 (2010) 18. Nguyen, P.Q., Stehl´e, D.: Low-dimensional lattice basis reduction revisited (extended abstract). In: Proceedings of ANTS VI. LNCS, Springer, Heidelberg (2004) 19. Schinzel, A.: On some problems of the arithmetical theory of continued fractions. Acta Arithmetica 6, 393–413 (1961) 20. Shanks, D.: The infrastructure of a real quadratic field and its applications. In: Proc. NTC 1992, pp. 217–224 (1972) 21. Vallee, B., Vera, A.: Lattice reduction in two dimensions: Analyses under realistic probalistic models. In: Proc. of AofA 2007, DMTCS AH, pp. 181–216 (2007) 22. Weimer, D.: An Adaptation of the NICE Cryptosystem to Real Quadratic Orders, Master’s thesis. PhD thesis, Technische Universitat Darmstadt (2004)
Practical Improvements to Class Group and Regulator Computation of Real Quadratic Fields Jean-Fran¸cois Biasse1 and Michael J. Jacobson, Jr.2, 1
´ Ecole Polytechnique, 91128 Palaiseau, France
[email protected] 2 Department of Computer Science, University of Calgary 2500 University Drive NW, Calgary, Alberta, Canada T2N 1N4
[email protected]
Abstract. We present improvements to the index-calculus algorithm for the computation of the ideal class group and regulator of a real quadratic field. Our improvements consist of applying the double large prime strategy, an improved structured Gaussian elimination strategy, and the use of Bernstein’s batch smoothness algorithm. We achieve a significant speed-up and are able to compute the ideal class group structure and the regulator corresponding to a number field with a 110decimal digit discriminant.
1
Introduction
Computing invariants of real quadratic fields, in particular the ideal class group and the regulator, has been of interest since the time of Gauss, and today has a variety of applications. For example, solving the well-known Pell equation is intimately linked to computing the regulator, and integer factorization algorithms have been developed that make use of this invariant. Public-key cryptosystems have also been developed whose security is related to the presumed difficulty of these computational tasks. See [16] for details. The fastest algorithm for computing the ideal class group and regulator in practice is a variation of Buchmann’s index-calculus algorithm [6] due to Jacobson [14]. The algorithm on which it is based has subexponential complexity in the size of the discriminant of the field. The version in [14] includes several practical enhancements, including the use of self-initialized sieving to generate relations, a single large-prime variant (based on that of Buchmann and D¨ ullman [7] in the case of imaginary quadratic fields), and a practical version of the required linear algebra. This approach proved to work well, enabling the computation of the ideal class group and regulator of a real quadratic field with a 101-decimal digit discriminant [15]. Unfortunately, both the complexity results of Buchmann’s algorithm and the correctness of the output are dependent on the Generalized Riemann Hypothesis (GRH). Nevertheless, for fields with large discriminants, this approach is the only one that works.
The second author is supported in part by NSERC of Canada.
G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 50–65, 2010. c Springer-Verlag Berlin Heidelberg 2010
Improvements in Real Quadratic Number Fields
51
Recently, Biasse [4] presented practical improvements to the corresponding algorithm for imaginary quadratic fields. These included a double large prime variant and improved algorithms for the required linear algebra. The resulting algorithm was indeed faster then the previous state-of-the-art [14], and enabled the computation of the ideal class group of an imaginary quadratic field with 110 decimal digit discriminant. In this paper, we describe a number of practical improvements to the indexcalculus algorithm for computing the class group and regulator of a real quadratic field. In addition to adaptations of Biasse’s improvements in the imaginary case, we have found some modifications designed to improve the regulator computation part of the algorithm. We also investigate applying an idea of Bernstein [3] to factor residues produced by the sieve using a batch smoothness test. Extensive computations demonstrating the effectiveness of our improvements are presented, including the computation of class group and regulator of a real quadratic field with 110 decimal digit discriminant. This paper is organized as follows. In the next section, we briefly recall the required background of real quadratic fields, and give an overview of the indexcalculus algorithm using self-initialized sieving. Our improvements to the algorithm are described in Section 3, followed by numerical results in Section 4.
2
Real Quadratic Fields
We present an overview of required concepts related to real quadratic fields and the index-calculus √ algorithm for computing invariants. For more details, see [16]. Let K = Q( Δ) be the real quadratic field of discriminant Δ, where Δ is a positive integer congruent to 0 or 1 modulo 4 with Δ or Δ/4 square-free. The integral closure of Z in K, called the maximal order, is denoted by OΔ . An interesting aspect of real quadratic fields is that their maximal orders contain infinitely many non-trivial units, i.e., units that are not roots of unity. More precisely, the unit group of OΔ consists of an order 2 torsion subgroup and an infinite cyclic group. The smallest unit greater than 1, denoted by εΔ , is called the fundamental unit. The regulator of OΔ is defined as RΔ = log εΔ . The fractional ideals of K play an important role in the index-calculus algorithm described in this paper. In our setting, a fractional ideal is a rank 2 Z-submodule of K. Any fractional ideal can be represented as √ b+ Δ s aZ + Z , a= d 2 where a, b, s, d ∈ Z and 4a | b2 − Δ. The integers a, s, and d are unique, and b is defined modulo 2a. The ideal a is said to be primitive if s = 1, and da ⊆ OΔ is integral. The norm of a is given by N (a) = as2 /d2 . Ideals can be multiplied using Gauss’s composition formulas for indefinite binary quadratic forms. Ideal norm respects ideal multiplication, and the set
52
J.-F. Biasse and M.J. Jacobson
IΔ forms an infinite abelian group with identity OΔ under this operation. The inverse of a is √ −b + Δ d −1 a = aZ + Z . sa 2 by the prime ideals of OΔ , namely those integral The group IΔ is generated √ ideals of the form pZ + (bp + Δ)/2Z where p is a prime that is split or ramified in K. As OΔ is a Dedekind domain, the integral part of any fractional ideal can be factored uniquely as a product of prime ideals. To factor a, it suffices to factor N (a) and, for each prime p dividing the norm, determine whether the prime ideal p or p−1 divides a according to whether b ≡ bp or −bp modulo 2p. The ideal class group, denoted by ClΔ , is the factor group IΔ /PΔ , where PΔ ⊆ IΔ is the subgroup of principal ideals. The class group is finite abelian, and its order is called the class number, denoted by hΔ . By computing the class group we mean computing the elementary divisors m1 , . . . , ml with mi+1 | mi for 1 ≤ i < l such that ClΔ ∼ = Z/m1 Z × · · · × Z/ml Z. 2.1
The Index-Calculus Algorithm
Like other index-calculus algorithms, the algorithm for computing the class group and regulator relies on finding certain smooth quantities, those whose prime divisors are all small in some sense. In the case of quadratic fields, one searches for smooth principal ideals for which all prime ideal divisors have norm less than a given bound B1 . The set of prime ideals B = {p1 , . . . , pn } with N pi ≤ B1 is called the factor base. A principal ideal (α) = pe11 . . . penn with α ∈ K that factors completely over the factor base yields the relation (e1 , . . . , en , log |α|). The key to the index-calculus algorithm is the fact, proved by Buchmann [6], that the set of all relations forms a sublattice Λ ⊂ Zn × R of determinant hΔ RΔ provided that the prime ideals in the factor base generate ClΔ . This follows, in part, due to the fact that L, the integer component of Λ, is the kernel of the homomorphism from Zn to ClΔ given by pe11 . . . penn for (e1 , . . . , en ) ∈ Zn . If p1 , . . . , pn generate ClΔ , then this homomorphism is surjective, and the homomorphism theorem then implies that Zn /L ∼ = ClΔ . The main idea behind the index-calculus algorithm is to find random relations until they generate the entire relation lattice Λ. Let Λ denote the sublattice of Λ generated by the relations that have been computed. To determine whether Λ = Λ, one computes an approximation h∗ of hΔ RΔ such that h∗ < hΔ RΔ < 2h∗ . The value h∗ is obtained by approximating the L-function L(1, χΔ ), where χΔ denotes the Kronecker symbol (Δ/p), and applying the analytic class number formula. If Λ ⊂ Λ, then det(Λ ) is a integer multiple of hΔ RΔ . Thus, Λ = Λ as soon as det(Λ ) < 2h∗ , because hΔ RΔ is the only integer multiple of itself in the interval (h∗ , 2h∗ ).
Improvements in Real Quadratic Number Fields
53
As described in [14], an adaptation of the strategy used in the self-initialized quadratic sieve (SIQS) factoring algorithm is used √ to compute relations. First, compute the ideal a√= pe11 . . . penn = (1/d)[aZ + (b + Δ)/2Z] with N (a) = a/d2 . Let α = (ax + (b + Δ)/2y)/d with x, y ∈ Z be an arbitrary element in a. Then √ √ b− Δ 1 b+ Δ y ax + y = (a/d2 )(ax2 + bxy + cy 2 ) N (α) = 2 ax + d 2 2 where c = (b2 − Δ)/(4a). Because ideal norm is multiplicative, there exists an ideal b with N (b) = ax2 + bxy + cy 2 such that (α) = ab. Thus, finding x and y such that N (b) factors over the norms of the prime ideals in the factor base yields a relation. Such x and y can be found by sieving the polynomial ϕ(x, y) = ax2 + bxy + cy 2 , and a careful selection of the ideals a yields a generalization of self-initialization, in which the coefficients of the sieving polynomials and their roots modulo the prime ideal norms can be computed quickly. In practice, we use ϕ(x, 1) for sieving, so that the algorithm resembles the SIQS more closely. For more details, see [14] or [16]. The determinant of the relation lattice Λ is computed in two stages. The first step is to compute the determinant of the integer part of this sublattice by finding a basis in Hermite normal form (HNF). Once Λ has full rank, the determinant of this basis is computed as the product of the diagonal elements in a matrix representation of the basis vectors. The group structure is then computed by finding the Smith normal form of this matrix. The real part of det(Λ ), a multiple of the regulator RΔ , is computed by first finding a basis of the kernel of the matrix consisting of the integer parts of the relations. Every vector (k1 , . . . , km ) ∈ Zm in the kernel corresponds to a multiple of the regulator computed with mRΔ = k1 log |α1 | + · · · + km log |αm |. The “real gcd” of the multiples m1 RΔ , . . . , mn RΔ computed from each basis vector of the kernel, defined as gcd(m1 , . . . , mn )RΔ , is then the real part of det(Λ ). An algorithm of Maurer [21] can be used to compute the real gcd efficiently and with guaranteed numerical accuracy given explicit representations of the αi and the kernel vectors. As mentioned in the introduction, the correctness of this algorithm depends on the truth of the Generalized Riemann Hypothesis. In fact, the GRH must be invoked in two places. The first is to compute a sufficiently accurate approximation h∗ of hΔ RΔ via a method due to Bach [2]. Without the GRH, an exponential number of terms in the Euler product used to approximate L(1, χΔ ) must be used (see, for example, [20]). The second is to ensure that the factor base generates ClΔ . Without the GRH, an exponential size factor base is required, whereas by a theorem of Bach [1] the prime ideals of norm less than 6 log(Δ)2 suffice. In practice, an even smaller factor base is often used, but in that case, the factor base must be verified by showing that every remaining prime ideal with norm less than Bach’s bound can be factored over the ideals in the factor base.
54
J.-F. Biasse and M.J. Jacobson
3
Practical Improvements
In this section, we describe our practical improvements for computing the class group structure and the regulator of a the real quadratic field. Some of these improvements, such as the double large prime variant and structured Gaussian elimination, were used in [4] for the simpler case of imaginary quadratic number fields. On the other hand, the batch smoothness test and system solving based methods for computing the regulator had never been implemented in the context of number fields before. 3.1
Relation Collection
Improving the relation collection phase allows us to speed up every other stage of the algorithm. Indeed, the faster the relations are found, the smaller the factor base can be, thus reducing the dimensions of the relation matrix and the time taken by the linear algebra phase. In addition, the verification phase also relies on our ability to find relations and therefore benefits from improvements to the relation collection phase. Throughout the rest of the paper, M denotes the relation matrix, the matrix whose rows are the integer parts of the relations. Large prime variants. The large prime variants were developed in the context of integer factorization to speed up the relation collection phase in both the quadratic sieve and the number field sieve. A single large prime variant was described by Buchmann and D¨ ullman [7] for computing the class group of an imaginary quadratic field, and adapted to the real case by Jacobson [14]. Biasse [4] described how the double large prime strategy could be using in the imaginary case, and obtained a significant speed-up. The idea is to keep relations involving one or two extra primes not in the factor base of norm less than B2 ≥ B1 . These relations thus have the form (α) = pe11 . . . penn p and (α) = pe11 . . . penn pp for pi in B, and for p, p of norm less than B2 . We will refer to these types of partial relations as 1-partial relations and 2-partial relations, respectively. Keeping partial relations only involving one large prime is the single large prime variant, whereas keeping those involving one or two is the double large prime variant which was first described by Lenstra and Manasse [17]. We do not consider the case of more large primes, but it is a possibility that has been studied in the context of factorization [10]. Partial relations may be identified as follows. Let m be the remainder of ϕ(x, 1) after the division by all primes p ≤ B1 , and assume that B2 < B12 . If m = 1 then we have a full relation. If m ≤ B2 then we have a 1-partial relation. We can see here that detecting 1-partial relations is almost for free. If we also intend to collect 2-partial relations then we have to consider the following possibilities:
Improvements in Real Quadratic Number Fields
1. 2. 3. 4.
55
m > B22 ; m is prime and m > B2 ; m is prime and m ≤ B2 ; m is composite and B12 < m ≤ B22 .
In Cases 1 and 2 we discard the relation. In Case 3 we have a 1-partial relation, and in Case 4 we have m = pp where p = N (p) and p = N (p ). Cases 1, 2, and 3 can be checked very easily, but if none are satisfied we need to factor m in order to determine whether Case 4 is satisfied. We used Milan’s implementation of the SQUFOF algorithm [22] based on the theoretical work of [12] to factor the m values produced. Even though we might have to factor the remainder, partial relations are found much faster than full relations. However, the dimensions of the resulting matrix are much larger, thus preventing us from running the linear algebra phase directly on the resulting relation matrix. In addition, we have to find many more relations since we have to produce a full rank matrix. We will see in §3.2 how to reduce the dimensions of the relation matrix using Gaussian elimination techniques. Batch smoothness test. After detecting potential candidates for smooth integers via the SIQS, one has to certify their smoothness. In [4,14], this was done by trial division with the primes in the factor base. The time taken by trial division can be shortened by using Bernstein’s batch smoothness test [3], which uses a product tree structure and modular arithmetic to factor a batch of residues simultaneously in time O b(log b)2 log log b where b is the total number of input bits. Instead of testing the smoothness of every potential candidate as soon as they are discovered, we rather stored them and tested them at the same time using Bernstein’s method as soon their number exceeded a certain limit. This improvement has an effect that is all the more important when the time spent in the trial division is long. In our algorithm, this time mostly depends on the tolerance value T, a parameter used to control the number of candidates yielded by the sieve for smoothness testing. 3.2
Structured Gaussian Elimination
As mentioned in §2.1, in order to determine whether the computed relations generate the entire relation lattice, we need to compute the HNF basis of the sublattice they generate. This can be done by putting the integer components of the relations as rows in a relation matrix, and computing the HNF. The first step when using large primes is to compute full relations from all of the partial relations. Traditionally, rows were recombined to give full relations as follows. In the case of 1-partial relations, any pair of relations involving the same large prime p were recombined into a full relation. In the case of 2-partial relations, Lenstra [17] described the construction of a graph whose vertices were the relations and whose edges linked vertices having one large prime in common.
56
J.-F. Biasse and M.J. Jacobson
Finding independent cycles in this graph allows us to recombine partial relations into full relations. In this paper, we instead follow the approach of Cavallar [8], developed for the number field sieve, and adapted by the first author to the computation of ideal class group structures in imaginary quadratic number fields [4], which uses Gaussian elimination on columns. The ideas is to eliminate columns using structured Gaussian strategies until the dimensions of the matrix are small enough to allow the computation of the HNF with standard algorithms. Let us recall a few definitions. First, subtracting two rows is called merging. If two relations corresponding to rows r1 and r2 share the same prime p with coefficients c1 and c2 respectively, then multiplying r1 by c2 and r2 by c1 and merging is called pivoting. Finally, finding a sequence of pivots leading to the elimination of a column of Hamming weight k is a k-way merge. We aim to reduce the dimensions of the relation matrix by performing kway merges on the columns of weight k = 1, . . . , w in increasing order for a certain bound w. To limit the growth of the density and of the size of the coefficients induced by these operations, we used optimized pivoting strategies. In what follows we describe an algorithm performing k-way merges to minimize the growth of both the density and the size of the coefficients, thus allowing us to go deeper in the elimination process and delay the explosion of the coefficients. As in [4], we define a cost function C mapping rows onto the integers. The one used in [4] satisfied 1+c 1, (1) C(r) = 1≤|ei |≤Q
|ej |>Q
where c and Q are positive numbers, and r = [e1 , . . . , en ] is a row corresponding to (α) = i pei i . This way, the heaviest rows are those which have a high density and large coefficients. In our experiments for this work, we used a different cost function, see §4.1. Then, to perform a k-way merge on a given column, we construct a complete graph G of size k such that – the vertices are the rows ri , and – every edge linking ri and rj has weight C(rij ), where rij is obtained by pivoting ri and rj . Finding the best sequence of pivots with respect to the chosen cost function C is equivalent to finding the minimum spanning tree T of G, and then recombining every row r with its parent starting with the leaves of T . Unlike in [4], we need to keep track of the permutations we apply to the relation matrix, and of the empty columns representing primes of norm less than 6 log2 Δ. This will be required for the regulator computation part of the algorithm described next. 3.3
Regulator Computation
As mentioned in §2.1, the usual way to compute the regulator is to find a basis of the kernel of the relation matrix, compute integer multiples of the regulator
Improvements in Real Quadratic Number Fields
57
from these basis vectors, and compute their real gcd using Maurer’s algorithm [21]. If det Λ > 2h∗ , then either the class number or regulator computed is too large, and we need to find extra relations corresponding to new generators, and new kernel vectors involving them. In this section, we describe a way of taking advantage of the large number of generators involved in the different partial relations. Indeed, the dimensions of the relation matrix before the Gaussian elimination stage is much larger than in the base scenario and thus involves more generators. Consequently, given a set of k ≤ dim(ker M ) kernel vectors (uj1 , . . . , ujn )j≤k , the probability that the corresponding elements vj := uj1 log |α1 | + . . . + ujn log |αn | , where αi is the generator of the i-th relation, can be recombined into R is much larger. On the other hand, the dimensions of the matrix prevents us from running a kernel computation directly after the relation collection phase. Thus, rather than attempting to compute the kernel, we use a method similar to that of Vollmer [24] based on solving linear systems. The first step of our algorithm consists of putting the matrix in a pseudo-lower triangular form using a permutation obtained during the Gaussian elimination phase. Indeed, as part of this computation we obtain a unimodular matrix U ∈ Zn×n such that ⎛ ⎞ ⎜ ⎜ A ⎜ ⎜ ⎜ ⎜ ⎜ UM = ⎜ ⎜ ⎜ ⎜ ⎜ (∗) ⎜ ⎜ ⎝
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ 1 (0) ⎟ ⎟. ⎟ ⎟ ⎟ .. ⎟ . ⎟ ⎠ (∗) 1 (0)
Thus, solving a linear system of the form xM = b for a vector b ∈ Zm boils down to solving a system of the form x A = b , then doing a trivial descent through the diagonal entries which equal 1 and finally permuting back the coefficients using U . To solve the small linear systems, we used the algorithm certSolveRedLong from the IML library [9]. It takes a single precision dense representation of A and returns an LLL-reduced solution. Once M is in pseudo-lower triangular form, we draw a set of relations r1 , . . . rd which are not already rows of M , and for each ri , i ≤ d, we solve the system xi A = ri . We then augment M with the rows ri for i ≤ d and the vectors xi with d extra coordinates, which are all set to zero except for the i-th which is set to −1.
58
J.-F. Biasse and M.J. Jacobson
⎞
⎛ ⎜ ⎜ M := ⎜ ⎝
M ri
⎟ ⎟ ⎟ xi := xi 0 . . . 0 −1 0 . . . 0 . ⎠
We clearly have xi M = 0 for i ≤ d, and the xi can be used to find a multiple of RΔ as described in §2.1.
4
Numerical Results
In this section, we give numerical results showing the impact of our improvements. For each timing, we specify the architecture used. All the timings were obtained with our code in C++ based on the libraries GMP [11], NTL [23], IML [9] and Linbox [19]. All timings are in CPU seconds. 4.1
Comparative Timings
The state of the art concerning class group and regulator computation was established in [14], where all the timings were obtained with the SPARCStation II architecture. In addition, most of the code used at the time is unavailable now, including the HNF computation algorithm. Thus, providing a meaningful comparison between our methods and those of [14] is difficult. We chose to implement the HNF computation algorithm in a way that resembles the one of [14], but takes advantage of the libraries available today for computing the determinant and the modular HNF. We used this implementation in each different scenario. The relation collection phase is easier to compare, since our method relies on SIQS. In the following, we will refer to the base case as the strategy consisting of finding the relation matrix without using the large prime variants or the smoothness batch test, and calculating the regulator by computing its kernel with the algorithm nullspaceLong from IML library. It differs from the 0 large prime case (0LP) where we use the algorithm described in §3.3 for computing the regulator, along with a relation collection phase that does not use large primes. We also denote the 1 large prime scenario by 1LP, the 2 large primes by 2LP and 2LP Batch when using batch smoothness test. Relation collection phase. In Table 1, we give the time taken to collect all necessary relations. Without large primes, we collected |B| + 100 relations, whereas when we allow large primes we need to collect enough relations to ensure that the number of rows is larger than the number of non-empty columns. We used a 2.4 GHz Opteron with 16GB of memory and took Δ = 4(10n + 3) with 40 ≤ n ≤ 70. For each discriminant, we used the optimal parameters given in [14], including the size of the factor base, even if we tend to reduce this parameter when optimizing the overall time. The only parameter we modified is the tolerance value for the SIQS, as a higher tolerance value is required for the large prime variations. In each case we took B2 = 12B1 . It is shown in [4] that the ratio B2 /B1 does not have an important impact on the sieving time.
Improvements in Real Quadratic Number Fields
59
Table 1. Comparative table of the relation collection time n 0LP 1LP 2LP 2LP Batch 40 0.83 0.48 0.63 0.90 45 6.70 3.10 2.70 2.20 50 23.00 9.50 9.20 6.10 55 56.00 26.00 23.00 15.00 60 202.00 86.00 69.00 41.00 65 1195.00 513.00 354.00 227.00 70 4653.00 1906.00 1049.00 834.00
The timings in Table 1 correspond to the optimal value of the tolerance value in each case, found by trying values between 1.7 and 4, and keeping the optimum for each scenario. For 0LP, the optimal value is between 1.7 and 2.3 whereas it is around 2.3 for 1LP, 2.8 for 2LP and 3.0 for 2LP Batch. The latter case has a higher optimal tolerance value because using the batch smoothness test allows one to spend more time factoring the residues. When using Bernstein’s smoothness test, we took batches of 100 residues. In our experiments, this value did not seem to have an important effect on the relation collection time. We observe in Table 1 that the use of the large prime variants has a strong impact on the relation collection phase, and that using the smoothness batch test strategy yields an additional speed-up of approximately 20% over the double large prime strategy. Structured Gaussian elimination. Structured Gaussian elimination allows us to reduce the time taken by the linear algebra phase by reducing the dimensions of the relation matrix. Our method minimizes the growth of the density and of the size of the coefficients. To illustrate the impact of the algorithm described in §3.2, we monitor in Table 2 the evolution of the dimensions of the matrix, the average Hamming weight of its rows, the extremal values of its coefficients and the time taken for computing its HNF in the case of a relation matrix corresponding to Δ = 4(1060 + 3). We keep track of these values after all i-way merges for some values of i between 5 and 170. The original dimensions of the matrix are 2000 × 1700, and the timings are obtained on a 2.4 Ghz Opteron with 32GB of memory. In [4], the first author regularly deleted the rows having the largest coefficients. To do this, we need to create more rows than in the base case. To provide a fair comparison between the two strategies, we used the same relation matrix resulting from a relation collection phase without large primes, and with as few rows as was required to use the same algorithm as in [14]. We therefore had to drop the regular row deletion. We also tuned the cost function to compensate for the resulting growth of the coefficients, using 1 + 100 |ej | , C(r) = 1≤|ei |≤8
instead of (1).
|ej |>8
60
J.-F. Biasse and M.J. Jacobson
The HNF computation consists of taking the GCD of the determinants of two different submatrices of the matrix after elimination using Linbox, and using the modular HNF of NTL with this value. Indeed, this GCD (which is likely to be relatively small) is a multiple of hΔ . This method, combined with an elimination strategy due to Havas [13], was used in [14] and implemented in LiDIA [18]. As this implementation is no longer available, we instead refer to the timings of our code, which has the advantage of using the best linear algebra libraries available today. Table 2. Comparative table of elimination strategies Naive Gauss i Row Nb Col Nb Average weight max coeff min coeff HNF time 5 1189 1067 27.9 14 -17 357.9 10 921 799 49.3 22 -19 184.8 30 757 635 112.7 51 -50 106.6 50 718 596 160.1 81 -91 93.7 70 699 577 186.3 116 -104 85.6 90 684 562 205.5 137 -90 79.0 125 664 542 249.0 140 -146 73.8 160 655 533 282.4 167 -155 72.0 170 654 532 286.4 167 -155 222.4 With dedicated elimination strategy i Row Nb Col Nb Average weight max coeff min coeff HNF time 5 1200 1078 26.8 13 -12 368.0 10 928 806 42.6 20 -15 187.2 30 746 624 82.5 33 -27 100.8 50 702 580 107.6 64 -37 84.3 70 672 550 136.6 304 -676 73.4 90 656 534 157.6 1278 -1088 67.5 125 637 515 187.1 3360 -2942 63.4 160 619 497 214.6 5324 -3560 56.9 170 615 493 247.1 36761280 -22009088 192.6
Table 2 shows that the use of our elimination strategy leads to a matrix with smaller dimensions (493 rows with our method, 533 with the naive elimination) and lower density (the average weight of its rows is of 214 with our method and 282 with the naive elimination). These differences result in an improvement of the time taken by the HNF computation: 56.9 seconds with our method against 72.0 seconds with the naive Gaussian elimination. The regular cancellation of the rows having the largest coefficients over the course of the algorithm would delay the explosion of the coefficient size, but require more rows for the original matrix. This brutal increase in the size of the extremal values of the matrix can be seen in Table 2. At this point these higher values propagate during pivoting operations, and any further column elimination becomes counter-productive.
Improvements in Real Quadratic Number Fields
61
Factor base verification. The improvements in the relation collection phase have an impact on the factor base verification. The impact of the smoothness batch test is straightforward, whereas the large prime variants act in a more subtle way. Indeed, we create many more relations when using the large prime variants, and the relations created involve primes of larger norm. Therefore, a given prime not in B of norm less than 6 log2 Δ is more likely to appear in a relation, and thus not to need to be verified. Table 3 shows the impact of the large prime variants and of the batch smoothness test on the verification time. We used a 2.4 GHz Opteron with 16GB of memory. We considered discriminants of the form Δ = 4(10n + 3) for n between 40 and 70, and we chose in every case the factor base giving the best results for the base scenario. Table 3. Comparative table of the factor base verification time n 40 45 50 55 60 65 70
0LP 17.0 77.0 147.0 308.0 826.0 8176.0 9639.0
1LP 11.0 44.0 85.0 167.0 225.0 1606.0 4133.0
2LP 2LP Batch 11.0 6.2 30.0 18.0 52.0 43.0 134.0 110.0 282.0 274.0 1760.0 1689.0 5777.0 2706.0
Regulator computation. Our method for computing the regulator avoids computing the relation matrix kernel. Instead, we need to solve a few linear systems involving the matrix resulting from the Gaussian elimination. To illustrate the impact of this algorithm, we used the relation matrix obtained in the base case for discriminants of the form 4(10n + 3) for n between 40 and 70. The timings are obtained on a 2.4GHz Opteron with 16GB of memory. In Table 4, the timings corresponding to our system solving approach are taken with seven kernel vectors. However, in most cases only two or three vectors are required to compute the regulator. As most of the time taken by our approach Table 4. Comparative table of regulator computation time n Kernel Computation System Solving 40 15.0 6.2 45 18.0 8.3 50 38.0 20.0 55 257.0 49.0 60 286.0 103.0 65 5009.0 336.0 70 10030.0 643.0
62
J.-F. Biasse and M.J. Jacobson Table 5. Effect on the overall time n 40
45
50
55
60
65
70
strategy base 0LP 1LP 2LP 2LP Batch base 0LP 1LP 2LP 2LP Batch base 0LP 1LP 2LP 2LP Batch base 0LP 1LP 2LP 2LP Batch base 0LP 1LP 2LP 2LP Batch base 0LP 1LP 2LP 2LP Batch base 0LP 1LP 2LP 2LP Batch
|B| relations elimination HNF regulator verification total 400 0.8 0.1 3.2 14.6 16.8 35.6 400 0.7 0.1 2.2 6.0 16.6 25.7 300 0.8 0.2 2.5 6.4 13.1 23.1 250 1.7 0.3 4.8 8.7 18.0 33.3 250 0.5 0.2 3.6 6.7 4.4 15.5 500 6.7 0.1 5.1 18.0 77.0 107.0 500 5.9 0.2 4.9 10.0 85.0 106.0 400 4.0 0.4 6.0 11.0 50.0 71.0 350 3.8 0.5 12.0 17.0 36.0 69.0 350 2.6 1.1 9.0 14.0 30.0 57.0 750 23.0 0.3 16.0 38.0 147.0 224.0 700 21.0 0.4 15.0 20.0 147.0 203.0 450 20.0 0.4 10.0 17.0 108.0 155.0 400 14.0 0.8 22.0 23.0 74.0 133.0 400 10.0 0.6 21.0 25.0 62.0 119.0 1200 129.0 1.9 60.0 257.0 308.0 756.0 1300 47.0 0.7 52.0 49.0 265.0 414.0 650 61.0 0.7 28.0 33.0 255.0 378.0 550 40.0 1.1 48.0 48.0 177.0 313.0 550 34.0 1.0 47.0 48.0 141.0 271.0 1700 322.0 2.9 95.0 286.0 830.0 1535.0 1700 187.0 1.3 106.0 103.0 846.0 1244.0 750 309.0 1.0 45.0 64.0 865.0 1284.0 700 143.0 2.1 152.0 137.0 365.0 799.0 700 142.0 1.8 103.0 100.0 309.0 655.0 2700 10757.0 12.0 652.0 5009.0 8176.0 24607.0 2700 1225.0 2.8 489.0 336.0 3676.0 5730.0 1900 1003.0 15.0 318.0 262.0 2984.0 4583.0 1200 753.0 4.7 525.0 398.0 1943.0 3624.0 1000 1030.0 35.0 199.0 219.0 1642.0 3125.0 3700 17255.0 24.0 1869.0 10031.0 9639.0 38818.0 3600 4934.0 19.0 1028.0 644.0 9967.0 16591.0 2500 3066.0 17.0 845.0 646.0 9005.0 13579.0 1700 2414.0 27.0 2054.0 1295.0 4590.0 10379.0 1700 2588.0 20.0 1372.0 934.0 5078.0 9991.0
is spent on system solving, we see that computing fewer kernel vectors would result in an improvement of the timings, at the risk of obtaining a multiple of the regulator. Overall time. We have studied the individual impact of our improvements on each stage of the algorithm. We now present their effect on the overall time taken by the algorithm, including the factor base verification time, for discriminants of the form Δ = 4(10n + 3) with 40 ≤ n ≤ 70 on a 2.4 GHz Opteron with 16GB of memory. We used the same parameters as in [14], except for the tolerance
Improvements in Real Quadratic Number Fields
63
and the size of the factor base. We notice in Table 5 that the optimal size of the factor base is smaller when we use improvements for the sieving phase. For example the optimal size for the double large prime variant is half the one of the base case scenario. This results in an improvement in the HNF and regulator computation whereas the relation collection time can remain unchanged, or even increase. The tolerance value we chose varies only with the strategy, but not with the size of the discriminant. We chose 2.0 for the base case and 0LP whereas we set it to 2.3 for 1LP, 2.8 for 2LP and 3.0 for 2LP Batch. We eliminated columns of weight up to w = 150 since Table 2 indicates that further elimination is counter-productive. Table 5 shows that there is an overall speed-up of of a factor of 2 for the smallest discriminants and 4 for the largest. The base case with the largest discriminants suffers from the necessity of finding some relations in a more randomized way. This ensures that we can get full rank submatrices of the relation matrix after the Gaussian elimination to compute a small multiple of hΔ . Matrices produced using the large prime variants do not need this extra step, even with the largest discriminants. This naturally affects the sieving time, since we cannot use SIQS for that purpose, but also affects phases relying on linear algebra. Indeed, elimination produces a matrix with larger entries and dimensions. 4.2
Large Example
The improvements we described allow us to compute class groups and regulators of real number fields with larger discriminants than was previously possible. The key is to parallelize the relation collection and verification phase, while the linear algebra has to be performed the usual way. These methods were successfully used in [4] to compute the class group structure of an imaginary quadratic field with a 110-digit discriminant. We used a cluster with 260 2.4GHz Xeon cores to compute a relation matrix corresponding to the discriminant Δ110 := 4(10110 +3) in 4 days. We allowed two large primes, used a tolerance value of 3.0, tested batches of 100 residues, took w = 250 and set |B| = 13000 . Then, we used three 2.4 GHz Opterons with 32GB of memory each to compute determinants of full-rank submatrices of the relation matrix after the Gaussian elimination in 1 day, and one 2.4GHz Opteron to compute the HNF modulo the GCD of these determinants in 3 days. We had to find 4018 extra relations during the verification phase that took 4 days on 96 2.4GHz Xeon cores. We thus obtained that (2) ClΔ110 ∼ = Z/12Z × Z/2Z , and the corresponding regulator is RΔ110 ≈ 70795074091059722608293227655184666748799878533480399.6730200233 .
We estimate that it would take two weeks (4000 relations per day) to complete the relation collection for Δ120 with the same factor base as Δ110 , thus requiring a similar time for the linear algebra.
64
5
J.-F. Biasse and M.J. Jacobson
Conclusions
Recently, our work has been extended to the problems of principal ideal testing and solving the discrete logarithm problem in the ideal class group [5]. The double large prime variant and improvements to relation generation translated directly to improvements in this context. However, HNF computations are not required for this problem, and linear system solving over Z can be used instead. The numerical results were used to give estimates for discriminant sizes that offer equivalent security to recommended sizes of RSA moduli. Some possibilities for further improvements remain to be investigated. For example, a lattice sieving strategy could be used to sieve ϕ(x, y) instead of ϕ(x, 1). Factor refinement and coprime factorization techniques may be a useful alternative to Bernstein’s batch smoothness test. Multiple large primes have been successfully used for integer factorization and could also be tried in our context. There is also still room for improvement to the linear algebra components. For example, a HNF algorithm that exploits the natural sparseness of the relation matrix, perhaps as a black-box algorithm, would be useful. If such an algorithm were available, we could reconsider using Gaussian elimination techniques since they induce a densification of the matrix. We could also study the effect of other dense HNF algorithms in existing linear algebra packages such as KASH, Pari, Sage and especially MAGMA which seems to have the most efficient HNF algorithm for our types of matrices. In that case, we would need the elimination phase regardless of how these algorithms are affected by the density and the size of the coefficients of the matrix. Indeed, we cannot afford manipulating a dense representation of the matrix before the Gaussian elimination phase.
References 1. Bach, E.: Explicit bounds for primality testing and related problems. Math. Comp. 55(191), 355–380 (1990) 2. Bach, E.: Improved approximations for Euler products. In: Number Theory: CMS Proc., vol. 15, pp. 13–28. Amer. Math. Soc., Providence (1995) 3. Bernstein, D.: How to find smooth parts of integers. Mathematics of Computation (submited) 4. Biasse, J.-F.: Improvements in the computation of ideal class groups of imaginary quadratic number fields. In: Advances in Mathematics of Communications (to appear 2010) 5. Biasse, J.-F., Jacobson Jr., M.J., Silvester, A.K.: Security estimates for quadratic field based cryptosystems. In: ACISP (to appear 2010) 6. Buchmann, J.: A subexponential algorithm for the determination of class groups and regulators of algebraic number fields. In: S´eminaire de Th´eorie des Nombres (Paris), pp. 27–41 (1988-1989) 7. Buchmann, J., D¨ ullmann, S.: Distributed class group computation. In: Festschrift aus Anlaß des sechzigsten Geburtstages von Herrn Prof. Dr. G. Hotz, pp. 69–79. Universit¨ at des Saarlandes (1991), Teubner, Stuttgart (1992)
Improvements in Real Quadratic Number Fields
65
8. Cavallar, S.: Strategies in filtering in the number field sieve. In: Bosma, W. (ed.) ANTS 2000. LNCS, vol. 1838, pp. 209–232. Springer, Heidelberg (2000) 9. Chen, Z., Storjohann, A., Fletcher, C.: IML: Integer Matrix Library. Software (2010), http://www.cs.uwaterloo.ca/~ astorjoh/iml.html 10. Dodson, B., Leyland, P.C., Lenstra, A.K., Muffett, A., Wagstaff, S.: MPQS with three large primes. In: Fieker, C., Kohel, D.R. (eds.) ANTS 2002. LNCS, vol. 2369, pp. 446–460. Springer, Heidelberg (2002) 11. GMP, The GNU multiple precision bignum library. Software (2010), http://gmp-lib.org/ 12. Gower, J.E., Wagstaff, S.: Square form factorization. Mathematics of Computation 77, 551–588 (2008) 13. Havas, G., Majewski, B.S.: Integer matrix diagonalization. Journal of Symbolic Computing 24, 399–408 (1997) 14. Jacobson Jr., M.J.: Subexponential class group computation in quadratic orders, Ph.D. thesis, Technische Universitt Darmstadt, Darmstadt, Germany (1999) 15. Jacobson Jr., M.J., Scheidler, R., Williams, H.C.: The efficiency and security of a real quadratic field based key exchange protocol. In: Public-Key Cryptography and Computational Number Theory, Warsaw, Poland, pp. 89–112. de Gruyter (2001) 16. Jacobson Jr., M.J., Williams, H.C.: Solving the Pell equation. CMS Books in Mathematics. Springer, Heidelberg (2009) ISBN 978-0-387-84922-5 17. Lenstra, A.K., Manasse, M.S.: Factoring with two large primes (extended abstract). In: Damg˚ ard, I.B. (ed.) EUROCRYPT 1990. LNCS, vol. 473, pp. 72–82. Springer, Heidelberg (1991) 18. LiDIA Group, LiDIA: a c++ library for computational number theory. Software, Technische Universit¨ at Darmstadt, Germany (1997), http://www.informatik.tu-darmstadt.de/TI/LiDIA 19. LinBox, Project LinBox: Exact computational linear algebra. Software (2010), http://www.linalg.org/ 20. Louboutin, S.: Computation of class numbers of quadratic number fields. Math. Comp. 71(240), 1735–1743 (2002) 21. Maurer, M.: Regulator approximation and fundamental unit computation for real quadratic orders, Ph.D. thesis, Technische Universitt Darmstadt, Darmstadt, Germany (1999) 22. Milan, J.: Tifa. Software (2010), http://www.lix.polytechnique.fr/Labo/Jerome-Milan/tifa/tifa.xhtml 23. Shoup, V.: NTL: A Library for doing Number Theory. Software (2010), http://www-shoup.net/ntl 24. Vollmer, U.: An accelerated Buchmann algorithm for regulator computation in real quadratic fields. In: Fieker, C., Kohel, D.R. (eds.) ANTS 2002. LNCS, vol. 2369, pp. 148–162. Springer, Heidelberg (2002)
On the Use of the Negation Map in the Pollard Rho Method Joppe W. Bos, Thorsten Kleinjung, and Arjen K. Lenstra Laboratory for Cryptologic Algorithms EPFL, Station 14, CH-1015 Lausanne, Switzerland
Abstract. The negation map can be used to speed up the Pollard rho method to compute discrete logarithms in groups of elliptic curves over finite fields. It is well known that the random walks used by Pollard rho when combined with the negation map get trapped in fruitless cycles. We show that previously published approaches to deal with this problem are plagued by recurring cycles, and we propose effective alternative countermeasures. As a result, fruitless cycles can be resolved, but the best speedup we managed to achieve is√by a factor of only 1.29. Although this is less than the speedup factor of 2 generally reported in the literature, it is supported by practical evidence. Keywords: Pollard’s rho method, fruitless cycles, negation map.
1
Introduction
The difficulty of the elliptic curve discrete logarithm problem (ECDLP) underlies the security of cryptographic schemes based on elliptic curves over finite fields [11,13]. The best method known to solve ECDLP for curves without special properties is the parallelized [17] Pollard rho method [15]. A common optimization is to halve the search space by identifying a point with its inverse [18,9,7]. Because representatives for the equivalence classes can quickly be computed using the negation√map, this equivalence relation may result in a speedup by a factor of up to 2 when solving ECDLP. For the elliptic curves over binary extension fields F2t from [12], order t equivalence relations can be used as well, √ resulting in a speedup by a factor of up to 2t [18,9]. Usage of the negation map in the context of the Pollard rho method leads to fruitless cycles, useless cycles trapping the random walks. An analysis of their likelihood of occurrence appeared in [7]. Various methods have been proposed [18,9] to deal with them, all leading to costlier random walks and administrative overhead. The literature suggests that √ the resulting inefficiencies are negligible, and that a speedup by a factor of 2 is attainable [1, Section 19.5.5]. We analyze fruitless cycles and the previously published methods to avoid their ill effects and show that current approaches to escape from cycles suffer from recurring cycles. These may have contributed to the lack of practical usage of the negation map to solve prime field ECDLPs: it was not used for the solutions G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 66–82, 2010. c Springer-Verlag Berlin Heidelberg 2010
On the Use of the Negation Map in the Pollard Rho Method
67
[10,6] of the 79-, 89-, 97- and 109-bit prime field Certicom challenges [5]. Neither was it used by the independent current 112-bit prime field record [3]. We present and analyze alternative methods to deal with fruitless cycles. All our analyses are supported by experiments. We found that the negation map indeed leads to a speedup, but we have √ not been able to reach more than a factor of 1.29, somewhat short of the 2 that we had hoped for. We also found that the best attainable speedup depends on the platform one uses: for instance, if the Pollard rho method is parallelized in SIMD fashion, it is a challenge to achieve any speedup at all. This has consequences for the applicability of the negation map in large scale prime field ECDLP solution attempts. For such efforts, all participating processors must use the same random walk definition, so one may desire to gear the implementation towards processors with the best performance/price ratio, such as graphics cards (which are SIMT, a SIMD variant). The negation map (while dealing with cycles) slows down random walks in three ways. In the first place, on average more elliptic curve group operations are required per step of each walk. This is unavoidable and attempts should be made to minimize the number of additional operations. Secondly, dealing with cycles entails administrative overhead and branching, which cause a non-negligible slowdown when running multiple walks in SIMD-parallel fashion. Finally, the best way to counter the effect of the higher average number of group operations per step is making the walks “more random” by allowing a finer grained decision per step. However, the beneficial effects of this approach are, in most circumstances on current processors, wiped out by cache inefficiencies. It will be seen that it is best to strike a balance between the first and third of these slowdowns. The second slowdown somewhat affects regular PCs, but is a major obstacle to the negation map in SIMD environments. This paper is organized as follows. Section 2 recalls background on ECDLP, the Pollard rho method and fruitless cycles. Section 3 introduces recurring cycles and presents and analyzes new methods to deal with them. Section 4 compares the various cycle reduction, detection, and escape methods in practice.
2 2.1
Preliminaries The Elliptic Curve Discrete Logarithm Problem
Let Fp denote a finite field of odd prime characteristic p. Any a, b ∈ Fp with 4a3 + 27b2 = 0 define an elliptic curve Ea,b over Fp . The additively written group of points Ea,b (Fp ) of Ea,b over Fp is defined as the zero point o along with the set of pairs (x, y) ∈ Fp × Fp that satisfy the shortened Weierstrass equation y 2 = x3 + ax + b. Let p, a, b and g ∈ Ea,b (Fp ) of prime order q be such that the index [Ea,b (Fp ) : g] is small. For h ∈ g, the ECDLP is to find an integer m such that mg = h. For curves without special properties, solving ECDLP is √ believed to require an effort on the order of q. Pollard’s rho method achieves this run time, while requiring more or less constant memory.
68
2.2
J.W. Bos, T. Kleinjung, and A.K. Lenstra
Pollard’s Rho Method
If objects are selected truly at random and with replacement from q objects, the conditional probability at step n + 1 of finding the first duplicate (or collision) is nq (if n < q). Via straightforward arguments this leads to πq/2 for the expected number of steps until the first collision. If random objects are selected as ug + vh ∈ g for random integer multipliers u, v, a collision corresponds to u, v, u ¯, v¯ such that ug + vh = u ¯g + v¯h. Unless v¯ ≡ v mod q, the value m = u−¯ u mod q solves the discrete logarithm problem. The expected number of steps v ¯−v of this idealized version of Pollard’s rho method [15] is πq/2. r-adding and r+s-mixed walks. Pollard’s rho method uses an approximation of a truly random walk in g. Let, for a small integer r, an index function : g → [0, r − 1] induce an r-partition g = ∪r−1 i=0 Gi of g, where Gi = {x : x ∈ g, (x) = i} and all Gi have cardinality close to qr . For random integers ui , vi , elements fi = ui g + vi h ∈ g are precomputed for 0 ≤ i < r. Starting at a random but known multiple of g, the successor of a point p of the walk is defined as p + f(p) ∈ g. It is easy to keep track of the u, v such that p = ug + vh. Such an r-adding walk results in anexpected number of steps until a collision occurs that is somewhat larger than πq/2, as shown by Brent and Pollard [4] i and expanded upon in [2]. Assume that is perfectly random. Let pi = #G q . A point in the walk is said to belong to class i if its predecessor upon its first occurrence belongs to Gi . If the nth point belongs to Gj (with probability pj ) and the (n + 1)st point produces the first collision, the collision point cannot be of class j (this happens with probability pj ), since then the collision would have occurred in step n. Therefore, the probability that the first collision occurs at step n + 1 is r−1 n (1 − p2j ). q j=0 With q =
1−
q r−1 j=0
p2j
this is
n q .
We get via the same arguments referred to above
πq = 2
2(1 −
πq r−1 j=0
p2j )
(1)
for the expected number of steps until the first collision. Pollard [15] uses r = 3, f0 = h, and f2 = g, but replaces the i = 1 case by the doubling 2p. Teske [16] shows that a larger r, such as r = 20, leads to better performance on average, conform the analysis, even if none of the choices does an explicit doubling, as Pollard’s i = 1 case. Inclusion of doublings leads to r + s-mixed walks: with : g → [0, r + s − 1] q , the next point equals partitioning g into r + s parts of cardinality close to r+s p + f(p) if 0 ≤ (p) < r, but 2p if (p) ≥ r. Pollard’s walk is a 2 + 1-mixed walk. The analysis above applies again, assuming that we consider the doublings as one class, hit with probability pD . Experiments by Teske show that best performance is achieved for rs between 14 and 12 but that apart from the case r = 3 mixed
On the Use of the Negation Map in the Pollard Rho Method
69
walks are not significantly better. The analysis and our own experiments, as reported below, suggest that the optimal ratio rs is close to zero. Per step the occurrence probability of the event p = fi (and thus a chance to solve the discrete logarithm problem) is negligible compared to the probability of a birthday collision. So, for r-adding walks doublings most likely will not occur. Parallelized random walks. Parallelization of Pollard’s rho method does not consist of running any number of random walks in parallel, until one of √ them M , so collides: on M processors the expected speedup would be by a factor of √ overall it would require M more processing power than a single processor. The proper way to parallelize Pollard’s rho method is presented in [17]. It achieves an M -fold speedup on M processors, thus requiring the same overall processing 1 th of the time. Different processes must be power as a single process, but in M able to efficiently recognize if, probably at different points in time, their walks collide. To achieve this, each process generates a single random walk, each from its own random starting point, but all using the same index function and the same fi ’s. As soon as a walk hits upon a distinguished point, this point is reported. The idea is that when two walks collide – without noticing it – they will keep taking the same steps (because they use the same walk definition) and will thus both ultimately reach the same distinguished point. This will be noticed when the colliding distinguished point is reported. The discrete logarithm can then be computed from the two, hopefully distinct, pairs of integer multipliers u, v that correspond to the same distinguished point. A distinguished point must be easy to recognize, occur with low enough probability to make it possible to store them all and to efficiently find collisions, but occur often enough for every walk to hit one. The distinguishing property could be that k specific bits of the point’s x-coordinate are zero, in which case walks may hit a distinguished point once every 2k steps. The parallelized version of Pollard’s rho method requires a unique, and thus affine, point representation to make the walks well-defined and to recognize distinguished points. The fastest suitable type of elliptic curve group arithmetic uses the affine Weierstrass point representation. Per group operation, it requires a (usually expensive) modular inversion. Its cost is amortized among the walks running in parallel per processor, at the cost of three modular multiplications per step per walk, using Montgomery’s simultaneous inversion [14]. Point doubling requires an extra modular squaring compared to regular non-doubling point addition. This makes doubling on average about 76 times slower than regular addition when parallelized walks and simultaneous inversion are used. Using automorphisms. Following [18], define an equivalence relation ∼ on g by p ∼ −p for p ∈ g and, instead of searching g of size q, search g/∼ of size about q2 . Denoting the equivalence class containing p and −p by ∼p, it may be represented by the element with y-coordinate of least absolute value. It is trivial to calculate since −(x, y) = (x, −y) for (x, √y) ∈ g. Thus, using this negation map one would expect to save a factor of 2 in the number of steps. √ For r-adding and r + s-mixed walks the speedup by a factor of 2 is slightly too pessimistic. Let the definitions of pi , pD , and of class i be as above. Assume
70
J.W. Bos, T. Kleinjung, and A.K. Lenstra
Table 1. Number of steps required by the Pollard rho method in random elliptic curve groups of 31-bit q over prime fields of random 31-bit prime characteristic p, prime order divided by πq/2 or by πq/4 (without or with the negation map). Lowest and highest averages are over 10 measurements. Each measurement calculates the average number of steps taken until a collision occurs, over 100 000 collision searches where for each search a prime p and an elliptic curve over Fp are randomly selected until the order q of the group of points is prime. Overall average is the average of the 10 averages (thus, the average over one million searches). Expression (1) and (2) columns are the quotients as 1 expected based on expressions (1) (with pi = 1r for 0 ≤ i < r) and (2) (with pi = r+s s for 0 ≤ i < r and pD = r+s ), respectively. Those expressions are for q → ∞ and indeed for larger (smaller) q they give a better (worse) fit. Without negation map Averages Expression lowest overall highest (1) 8-adding 1.079 1.083 1.085 1.069 16-adding 1.032 1.037 1.040 1.033 32-adding 1.014 1.018 1.019 1.016 16 + 4-mixed 1.041 1.043 1.044 1.043 16 + 8-mixed 1.075 1.078 1.081 1.078
With negation map Averages Expression lowest overall highest (2) 1.035 1.039 1.042 1.033 1.015 1.017 1.020 1.016 1.007 1.009 1.011 1.008 1.036 1.038 1.040 1.031 1.075 1.077 1.079 1.069
that the nth point belongs to Gj and that the (n + 1)st point produces the first collision while hitting the representative p, directly or after negation. If this step is a doubling then the analysis is as above. This happens with probability p2D . Otherwise, we only exclude the case that, as a result of just the addition, the two predecessors hit the same point (p or −p). This happens with probability Therefore, the probability that the first collision occurs at step n + 1 is
p2j 2 .
r−1 2 pj 2n (1 − p2D − ). q 2 j=0
As above we get
πq 4(1 −
p2D
−
1 2
r−1 j=0
p2j )
(2)
for the expected number of steps until√the first collision. For the same parameter values this expression is more than 2 smaller than Expression (1). However, usage of the negation map requires modifications to the iteration function due to the occurrence of fruitless cycles. This disadvantage of the negation map was already pointed out in [9,18]. It is the focus of this article. The group g may admit other trivially computable maps. For Koblitz curves the √ Frobenius automorphism of a degree t binary extension field leads to a further t-fold speedup. This does not apply to the case considered here. Small scale experiments. We checked the accuracy of predictions based on expressions (1) and (2). The results, for 31-bit primes q, are listed in Table 1.
On the Use of the Negation Map in the Pollard Rho Method
71
With all averages larger than 1, both r-adding and r + s-mixed walks on average perform worse than truly random walks. For most walks with the negation map the averages are lower than their negation-less counterparts, indicating√that the reduction factor in the expected number of steps is indeed larger than 2. This does not imply a speedup by the same factor, because to obtain the figures costly fruitless cycle detection methods had to be used. It can be seen that r + s-mixed walks are disadvantageous if s > r4 . 2.3
Fruitless Cycles
Straightforward application of the negation map to Pollard’s rho method with r-adding or r + s-mixed walks does not work due to fruitless cycles. This section describes the current state-of-the-art of dealing with those cycles. Length 2 cycles. If a random walk step goes from p to −p − fi (with probability 12 , for some i) and −p − fi ∈ Gi (with probability 1r ), then the next point after −p − fi is p again (with probability 1), thereby cancelling the effect of the previous step. It follows that a fruitless 2-cycle starts from a random point with 1 probability 2r , cf. [7, Proposition 31]. This 2-cycle is denoted as (i,−)
(i,−)
p −→ −(p + fi ) −→ p. Here “(i, s)” with s ∈ {−, +} indicates that addition constant fi is added to a point p after which the result is left as is (s = +) or negated (s = −) to find the correct representative (p + fi if s = +, or −p − fi if s = −). Any walk with two consecutive steps “(i, −)” is trapped in an infinite loop. Because this happens 1 , all walks can be expected to end up in fruitless cycles after with probability 2r a moderate number of steps when the negation map is used with r-adding walks. Looking ahead to reduce 2-cycles. To reduce the occurrence of 2-cycles, Wiener and Zuccherato propose to use a more costly iteration function that results in a lower probability that two successive points belong to the same partition [18]. This can be achieved by using the first i of (p), (p) + 1, . . ., (p) + r − 1 such that i mod r = (∼ (p + fi )), if such an index exists (here and in the sequel indices i in fi are understood to be taken modulo r). Thus, define the next point as f (p) with f : g → g defined by E(p) if j = (∼(p + fj )) for 0 ≤ j < r f (p) = ∼(p + fi ) with i ≥ (p) minimal s.t. (∼(p + fi )) = i mod r. The function E : g → g may restart the walk at a new random initial point. The latter is expected to happen once every rr steps and will therefore not affect the The expected cost per step of the walk is increased by a factor of r efficiency. 1 1 1 i=0 r i , which lies between 1 + r and 1 + r−1 . Dealing with fruitless cycles in general. Although the look-ahead technique reduces the frequency of 2-cycles, they may still occur [18]. This is elaborated upon in Section 3. Even so, it is well known that just addressing 2-cycles does
72
J.W. Bos, T. Kleinjung, and A.K. Lenstra 4.5e+06 4e+06
steps / second
3.5e+06 3e+06 2.5e+06 2e+06 1.5e+06 1e+06 500000 0
2
4
6
8
10
log2 (r)
12
14
16
18
Fig. 1. Total number of steps per second as a function of r, taken by 200 parallel r-adding walks sharing the modular inversion and not using the negation map, for Pollard’s rho method applied to a 131-bit prime ECDLP
not solve the problem of fruitless cycles, because longer cycles will occur as well. Reducing their occurrence requires additional overhead on top of what is already incurred to reduce 2-cycles. Given that fruitless cycles are unavoidable, they must be effectively dealt with when they occur. In [9] a general approach is proposed to detect cycles and to escape from them: after α steps record a length β sequence of successive points and compare the next point to these β points. If a cycle is detected a cycle representative p is chosen deterministically from which the cycle is escaped. One may add f(p)+c for a fixed c ∈ [2, r − 1] (the choice c = 1 is bad as it could lead to an immediate cycle recurrence). Instead one may add a distinct precomputed value f that does not depend on the escape-point, or one may add f(p) from a distinct list of r precomputed values f0 , f1 , . . . , fr−1 . In the next section we discuss fruitless cycles in greater detail and propose alternative methods that avoid problems that the method from [9] may run into.
3
Improved Fruitless Cycle Handling
The probability to enter a fruitless cycle decreases with increasing r [7]. This does not imply that it suffices to take r large enough to make the probability sufficiently low. Fig. 1 depicts the effect of increasing r-values on the performance of an r-adding walk, measured as number of steps per second. The performance deterioration can be attributed to the increasing rate of cache misses during retrieval of the addition constants fi . The effect varies between processors, implementations, and elliptic curves. It is worsened for more contrived walks, such as those using the negation map where cycle reduction, detection and escape methods are unavoidable. Unless the expected overall number of steps (of or√ der q) is too small to be of interest, r cannot be chosen large enough to both
On the Use of the Negation Map in the Pollard Rho Method
(i,−)
(i,−) −p−fi =q
p (i,−)
(i−1, ..)
(∼(p+fi−1 )) = i−1
73
(i−1, ..)
(∼(q+fi−1 )) = i−1
−p−fi =q
p (i−1, ..)
(i,−)
p¯ = ∼(p+fi−1 )
¯q = ∼(q+fi−1 )
(j, ..) (∼(p¯ +fj )) ∈ {i−1, j}
(i−1, ..)
(k, ..) (∼(¯q +fk )) ∈ {i−1, k}
Fig. 2. 2-cycles caused by 2-cycle reduction (left) and 4-cycle reduction. The dotted steps are prevented.
avoid fruitless cycles and achieve adequate performance. Therefore, in this section we concentrate on other ways to deal with fruitless cycles. We first discuss short-cycle reduction techniques, next discuss cycle detection methods and analyze their behavior, and finally propose alternative methods. 3.1
Short Fruitless Cycle Reduction
2-cycles. Unfortunately, the look-ahead technique to reduce 2-cycles presented above introduces new 2-cycles. The dotted lines in the left example in Fig. 2 are the steps taken by the regular iteration function, the new cycle is depicted by the solid lines which are the steps taken as a result of f (p) and f (q). This new cycle occurs with probability 2r13 . It is the most likely 2-cycle introduced by the look-ahead technique. Lemma 1. The probability to enter a fruitless 2-cycle when looking ahead to reduce 2-cycles while using an r-adding walk is 1 2r
r−1 2
1 1 (rr−1 − 1)2 1 = = + O . i 2r−1 2 3 r 2r (r − 1) 2r r4 i=1
Proof. With i as in the definition of f , the probability is r−c that i ≥ (p) + c for 0 ≤ c < r (considering the case E(p) as i = ∞), hence i = (p) + c with 1 probability r−1 r rc . We compute the probability of entering a cycle consisting of points p and q starting at p. Let j = (p) and k = (q), and let the steps from p to q and back be adding fj+c and fk+d , respectively. This implies that j + c ≡ k + d mod r and that the step from p to q involves a negation. From the definition of f it follows
74
J.W. Bos, T. Kleinjung, and A.K. Lenstra
(∼(p˜ + fk )) ∈ {i, k} (k, ..) p˜ =∼(p + fi ) (i, ..) p
(∼(˜q + fn ) ∈ {j, n} (n, ..) ∼(−p − fj+1 + fj ) = ˜q (j + 1,−)
(i + 1,+)
(j, ..) −p − fj+1 (i + 1,+) −p − fi+1 − fj+1
p + fi+1 (j, ..)
(j + 1,−)
p¯ =∼(p + fi+1 + fj ) (l, ..) (∼(p¯ + fl )) ∈ {j, l}
(i, ..) ∼(−p − fi+1 − fj+1 + fi ) = ¯q (m, ..) (∼ (¯q + fm )) ∈ {i, m}
Fig. 3. A 4-cycle when the 4-cycle reduction method is used
that (q) ≡ j + c mod r, thus d = 0 and by symmetry c = 0. Since j is given and k is determined by j, c and d, the probabilities must be summed over all possible c and d. The probability for a c, d pair is the product of the following probabilities: • • •
r−1 1 r rc 1 2 1 r−1
•
1 rd
for the first step being c; for the sign; for (∼(p + fj+c )) = k (we know already that (∼(p + fj+c )) ≡ j + c ≡ k mod r); for the second step being d (since (∼(q + fk+d )) ≡ k + d mod r).
This results in the probability
r−1 r−1 1 1 1 . 2r c=1 rc rd
d=1
We conclude that, even when the look-ahead technique is used, 2-cycles are still too likely to occur for relevant values of q and r. Some of the new 2-cycles are prevented by other short-cycle reduction methods, but the remaining ones must be dealt with using detection and escape methods. This is discussed below. 4-cycles. Unless the addition constants fi have been chosen poorly, 3-cycles do not occur as a direct result of the negation map, so that 4-cycles are the next type of short cycles to be considered. Excluding again that the fi have unlikely properties, a fruitless 4-cycle without proper sub-cycle is of the form (i,+)
(j,−)
(i,+)
(j,−)
p −→ p + fi −→ −p − fi − fj −→ −p − fj −→ p. The cycle may be entered at any of its four points. Hence, a fruitless 4-cycle starts from a random point with probability r−1 4r 3 . This is a lower bound for the probability of occurrence of 4-cycles when looking ahead to reduce 2-cycles.
On the Use of the Negation Map in the Pollard Rho Method
75
An extension of the 2-cycle reduction method looks ahead to the first two successors of a point, thereby reducing the frequency of 2-cycles and 4-cycles, while still being deterministic: ⎧ E(p) if j ∈ {(q), (∼(q + f(q) ))} or (q) = (∼(q + f(q) )) ⎪ ⎪ ⎨ where q =∼(p + fj ), for 0 ≤ j < r, g(p) = q =∼(p + f ) ⎪ i with i ≥ (p) minimal s.t. ⎪ ⎩ i mod r = (q) = (∼(q + f(q) )) = i mod r. Compared to f (p), the probability that E is called increases from ( 1r )r to at least ( 2r )r because (∼(q + f(q) )) ∈ {j mod r, (q)} with probability 2r for each j. This times slower than the standard one, because iteration function is at least r+4 r with probability 2r at least two additional group operations need to be carried 1 2 out, an effect that is slightly alleviated by a factor of ( r−1 r ) since the image of g q. The value ∼(q+f(q)) can be is a subset of g of cardinality approximately r−1 r stored for use in the next iteration. Usage of g reduces the occurrence of 4-cycles, and also prevents some of the 2-cycles newly introduced by the 2-cycle reduction method (such as the one depicted on the left in Fig. 2). But g introduces new types of 2-cycles and 4-cycles as well, both of which do indeed occur in practice. A newly introduced 2-cycle is shown in the right example in Fig. 2. There the 2 points ¯ p and ¯ q are ∈ Gi−1 ∪ Gi . This 2-cycle occurs with probability 2(r−2) (r−1)r 4 , which is therefore a lower bound for the probability of 2-cycles when using the 4-cycle reduction method. Fig. 3 depicts an example of a newly introduced 4cycle: the points reached via dotted lines belong to a partition different from their predecessors. The probability that such a 4-cycle starts from a random 4 (r−1) point is at least 4(r−2) . r 11 We have not been able to design or to find in the literature short-cycle reduction methods that do not introduce other (lower probability) short cycles. We therefore turn our attention to cycle detection and escape methods. 3.2
Cycle Detection and Escape
Recurring cycles. The cycle detection and escape method from [9] described in Section 2.3, does not prevent recurrence to the same cycle. When using f(p)+c to escape (we fixed c = 4 as it worked as well as any other choice = 1), Fig. 4 depicts how the (wavy) escape from the (solid) 4-cycle recurs to the 4-cycle via one of the dotted possibilities. The probability of recurrence depends on the escape method and on which point in the cycle the walk recurs to. With f(p)+c 1 as escape, immediate recurrence to the escape point happens with probability 2r 1 when no cycle reduction is used, recurrence happens with probability at least 2r2 2
with 2-cycle reduction, and with probability at least (r−2) with 4-cycle and thus r4 2-cycle reduction. Similar recurrences occur, with lower probabilities, when f or f(p) are used to escape. Lemma 2. Lower bounds for the probabilities to enter 2-cycles or 4-cycles or to recur to cycles for three different cycle escape methods are listed in Table 2
76
J.W. Bos, T. Kleinjung, and A.K. Lenstra
−p − fi − fj (i, +)
(j, −)
−p − fj
p + fi (k, −)
p
(i, +)
(k, +) (j, −)
−p − fk − fj
(k, +)
−p − fi − fk
(i, −)
(j, −)
p + fk
Fig. 4. Escaping from a fruitless 4-cycle, and recurring to it (i = j = k = i)
if no cycle reduction, or 2-cycle reduction (f ), or 4-cycle reduction (g) is used, along with a lower bound for the slowdown factor caused by f or g. Proof. The proofs for many entries of Table 2 were given earlier. We prove the entries in rows four and five. Let p be the escape point and let q be the point it escapes to. Using f or f(p) one can recur to the escape point p by entering another cycle at q and escaping from it at q again. This new cycle could be a 2-cycle. For this to happen the first escape step to q has to involve a negation (probability 12 ), a 2-cycle has to be entered at q (probabilities in first row, but see below), the escape point of this 2-cycle has to be q (probability 12 ), and, in the case of fi , the partition that q belongs to has to be the same as the one p belongs to (probability 1r ). In the case of 4-cycle reduction the probability to enter a 2-cycle at q is slightly lower since we do not have the information that (∼(q + f(q) )) = (q); a calculation analogous to the one done at the end of Section 3.1 produces the values listed in the table. 6-cycles. With proper fi and no sub-cycle, a common 6-cycle is of the form (i,+)
(j,−)
(k,+)
(i,+)
(j,−)
(k,+)
p −→ p+fi −→ −p−fi −fj −→ −p−fi −fj +fk −→ −p−fj +fk −→ p−fk −→ p (i = j = k = i) where with appropriate sign changes steps four and five may be swapped. It may be entered at any of its six points and occurs, when using 4-cycle reduction, with probability 4r13 + O( r14 ). A lower bound to recur to it follows by multiplying this probability with the recurring probabilities from Table 2.
On the Use of the Negation Map in the Pollard Rho Method
77
Table 2. Summary of effect of cycle reduction, detection, and escape methods. With the exception of the two bold entries, all figures are lower bounds. Probability to enter
Cycle reduction method:
none
2-cycle 4-cycle
⎧ ⎪ ⎨ f(p)+c Probability to recur to escape point using f ⎪ ⎩ f(p) Slowdown factor of iteration function
3.3
2-cycle
4-cycle
1 2r r−1 4r3
1 2r 3 r−1 4r 3
2(r−2)2 (r−1)r 4 4(r−2)4 (r−1) r 11
1 2r 1 8r 1 8r 2
1 2r 2 1 8r 3 1 8r 4
(r−2)2 r4 (r−2)2 2r 5 (r−2)2 2r 6
n/a
r+1 r
r+4 r
Alternative Approaches
The purpose √ of using the negation map is to obtain a speedup, hopefully by a factor of 2. From Fig. 1 it follows that large r-values cannot be used. From Table 2 it follows that for small r-values and relevant q-values fruitless cycles are likely to occur and recur. Medium r-values look the most promising, but are not compatible with all environments. Since fruitless cycle occurrence and recurrence cannot be rooted out, alternative methods are needed if we want to make the negation map useful. In this section several possibilities are offered. Heuristic. A cycle with at least one doubling is most likely not fruitless. Proof. Let p = ug + vh be a point on the cycle. The subsequent points are obtained by adding one of the fi or by doubling, and negating if needed, thus are up to sign linear combinations of the fi and a power-of-two multiple of p. If c ≥ 1 is the number of doublings in the cycle, we get a relation of the form p = ±2c p +
r−1
ci fi = ±2c p +
i=0
(1 ∓ 2c )u −
r−1 i=0
r−1 i=0
ci u i
ci u i g +
r−1
g+
ci vi h
and thus
i=0
(1 ∓ 2c )v −
r−1
ci vi
h = 0,
i=0
r−1 where ci ∈ Z. Since 1 ∓ 2c = 0, the expression (1 ∓ 2c )u − i=0 ci ui is most likely not divisible by the group order. This also holds if {fi : 0 ≤ i < r} is enlarged with f or with {fi : 0 ≤ i < r}. This concludes our heuristic argument. Cycle reduction by doubling. The regular structure required for cycles is caused by repeated addition and subtraction using the same set of constants. This structure would be broken effectively by using an occasional doubling, i.e., a mixed walk. If such walks are used, the heuristics suggest that cycles occur
78
J.W. Bos, T. Kleinjung, and A.K. Lenstra
only between two doublings. If the doubling frequency is sufficiently high, only short cycles would have to be dealt with. As borne out by expressions (1) and (2) when using the idealized values pi = 1 s r+s for 0 ≤ i < r and pD = r+s for r > 0, and as supported by the experiments reported in Table 1, an r + s-mixed walk with s > 1 always displays noticeably less random behavior than a well-partitioned r -adding walk for any r > r. Nevertheless, using properly tuned r + s-mixed walks may be a way to address the cycle problem while avoiding impractically large r-values. However, r + s-mixed walks have disadvantages caused by the underlying arithmetic. Given the relative speeds of addition and doubling, an r + s-mixed times slower than an r-adding walk. In a SIMD environment walk is r+7s/6 r+s where many walks are processed simultaneously, per step a fraction of about r r+s of the walks will do an addition, whereas the others do a doubling. If the addition and doubling code differ, as is the case for the affine Weierstrass representation, the two types of steps cannot be executed simultaneously. Thus, in such environments, to avoid a slowdown by a factor of more than 2 one needs to swap walks to make all parallel step-operations identical (at non-negligible overhead), or one has to settle for a suboptimal affine point representation that allows identical code. SIMD-application of the negation map and the possibility of another point representation are subjects for further study. Doubling based cycle reduction and escape. Taking into account that doubling should not be used too frequently, usage could be limited to cycle reduction or escape. This would not solve the SIMD-issue, but the relative inefficiency and non-randomness would be addressed. If doublings are used to escape from fruitless cycles, they would not recur, as that would contradict the heuristics. Cycle reduction using doubling replaces f (p) and g(p) by f¯(p) and g¯(p), respectively, where ∼(p + f(p) ) if (p) = (∼(p + f(p) )), ¯ f (p) = ∼(2p) otherwise, g¯(p) =
q =∼(p + f(p) ) if (q) = (p) = (∼(q + f(q) )) = (q), ∼(2p) otherwise.
It follows from the heuristics that these functions avoid recurring fruitless cycles. Alternative cycle detection. Because shorter cycles are more frequent, a potentially interesting modification of the cycle detection method from [9] (described at the end of Section 2.3) would be to occasionally compare a point to its kth successor, where k is the least common multiple of all even short cycle lengths that one wants to catch. Detecting, for instance, cycles up to length 1 th comparison per step. This can be done in several steps, 12 requires only 120 recording every 12th point to catch 4- and 6-cycles, recording every 10th of these recorded points to catch 8- and 10-cycles, etc. It can be combined with the regular method with large α and β to catch longer cycles infrequently. However, if a cycle has been detected the k points need to be recorded as before, so an escape point can be chosen deterministically. This argues against
On the Use of the Negation Map in the Pollard Rho Method
79
using large k. It also suggests that an improvement can be expected only if cycles occur with low probability, and therefore that the improvement will be marginal at best (cf. α and β choices in Section 4). For this reason we did not conduct extensive experiments with this method.
4
Comparison
We implemented and compared on a traditional non-SIMD platform all previously published and newly proposed methods to deal with fruitless cycles when using the negation map. Here we report on our findings. It quickly turned out that the cycle detection methods from [9] when combined with doubling based cycle reduction and escape, are considerably more efficient than r+s-mixed walks with their on average slower steps and less random behavior. Mixed walks are therefore not further discussed. Experiments with the alternative cycle detection method were quickly abandoned as well. For each combination of iteration function, escape method, and r-value a search was conducted to determine the α and β to be used for the cycle detection method from [9]. Using a heuristic argument that for β = 2k with k much smaller than r, cycles of length ≥ β occur with probability on the order of (k−1)! , values (2r)k for k that make this probability low enough resulted in good initial values for the search for close to optimal α and β. To give some examples, for “f , e,” as explained in Table 3 we used α = 31 and β = 20 for r = 16, α = 3264 and β = 12 for r = 128, and α = 52 418 and β = 10 for r = 256. For “f¯, ¯e” and the same r-values we used the same β-values but replaced the α-values by 1 618, 838 848, and 53 687 081, respectively. Each of the benchmarks presented in Table 3 was run on a single core of an AMD Phenom 2.2GHz 4-core processor, with each of the four cores processing a different combination. A 10-bit distinguishing property was used to get a significant amount of data in a reasonable amount of time. This somewhat affects the performance, but not the cycle behavior as walks continue after hitting a distinguished point. The figures in millions as given in the table are thus an underestimate for the actual per-core yield in units when a more realistic 30-bit distinguishing property would be used (since 230 /210 = 220 ≈ 106 ). In order to be able to compare the long term yield figures, the expected number of steps must be taken into account using expressions 1 and 2. As a 1 2 result, the yields are corrected by a factor of ( r−1 r ) for the iteration functions 1 2 that do not use the negation map, and by a factor of ( 2r−1 r ) for the others, with 1 r an extra factor of ( r−1 ) 2 for g and g¯. After this correction, the best iteration function without the negation map is the one with r = 64. Comparing that one with each iteration function that uses the negation map, thus boosting the 63 12 63 12 or C = (( 2r−1 latter’s yield ratio by a factor of C = (( 2r−1 r )/( 64 )) r−1 )/( 64 )) for g and g¯, leads to the long term speedup figure given in Table 3. Note that the correction factor√C depends on the iteration function, and is close to and for some r larger than 2.
80
J.W. Bos, T. Kleinjung, and A.K. Lenstra
Table 3. For the (iteration function, escape method, r-value) combinations specified, the non-italics entries list the long term yield (millions of distinguished points, found during the second half hour) and the long term speedup over the best r-value (r = 64) without the negation map, taking into account the correction factor C as explained in the text. Cycle detection and subsequent escape by adding f(p)+4 , f , f(p) and by doubling is indicated by “e,” “e ,” “e ” and by “¯e,” respectively. The iteration functions f (2-cycle reduction), g (4-cycle and 2-cycle reduction), f¯ (2-cycle reduction using doubling), and g¯ (4-cycle and 2-cycle reduction using doubling) are as in sections 2.3, 3.1 and 3.3. The yields are for 256 parallel walks (sharing the inversion) for a 131-bit ECDLP with a 131-bit prime order group. The yields during the first half hour are almost consistently higher, considerably so for poorly performing combinations. They are not meaningful and are thus not listed. The italics entries are A above D, followed 9 −A) , as explained in the text. by the maximal achievable speedup factor of C(10 109 +D/6 †: This applies to “no reduction, no escape,” “just f ,” “just f¯,” “just e,” and “just e .” r = 16
r = 32
Without negation map 7.29: 0.98 7.28: 0.99 With negation map 0.00: 0.00 0.00: 0.00 † 0.00: 0.00 0.00: 0.00 just g 0.00: 0.00 0.00: 0.00 just g ¯ 0.00: 0.00 0.00: 0.00 just e 3.34: 0.64 4.89: 0.95 just ¯ e 0.00: 0.00 0.00: 0.00 f, e 9 .4e8 6 .6e8 0 .0e0 }0 .48 0 .0e0 }0 .08 0.00: 0.00 3.24: 0.63 f , e 8 .0e7 3 .9e8 0 .0e0 }0 .86 0 .0e0 }1 .30 0.00: 0.00 5.34: 1.04 f , e 6 .0e7 1 .3e8 0 .0e0 }1 .22 0 .0e0 }1 .33 3.71: 0.72 6.36: 1.24 f, ¯ e 9 .2e7 6 .8e7 9 .9e5 }1 .27 2 .8e5 }1 .32 0.00: 0.00 0.01: 0.00 g, e 8 .7e8 3 .7e8 0 .0e0 }0 .19 0 .0e0 }0 .91 0.00: 0.00 0.01: 0.00 g, e 7 .8e8 3 .0e8 0 .0e0 }1 .00 0 .0e0 }0 .32 0.00: 0.00 1.09: 0.21 g, e 7 .6e8 1 .2e8 0 .0e0 }1 .27 0 .0e0 }0 .34 0.76: 0.15 5.91: 1.17 g, ¯ e 1 .7e8 3 .3e8 1 .6e5 }0 .97 6 .0e4 }1 .19 0.00: 0.00 0.00: 0.00 f¯, e 8 .7e8 4 .3e8 2 .4e6 }0 .18 1 .7e7 }0 .80 0.01: 0.0 4.24: 0.82 f¯, e 6 .8e7 2 .6e8 4 .3e7 }1 .03 2 .9e7 }1 .31 1.34: 0.26 5.80: 1.13 f¯, e 8 .9e7 5 .3e7 5 .2e7 }1 .27 2 .9e7 }1 .33 5.58: 1.06 6.14: 1.18 f¯, ¯ e 6 .1e7 3 .7e7 4 .2e7 }1 .31 3 .0e7 }1 .36 2.56: 0.51 5.80: 1.15 g ¯, e 1 .4e8 7 .9e7 9 .9e7 }1 .23 5 .6e7 }1 .31 4.74: 0.94 5.88: 1.16 g ¯, e 7 .8e7 1 .2e8 1 .0e8 }1 .25 5 .6e7 }1 .31 4.72: 0.94 5.80: 1.15 g ¯, e 7 .7e7 1 .2e8 1 .0e8 }1 .25 5 .6e7 }1 .31 4.83: 0.96 5.87: 1.16 g ¯, ¯ e 7 .9e7 1 .2e8 1 .0e8 }1 .25 5 .6e7 }1 .31
r = 64
r = 128
r = 256
r = 512
7.27: 1.00
7.19: 0.99
6.97: 0.96
6.78: 0.94
0.00: 0.00 0.00: 0.00 0.00: 0.00 0.00: 0.00 5.85: 1.14 1.52: 0.30 1 .0e8 0 .0e0 }1 .28 6.04: 1.18 4 .6e7 0 .0e0 }1 .35 6.21: 1.21 4 .2e7 0 .0e0 }1 .36 6.50: 1.27 4 .2e7 6 .5e4 }1 .36 4.89: 0.96 6 .6e7 0 .0e0 }1 .34 5.32: 1.05 6 .0e7 0 .0e0 }1 .35 5.37: 1.13 6 .0e7 0 .0e0 }1 .35 6.02: 1.18 8 .1e7 8 .1e3 }1 .32 2.70: 0.53 5 .4e7 1 .5e7 }1 .34 6.32: 1.23 3 .9e7 1 .5e7 }1 .36 6.23: 1.22 3 .9e7 1 .5e7 }1 .36 6.34: 1.23 1 .8e7 1 .5e7 }1 .39 6.02: 1.18 5 .1e7 2 .9e7 }1 .35 6.14: 1.21 5 .3e7 2 .9e7 }1 .35 6.08: 1.20 5 .3e7 2 .9e7 }1 .35 6.09: 1.20 5 .2e7 2 .9e7 }1 .35
0.00: 0.00 0.00: 0.00 0.75: 0.15 0.61: 0.12 6.10: 1.19 5.93: 1.16 3 .6e7 0 .0e0 }1 .37 6.41: 1.25 3 .3e7 0 .0e0 }1 .38 6.30: 1.23 3 .3e7 0 .0e0 }1 .38 6.57: 1.29 3 .3e7 1 .5e4 }1 .38 6.22: 1.22 4 .2e7 0 .0e0 }1 .37 6.26: 1.23 4 .1e7 0 .0e0 }1 .37 6.08: 1.20 4 .2e7 0 .0e0 }1 .37 6.25: 1.23 5 .4e7 1 .0e3 }1 .35 5.96: 1.16 1 .1e7 7 .7e6 }1 .41 6.43: 1.26 3 .2e7 7 .6e6 }1 .38 6.21: 1.22 3 .6e7 7 .5e6 }1 .37 6.42: 1.25 1 .1e7 7 .7e6 }1 .41 6.09: 1.20 4 .1e7 1 .5e7 }1 .37 6.28: 1.23 3 .9e7 1 .5e7 }1 .37 6.05: 1.19 3 .8e7 1 .5e7 }1 .37 6.16: 1.21 4 .0e7 1 .5e7 }1 .37
0.00: 0.00 0.04: 0.01 4.90: 0.96 4.94: 0.97 6.28: 1.23 6.47: 1.27 2 .9e7 0 .0e0 }1 .38 6.29: 1.23 2 .9e7 0 .0e0 }1 .38 6.20: 1.21 2 .9e7 0 .0e0 }1 .38 6.47: 1.27 2 .9e7 3 .8e3 }1 .38 6.23: 1.22 3 .3e7 0 .0e0 }1 .38 6.25: 1.23 3 .0e7 0 .0e0 }1 .38 6.06: 1.19 3 .5e7 0 .0e0 }1 .38 6.13: 1.20 4 .0e7 1 .2e2 }1 .37 6.34: 1.24 1 .0e7 3 .9e6 }1 .41 6.33: 1.24 2 .8e7 3 .8e6 }1 .38 6.15: 1.20 2 .8e7 3 .8e6 }1 .38 6.27: 1.23 1 .0e7 3 .9e6 }1 .41 6.19: 1.21 2 .6e7 7 .6e6 }1 .39 6.05: 1.19 2 .6e7 7 .6e6 }1 .39 5.91: 1.16 1 .8e7 7 .6e6 }1 .40 6.09: 1.20 2 .6e7 7 .6e6 }1 .39
0.00: 0.00 3.59: 0.70 5.90: 1.16 5.73: 1.12 6.18: 1.21 6.36: 1.25 2 .5e7 0 .0e0 }1 .39 6.21: 1.22 2 .6e7 0 .0e0 }1 .39 5.99: 1.17 2 .7e7 0 .0e0 }1 .39 6.30: 1.25 2 .7e7 9 .7e2 }1 .39 6.05: 1.19 1 .3e7 0 .0e0 }1 .41 6.11: 1.20 5 .5e7 0 .0e0 }1 .35 5.86: 1.15 4 .3e7 0 .0e0 }1 .37 6.00: 1.18 2 .7e7 9 .0e0 }1 .39 6.20: 1.21 1 .4e7 1 .9e6 }1 .40 6.20: 1.22 2 .7e7 1 .9e6 }1 .39 6.00: 1.18 2 .6e7 1 .9e6 }1 .39 6.07: 1.19 1 .4e7 1 .9e6 }1 .40 5.74: 1.13 7 .7e6 3 .9e6 }1 .41 5.80: 1.14 7 .7e6 3 .9e6 }1 .41 5.67: 1.11 7 .7e6 3 .9e6 }1 .41 5.70: 1.12 7 .7e6 3 .9e6 }1 .41
On the Use of the Negation Map in the Pollard Rho Method
81
Non-doubling 2-cycle reduction (f ) with doubling-based cycle escape (¯e) and r = 128 performed best, with an overall speedup by a factor of 1.29: although fewer distinguished points are found than for the best case without the negation map (r = 64), there is a considerable overall gain because fewer distinguished points (by a factor of C, for the relevant C) should suffice. For r = 16 most iteration functions with the negation map perform poorly. √ We measured to what extent our failure to achieve a speedup by a factor of 2 can be blamed on cycle detection and escape and other overheads, and which part is due to the higher average cost of the iteration function. For most combinations in Table 3 we counted the number S of useful steps performed when doing 109 group operations, while keeping track of the number D of doublings among them. Here a step is useful if it is not taken as part of a fruitless cycle, so all D doublings are useful. Without the negation map, S would be 109 and D = 0; this is the basis for the comparison. With the negation map, A = 109 − S is counted as the number of additional additions due to cycle reductions or fruitless cycles. , so that it The inherent slowdown of that iteration function is then 1 + A+D/6 S 9
−A) CS can achieve a speedup by a factor of at most S+A+D/6 = C(10 109 +D/6 , with C as defined above. Based on Table 3 and Fig. 1, we√conclude that our failure to better approach the optimal speedup by a factor of 2 is due to an onset of cache effects combined with various overheads. The italics figures from Table 3 make us believe that improvements may be obtained when using better implementations.
Previous results. The only publication that we know that presents practical data about Pollard’s rho method used with the negation map is [8]. Only relatively small ECDLPs were solved (42- and 43-bit prime fields) and small r-values were avoided. The adverse cycle behavior that we witnessed can therefore not be expected and we doubt if the results reported are significant for the sizes that we consider. Only mixed walks were used, and an overall speedup by a factor of about 1.35 was reported. Cycle escaping was done by jumping to the sum of all points in a cycle, which cannot be expected to work in general because the sum may depend just on the addition constants.
5
Conclusion
With judicious application of doubling, usage of the negation map to solve ECDLPs over prime fields using Pollard’s rho method can indeed be recommended. In the best of circumstances that √ we have been able to create, however, the speedup falls short of the hoped for 2, but is with 1.29 still considerable. This conclusion does not apply to SIMD-environments where occasional doublings cause considerable delays. Alternative point representations need to be considered to assess the usefulness of the negation map for SIMD platforms, in particular because such platforms are becoming popular again. Acknowledgements. This work was supported by the Swiss National Science Foundation under grant numbers 200021-119776 and 206021-117409 and
82
J.W. Bos, T. Kleinjung, and A.K. Lenstra
by EPFL DIT. We gratefully acknowledge useful suggestions by Marcelo E. Kaihara and very insightful comments by the ANTS reviewers.
References 1. Avanzi, R.M., Cohen, H., Doche, C., Frey, G., Lange, T., Nguyen, K., Vercauteren, F.: Handbook of Elliptic and Hyperelliptic Curve Cryptography. Chapman & Hall/CRC (2006) 2. Bailey, D.V., et al.: Breaking ECC2K-130. In: Cryptology ePrint Archive, Report 2009/541 (2009), http://eprint.iacr.org/ 3. Bos, J.W., Kaihara, M.E., Montgomery, P.L.: Pollard rho on the PlayStation 3. In: Workshop record of SHARCS 2009, pp. 35–50 (2009), http://www.hyperelliptic.org/tanja/SHARCS/record2.pdf 4. Brent, R.P., Pollard, J.M.: Factorization of the eighth Fermat number. Math. Comp. 36(154), 627–630 (1981) 5. Certicom. Certicom ECC Challenge (1997), http://www.certicom.com/images/pdfs/cert_ecc_challenge.pdf 6. Certicom. Press release: Certicom announces elliptic curve cryptosystem (ECC) challenge winner (2002), http://www.certicom.com/index.php/2002-press-releases/ 38-2002-press-releases/340-notre-dame-mathematician-solveseccp-109-encryption-key-problem-issued-in-1997 7. Duursma, I.M., Gaudry, P., Morain, F.: Speeding up the discrete log computation on curves with automorphisms. In: Lam, K.-Y., Okamoto, E., Xing, C. (eds.) ASIACRYPT 1999. LNCS, vol. 1716, pp. 103–121. Springer, Heidelberg (1999) 8. Escott, A.E., Sager, J.C., Selkirk, A.P.L., Tsapakidis, D.: Attacking elliptic curve cryptosystems using the parallel Pollard rho method. CryptoBytes Technical Newsletter 4(2), 15–19 (1999), ftp.rsasecurity.com/pub/cryptobytes/crypto4n2.pdf 9. Gallant, R.P., Lambert, R.J., Vanstone, S.A.: Improving the parallelized Pollard lambda search on anomalous binary curves. Math. Comp. 69(232), 1699–1705 (2000) 10. Harley, R.: Elliptic curve discrete logarithms project, http://pauillac.inria.fr/~harley/ 11. Koblitz, N.: Elliptic curve cryptosystems. Math. Comp. 48, 203–209 (1987) 12. Koblitz, N.: CM-curves with good cryptographic properties. In: Feigenbaum, J. (ed.) CRYPTO 1991. LNCS, vol. 576, pp. 279–287. Springer, Heidelberg (1992) 13. Miller, V.S.: Use of elliptic curves in cryptography. In: Williams, H.C. (ed.) CRYPTO 1985. LNCS, vol. 218, pp. 417–426. Springer, Heidelberg (1986) 14. Montgomery, P.L.: Speeding the Pollard and elliptic curve methods of factorization. Math. Comp. 48, 243–264 (1987) 15. Pollard, J.M.: Monte Carlo methods for index computation (mod p). Math. Comp. 32, 918–924 (1978) 16. Teske, E.: On random walks for Pollard’s rho method. Math. Comp. 70(234), 809– 825 (2001) 17. van Oorschot, P.C., Wiener, M.J.: Parallel collision search with cryptanalytic applications. Journal of Cryptology 12(1), 1–28 (1999) 18. Wiener, M.J., Zuccherato, R.J.: Faster attacks on elliptic curve cryptosystems. In: Tavares, S., Meijer, H. (eds.) SAC 1998. LNCS, vol. 1556, pp. 190–200. Springer, Heidelberg (1999)
An O(M (n) log n) Algorithm for the Jacobi Symbol Richard P. Brent1 and Paul Zimmermann2 1 2
Australian National University, Canberra, Australia INRIA Nancy - Grand Est, Villers-l`es-Nancy, France
Abstract. The best known algorithm to compute the Jacobi symbol of two n-bit integers runs in time O(M (n) log n), using Sch¨ onhage’s fast continued fraction algorithm combined with an identity due to Gauss. We give a different O(M (n) log n) algorithm based on the binary recursive gcd algorithm of Stehl´e and Zimmermann. Our implementation — which to our knowledge is the first to run in time O(M (n) log n) — is faster than GMP’s quadratic implementation for inputs larger than about 10000 decimal digits.
1
Introduction
We want to compute the Jacobi symbol1 (b|a) for n-bit integers a and b, where a is odd positive. We give three algorithms based on the 2-adic gcd from Stehl´e and Zimmermann [13]. First we give an algorithm whose worst-case time bound is 3 ); we call this the cubic algorithm although this is pessimistic O(M (n)n2 ) = O(n since the algorithm is quadratic on average as shown in [5], and probably also in the worst case. We then show how to reduce the worst-case to O(M (n)n) = 2 ) by combining sequences of “ugly” iterations (defined in Section 1.1) into O(n one “harmless” iteration. Finally, we obtain an algorithm with worst-case time O(M (n) log n). This is, up to a constant factor, the same as the time bound for the best known algorithm, apparently never published in full, but sketched in Bach [1] and in more detail in Bach and Shallit [2] (with credit to Bachmann [3]). The latter algorithm makes use of the Knuth-Sch¨ onhage fast continued fraction algorithm [9] and an identity of Gauss [6]. Although this algorithm has been attributed to Sch¨ onhage, Sch¨ onhage himself gives a different O(M (n) log n) algorithm [10,15] which does not depend on the identity of Gauss. The algorithm is mentioned in Sch¨ onhage’s book [11, §7.2.3], but no details are given there. With our algorithm it is not necessary to compute the full continued fraction or to use the identity of Gauss for the Jacobi symbol. Thus, it provides an alternative that may be easier to implement. 1
Notation: we write the Jacobi symbol (b|a), since this is easier to typeset and as less ambiguous than the more usual ab . Also, M (n) is the time to multiply n-bit (n)) means O(f (n)(log f (n))c ) for some constant c ≥ 0. numbers, and O(f
G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 83–95, 2010. c Springer-Verlag Berlin Heidelberg 2010
84
R.P. Brent and P. Zimmermann
It is possible to modify some of the other fast GCD algorithms considered by M¨ oller [8] to compute the Jacobi symbol, but we do not consider such possibilities here. At best they give a small constant factor speedup over our algorithm. We recall the main identities satisfied by the Jacobi symbol: (bc|a) = (b|a)(c|a); 2 (2|a) = (−1)(a −1)/8 ; (b|a) = (−1)(a−1)(b−1)/4 (a|b) for a, b odd; and (b|a) = 0 if (a, b) = 1. Note that all our algorithms compute (b|a) with b even positive and a odd positive. For the more general case where b is any integer, we can reduce to b even and positive using (b|a) = (−1)(a−1)/2 (−b|a) if b is negative, and (b|a) = (b+a|a) if b is odd. We first describe a cubic algorithm to compute the Jacobi symbol. The quadratic algorithm in Section 2 is based on this cubic algorithm, and the subquadratic algorithm in Section 3 uses the same ideas as the quadratic algorithm but with an asymptotically fast recursive implementation. For a ∈ Z, the notation ν(a) denotes the 2-adic valuation ν2 (a) of a, that is the maximum k such that 2k |a, or +∞ if a = 0. 1.1
Binary Division with Positive Quotient
Throughout the paper we use the binary division with positive quotient defined by Algorithm 1.1. Compared to the “centered division” of [13], it returns a quotient in [1, 2j+1 − 1] instead of in [1 − 2j , 2j − 1]. Note that the quotient q is always odd. Algorithm 1.1. BinaryDividePos Input: a, b ∈ N with ν(a) = 0 < ν(b) = j Output: q and r = a + qb/2j such that 0 < q < 2j+1 , ν(b) < ν(r) q is odd and positive 1: q ← −a/(b/2j ) mod 2j+1 2: return q, r = a + qb/2j .
With this binary division, we define Algorithm CubicBinaryJacobi, where the fact that the quotient q is positive ensures that all a, b terms computed remain positive, and a remains odd, thus (b|a) remains well-defined.2 Theorem 1. Algorithm CubicBinaryJacobi is correct (assuming it terminates). Proof. We prove that the following invariant holds during the algorithm, if a0 , b0 are the initial values of a, b: (b0 |a0 ) = (−1)s (b|a). This is true before we enter the while-loop, since s = 0, a = a0 , and b = b0 . For each step in the while loop, we divide b by 2j , swap a and b = b/2j , replace a 2
M¨ oller says in [8]: “if one tries to use positive quotients 0 < q < 2k+1 , the [binary gcd] algorithm no longer terminates”. However, with a modified stopping criterion as in Algorithm CubicBinaryJacobi, the algorithm terminates (we prove this below).
An O(M (n) log n) Algorithm for the Jacobi Symbol
85
Algorithm 1.2. CubicBinaryJacobi Input: a, b ∈ N with ν(a) = 0 < ν(b) Output: Jacobi symbol (b|a) 1: s ← 0, j ← ν(b) 2: while 2j a = b do 3: b ← b/2j 4: (q, r) ← BinaryDividePos(a, b) 2 5: s ← (s + j(a2 − 1)/8 + (a − 1)(b − 1)/4 + j(b − 1)/8) mod 2 j 6: (a, b) ← (b , r/2 ), j ← ν(b) 7: if a = 1 then return (−1)s else return 0
by r = a + qb , and divide r by 2j . The Jacobi symbol is modified by a factor 2 (−1)j(a −1)/8 for the division of b by 2j , by a factor (−1)(a−1)(b −1)/4 for the 2 interchange of a and b , and by a factor (−1)j(b −1)/8 for the division of r by 2j . At the end of the loop, we have gcd(a0 , b0 ) = a; if a = 1, since (b|1) = 1, we have (b0 |a0 ) = (−1)s , otherwise (b0 |a0 ) = 0. Lemma 1. The quantity a + 2b is non-increasing in Algorithm CubicBinaryJacobi. Proof. At each iteration of the “while” loop, a becomes b/2j , and b becomes (a + qb/2j )/2j . In matrix notation a 0 1/2j a ← . (1) b 1/2j q/22j b Therefore a + 2b becomes a + qb/2j b 2a b +2 = j + (1 + 2q/2j ) j . j j 2 2 2 2
(2)
Since j ≥ 1, the first term is bounded by a. In the second term, q ≤ 2j+1 − 1, thus the second term is bounded by (5/2j − 2/22j )b, which is bounded by 9b/8 for j ≥ 2, and equals 2b for j = 1. If j ≥ 2, then a + 2b is multiplied by a factor at most 9/16. If j = q = 1 then a + 2b decreases, but by a factor which could be arbitrarily close to 1. The only case where a + 2b does not decrease is when j = 1 and q = 3; in this case a + 2b is unchanged. This motivates us to define three classes of iterations: good, bad, and ugly. Let us say that we have a good iteration when j ≥ 2, a bad iteration when j = q = 1, and an ugly iteration when j = 1 and q = 3. Since q is odd and 1 ≤ q ≤ 2j+1 − 1, this covers all possibilities. For a bad iteration, (a, b) becomes (b/2, a/2 + b/4), and for an ugly iteration, (a, b) becomes (b/2, a/2 + 3b/4). We denote the matrices corresponding to good, bad and ugly iterations by G, B and U respectively. Thus
86
R.P. Brent and P. Zimmermann
G = Gj,q =
0 1/2j 1/2j q/4j
, B=
0 1/2 1/2 1/4
, U=
0 1/2 1/2 3/4
.
The effect of m successive ugly iterations is easily seen to be given by the matrix 1 1 + 4(−1/4)m 2 − 2(−1/4)m m U = . (3) 5 2 − 2(−1/4)m 4 + (−1/4)m Assume we start from (a, b) = (a0 , b0 ), and after m > 0 successive ugly iterations we get values (am , bm ). Then, from Equation (3), 5am = (a + 2b) + 2(2a − b)(−1/4)m , m
5bm = 2(a + 2b) − (2a − b)(−1/4) .
(4) (5)
We can not have 2a0 = b0 or the algorithm would have terminated. However, am must be an integer. This gives an upper bound on m. For a0 , b0 of n bits, the number of successive ugly iterations is bounded by n/2 + O(1) (a precise statement is made in Lemma 2). If there were no bad iterations, this would prove that for n-bit inputs the number of iterations is O(n2 ), since each sequence of ugly iterations would be followed by at least one good iteration. Bad iterations can be handled by a more complicated argument which we omit, since they will be considered in detail in §2 when we discuss the complexity of the quadratic algorithm (see the proof of Theorem 2). Since the number of iterations is O(n2 ) from Theorem 2, and each iteration costs time O(M (n)), the overall time for Algorithm CubicBinaryJacobi is 3 ). Note that this worst-case bound is almost certainly too O(n2 M (n)) = O(n pessimistic (see §4).
2
A Provably Quadratic Algorithm
Suppose we have a sequence of m > 0 ugly iterations. It is possible to combine the m ugly iterations into one harmless iteration which is not much more expensive than a normal (good or bad) iteration. Also, it is possible to predict the maximal such m in advance. Using this trick, we reduce the number of iterations (good, 2 ). Without loss bad and harmless) to O(n) and their cost to O(M (n)n) = O(n of generality, suppose that we start from (a0 , b0 ) = (a, b). Lemma 2. If μ = ν(a−b/2), then we have exactly μ/2 ugly iterations starting from (a, b), followed by a good iteration if μ is even, and by a bad iteration if μ is odd. Proof. We prove the lemma by induction on μ. If μ = 0, a − b/2 is odd, but a is odd, so b/2 is even, which yields j ≥ 2 in BinaryDividePos, thus a, b yield a good iteration. If μ = 1, a − b/2 is even, which implies that b/2 is odd, thus we have j = 1. If we had q = 3 in BinaryDividePos, this would mean that
An O(M (n) log n) Algorithm for the Jacobi Symbol
87
a + 3(b/2) = 0 mod 4, or equivalently a − b/2 = 0 mod 4, which is incompatible with μ = 1. Thus we have q = 1, and a bad iteration. Now assume μ ≥ 2. The first iteration is ugly since 4 divides a − b/2, which implies that b/2 is odd. Thus j = 1, and a − b/2 = 0 mod 4 implies that q = 3. After one ugly iteration (a, b) becomes (b/2, a/2 + 3b/4), thus a − b/2 becomes −(a − b/2)/4, and the 2-valuation of a − b/2 decreases by 2. From the above, we see that, for a sequence of m ugly iterations, a0 , a1 , . . . , am satisfy the three-term recurrence 4ai+1 − 3ai − ai−1 = 0 for 0 < i < m, and similarly for b0 , b1 , . . . , bm . It follows that ai = a mod 4, and similarly bi = b mod 4, for 1 ≤ i < m. We can modify Algorithm CubicBinaryJacobi to consolidate m consecutive ugly iterations into one harmless iteration, using the expressions (4)–(5) for am and bm (we give an optimised evaluation below). It remains to modify step 5 of CubicBinaryJacobi to take account of the m updates to s. Since j = 1 for each ugly iteration, we have to increment s by an amount 2 a2i − 1 bi − 1 ai − 1 bi − 1 + + mod 2, δ= 8 8 2 2 0≤i<m
where we write bi for bi /2. However, ai+1 = bi for 0 ≤ i < m, so the terms involving division by 8 “collapse” mod 2, leaving just the first and last terms. The terms involving two divisions by 2 are all equal to (a − 1)/2 · (b − 1)/2 mod 2, using the observation that ai mod 4 is constant for 0 ≤ i < m. Thus 2 a0 − 1 a2m − 1 a0 − 1 a1 − 1 + +m δ= mod 2. 8 8 2 2 One further simplification is possible. Since a0 = a1 mod 4, and a0 is odd, we can replace a1 by a0 in the last term, and use the fact that x2 = x mod 2 to obtain 2 a0 − 1 a2m − 1 a0 − 1 + +m δ= mod 2. (6) 8 8 2 We can economise the computation of am and bm from (4)–(5) by first computing d = a − b , m = ν(d) div 2, c = (d − (−1)m (d/4m ))/5, where the divisions by 4m and by 5 are exact; then am = a − 4c, bm = b + 2c. From these observations, it is easy to modify Algorithm CubicBinaryJacobi to obtain Algorithm QuadraticBinaryJacobi. In this algorithm, steps 7–11 implement a harmless iteration equivalent to m > 0 consecutive ugly iterations; steps 13–14 implement bad and good iterations, and the remaining steps are common to both. Step 5 of Algorithm CubicBinaryJacobi is split into three steps 4, 13 and 15. In the case of a harmless iteration, the computation of δ satisfying (6) is implicit in steps 4, 10 and 15.
88
R.P. Brent and P. Zimmermann
Algorithm 2.1. QuadraticBinaryJacobi Input: a, b ∈ N with ν(a) = 0 < ν(b) Output: Jacobi symbol (b|a) 1: s ← 0, j ← ν(b) 2: while 2j a = b do 3: b ← b/2j 4: s ← (s + j(a2 − 1)/8) mod 2 5: (q, r) ← BinaryDividePos(a, b) 6: if (j, q) = (1, 3) then 7: d ← a − b 8: m ← ν(d) div 2 9: c ← (d − (−1)m d/4m )/5 10: s ← (s + m(a − 1)/2) mod 2 11: (a, b) ← (a − 4c, b + 2c) 12: else 13: s ← (s + (a − 1)(b − 1)/4) mod 2 14: (a, b) ← (b , r/2j ) 15: s ← (s + j(a2 − 1)/8) mod 2, j ← ν(b) 16: if a = 1 then return (−1)s else return 0
harmless iteration
good or bad iteration
Theorem 2. Algorithm QuadraticBinaryJacobi is correct and terminates after O(n) iterations of the “while” loop (steps 2–15) if the inputs are positive integers of at most n bits, with 0 = ν(a) < ν(b). Proof. Correctness follows from the equivalence to Algorithm CubicBinaryJacobi. To prove that convergence takes O(n) iterations, we show that a + 2b is multiplied by a factor at most 5/8 in each block of three iterations. This is true if the block includes at least one good iteration, so we need only consider harmless and bad iterations. Two harmless iterations do not occur in succession, so the block must include either (harmless, bad) or (bad, bad). In the first case, the corresponding matrix is BU m = BU · U m−1 for some m > 0. We saw in §1.1 that the matrix U leaves a + 2b unchanged, so U m−1 also leaves a + 2b unchanged, and we need only consider the effect of BU . Suppose that (a, b) is transformed into ( a, b) by BU . Thus a a 1/4 3/8 a . b = BU b = 1/8 7/16 b We see that a + 2b =
5 a 5b + ≤ (a + 2b). 2 4 8
The case of two successive bad iterations is similar – just replace BU by B 2 in the above, and deduce that a + 2b ≤ (a + 2b)/2. We conclude that the number of iterations of the while loop is at most cn + O(1), where c = 3/ log2 (8/5) ≈ 4.4243.
An O(M (n) log n) Algorithm for the Jacobi Symbol
89
Remarks 1. A more complicated argument along similar lines can reduce the constant c to √ 2/ log2 (1/ρ(BU )) = 2/ log2 ((11 − 57)/2) ≈ 2.5424. Here ρ denotes the spectral radius: ρ(A) = limk→∞ ||Ak ||1/k . 2. In practice QuadraticBinaryJacobi is not much (if any) faster than CubicBinaryJacobi. Its advantage is simply the better worst-case time bound. A heuristic argument suggests that on average only 1/4 of the iterations of CubicBinaryJacobi are ugly. 3. Our implementations of CubicBinaryJacobi and QuadraticBinaryJacobi are slower than GMP’s O(n2 ) algorithm (which is based on Stein’s binary gcd, as in Shallit and Sorenson [12]). However, in the next section we use the ideas of our QuadraticBinaryJacobi algorithm to get an O(M (n) log n) algorithm. We do not see how to modify the algorithm of Shallit and Sorenson to do this.3
3
An O(M (n) log n) Algorithm
Algorithm HalfBinaryJacobi below is a modification of Algorithm Half-GB-gcd from [13]. (Algorithm Half-GB-gcd is a subquadratic right-to-left gcd algorithm; for more on the general structure of subquadratic gcd algorithms, we refer the reader to M¨ oller [8].) The main differences between Half-GB-gcd and our algorithm are the following: 1. binary division with positive (not centered) quotient is used; 2. the algorithm returns an integer s such that if a, b are the inputs, c, d the output values defined by Theorem 3, then (b|a) = (−1)s (d|c); 3. at steps 4 and 27, we reduce mod 22k1 +2 (resp. 22k2 +2 ) instead of mod 22k1 +1 (resp. 22k2 +1 ), so that we have enough information to correctly update s0 at steps 10, 17, 21 and 25; 4. we have to “cut” some harmless iterations in two (step 15). Remarks. The matrix Q occurring at step 19 is just 22m U m , where U m is given by Equation (3). Similarly, the matrix Q occurring at step 23 is 22j0 Gj0 ,q . In practice, steps 13–20 can be omitted (so the algorithm becomes a fast version of CubicBinaryJacobi) – this variant is simpler and slightly faster on average. We now state our main theorem. Its proof is based on comparing the GB sequence of a, b and that of a1 , b1 , where a1 = a mod 22k1 +2 and b1 = b mod 22k1 +2 . The GB — which stands for Generalized Binary division, see [13] — sequence of a, b is the sequence of remainders we obtain by applying the binary division iteratively. Two GB sequences match if they produce the same binary quotients qi . 3
In Algorithm Binary Jacobi of [12], it is necessary to know the sign of a − n (b − a in our notation) to decide whether to perform an interchange. This makes it difficult to construct an recursive O(M (n) log n) algorithm along the lines of Algorithm HalfBinaryJacobi.
90
R.P. Brent and P. Zimmermann
Algorithm 3.1. HalfBinaryJacobi Input: a ∈ N, b ∈ N ∪ {0} with 0 = ν(a) < ν(b), and k ∈ N Output: two integers s, j and a 2 × 2 matrix R 1: if ν(b) > k then 10 2: Return 0, 0, 01 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
b = 0 is possible
k1 ← k/2 a1 ← a mod 22k1 +2 , b1 ← b mod 22k1 +2 s1 , j1 , R ← HalfBinaryJacobi(a1 , b1 , k1 ) a ← 2−2j1 (R1,1 a + R1,2 b), b ← 2−2j1 (R2,1 a + R2,2 b) j0 ← ν(b ) if j0 + j1 > k then Return s1 , j1 , R 2 s0 ← j0 (a − 1)/8 mod 2 q, r ← BinaryDividePos(a , b ) b ← b /2j0 if (j0 , q) = (1, 3) then d ← a − b m ← min(ν(d) div 2, k − j1 ) c ← (d − (−1)m d/4m )/5 s0 ← s0 + m(a − 1)/2 mod 2 harmless iteration (a2 , b2) ← (a − 4c, 2(b + c)) (4m + 4(−1)m )/5 2(4m − (−1)m )/5 Q← 2(4m − (−1)m )/5 (4m+1 + (−1)m )/5 else s0 ← s0 + (a − 1)(b − 1)/4 mod 2 r/2j0 ) good or bad iteration (a2 , b2) ← (b , j0 0 2 Q← 2j0 q m ← j0 s0 ← s0 + j0 (a22 − 1)/8 mod 2 k2 ← k − (m + j1 ) s2 , j2 , S ← HalfBinaryJacobi(a2 mod 22k2 +2 , b2 mod 22k2 +2 , k2 ) Return (s0 + s1 + s2 ) mod 2, j1 + j2 + m, S × Q × R
An O(M (n) log n) Algorithm for the Jacobi Symbol
91
Theorem 3. Let a, b, k be the inputs of Algorithm HalfBinaryJacobi, and s, j, R the corresponding outputs. If dc = 2−2j R ab , then: (b|a) = (−1)s (d|c)
and
ν(2j c) ≤ k < ν(2j d).
Proof (outline). We prove the theorem by induction on the parameter k. The key ingredient is that if we reduce a, b mod 22k1 +1 in step 4, then the GB sequence of a1 , b1 matches that of a, b, for the terms computed by the recursive call at step 5. This is a consequence of [13, Lemma 7] (which also holds for binary division with positive quotient). It follows that in all the binary divisions with inputs ai , bi in that recursive call, ai and bi /2ji match modulo 2ji +1 the corresponding values that would be obtained from the full inputs a, b (otherwise the corresponding binary quotient qi would be wrong). Since here we reduce a, b mod 22k1 +2 instead of mod 22k1 +1 , ai and bi /2ji now match modulo 2ji +2 — instead of modulo 2ji +1 — the values that would be obtained from the full inputs a, b, where 2ji +2 ≥ 8 since ji ≥ 1. At step 10, s0 depends only on j0 mod 2 and a mod 8, at step 17 it depends on m mod 2 and a mod 4, and at step 21 on a mod 4 and b mod 4. Since a and b at step 21 correspond to some ai and bi /2ji , it follows that a and b agree mod 8 with the values that would be computed from the full inputs, and thus the correction s0 is correct. This proves by induction that (b|a) = (−1)s (d|c). Now we prove that ν(2j c) ≤ k < ν(2j d). If there is no harmless iteration, it is a consequence of the proof of Theorem 1 in [13]. In case there is a harmless iteration, first assume that m = ν(d) div 2 at step 15. The new values a2 , b2 at step 18 correspond to m successive ugly iterations, which yield j = j1 + m ≤ k. Thus ν(2j a2 ) ≤ k: we did not go too far, and since we are computing the same sequence of quotients as Algorithm QuadraticBinaryJacobi, the result follows. Now if k − j1 < ν(d) div 2, we would go too far if we performed ν(d) div 2 ugly iterations, since it would give j0 := ν(d) div 2 > k −j1 , thus j := j1 +j0 > k, and ν(2j a2 ) would exceed k. This is the reason why we “cut” the harmless iteration at m = k − j1 (step 15). The other invariants are unchanged. Finally we can present our O(M (n) log n) Algorithm FastBinaryJacobi, which computes the Jacobi symbol by calling Algorithm HalfBinaryJacobi. The general structure is similar to that described in [8] for several asymptotically fast GCD algorithms. Daireaux, Maume-Deschamps and Vall´ee [5] prove that, for the positive binary division, the average increase of the most significant bits is 0.65 bits/iteration (which partly cancels an average decrease of two least significant bits per iteration); compare this with only 0.05 bits/iteration on average for the centered division.4
4
We have computed more accurate values of these constants: 0.651993 and 0.048857 respectively.
92
R.P. Brent and P. Zimmermann
Algorithm 3.2. FastBinaryJacobi Input: a, b ∈ N with 0 = ν(a) < ν(b) Output: Jacobi symbol (b|a) 1: s ← 0, j ← ν(b) 2: while 2j a = b do 3: k ← max(ν(b), (b) div 3) 4: s , j, R ← HalfBinaryJacobi(a, b, k) 5: s ← (s + s ) mod 2 6: (a, b) ← 2−2j (R1,1 a + R1,2 b, R2,1 a + R2,2 b), 7: if a = 1 then return (−1)s else return 0
4
(b) is length of b in bits
j ← ν(b)
Experimental Results
We have implemented the different algorithms in C (using 64-bit integers) and in GMP (using multiple-precision integers), as well as in Maple/Magma (for testing purposes). For max(a, b) < 226 the maximum number of iterations of Algorithm CubicBinaryJacobi is 64, with a = 15548029 and b = 66067306. The number of iterations seems to be O(n) for a, b < 2n : see Table 1. This is plausible because, from heuristic probabilistic arguments, we expect about half of the iterations to be good, and experiments confirm this. For example, if we consider all admissible a, b < 220 , the cumulated number of iterations is 3.585×1012 for 238 calls, i.e., an average of 13.04 iterations per call (max 48); the cumulated number of good, bad and ugly iterations is 51.78%, 25.47%, and 22.75% respectively. For a, b < 260 , a random sample of 108 pairs (a, b) gave 42.72 iterations per call (max 89), with 50.54%, 25.14%, and 24.31% for good, bad and ugly respectively. These ratios seem to be converging to the heuristically expected 1/2 = 50%, 1/4 = 25%, and 1/4 = 25%. When we consider all admissible a, b < 220 , the maximum number of iterations of QuadraticBinaryJacobi is 37 when a = 933531, b = 869894, the cumulated number of iterations is 3.405 × 1012 (12.39 per call), the cumulated number of good, bad and harmless iterations is 54.51%, 26.82%, and 18.67% respectively. For a, b < 260 , a random sample of 108 pairs (a, b) gave 40.21 iterations per call (max 76), with 53.70%, 26.71%, and 19.59% for good, bad and harmless respectively. These ratios seem to be converging to the heuristically expected 8/15 = 53.33%, 4/15 = 26.67%, and 1/5 = 20%. We have also compared the time and average number of iterations for huge numbers, using the fast gcd algorithm in GMP, say gcd — which implements the algorithm from [8] — and an implementation of the algorithm from [13], say bgcd. For inputs of one million 64-bit words, gcd takes about 45.8s on a 2.83Ghz Core 2, while bgcd takes about 48.3s and 32,800,000 iterations: this is in accordance with the fact proven in [5] that each step of the binary gcd discards on average two least significant bits, and adds on average about 0.05 most significant bits. Our algorithm bjacobi (based on Algorithms 3.1–3.2) takes about 83.1s
An O(M (n) log n) Algorithm for the Jacobi Symbol
93
1e+06 mpz_jacobi FastBinaryJacobi 100000 10000 1000 100 10 1 0.1 0.01 0.001 0.0001 1
10
100
1000
10000
100000
Fig. 1. Comparison of GMP 4.3.1 mpz jacobi routine with our FastBinaryJacobi implementation in log-log scale. The x-axis is in 64-bit words, the y-axis in milliseconds on a 2.83Ghz Core 2. Table 1. Worst cases for CubicBinaryJacobi(b|a), max(a, b) < 2n n iterations example (a, b) 5 6 (7, 30) 10 19 (549, 802) 15 34 (23449, 19250) 20 48 (656227, 352966) 21 51 (1596811, 1493782)
n iterations example (a, b) 22 53 (2214985, 2781506) 23 55 (1383497, 8292658) 24 58 (2236963, 12862534) 25 62 (28662247, 30847950) 26 64 (15548029, 66067306)
and 47,500,000 iterations (for a version with steps 13–20 of Algorithm 3.1 omitted in the basecase routine), which agrees with the theoretical drift of 0.651993 bits per iteration. The break-even point between the O(n2 ) implementation of the Jacobi symbol in GMP 4.3.1 and our O(M (n) log n) implementation is about 535 words, that is about 34, 240 bits or about 10, 300 decimal digits (see Fig. 1).
5
Concluding Remarks
Weilert [15] says: “We are not able to use a GCD calculation in Z[i] similar to the binary GCD algorithm · · · because we do not get a corresponding quotient
94
R.P. Brent and P. Zimmermann
sequence in an obvious manner ”. In a sense we filled that gap for the computation of the Jacobi symbol, because we showed how it can be computed using a binary GCD algorithm without the need for a quotient sequence. We showed how to compute the Jacobi symbol with an asymptotically fast time bound, using such a binary GCD algorithm. Our implementation is faster than a good O(n2 ) implementation for numbers with bitsize n > 35000. Our subquadratic implementation is available from http://www.loria.fr/~zimmerma/ software/#jacobi. Binary division with a centered quotient does not seem to give a subquadratic algorithm; however we can use it with the “cubic” algorithm (which then becomes provably quadratic) since then we control the sign of a, b. For a better quadratic algorithm, we can choose the quotient q so that abq < 0, by replacing q by q − 2j+1 if necessary: experimentally, this gains on average 2.194231 bits per iteration, compared to 1.951143 for the centered quotient, and 1.348008 for the positive quotient. In comparison, Stein’s “binary” algorithm gains on average 1.416488 bits per iteration [4, §7][7, §4.5.2]. Acknowledgement. We thank Steven Galbraith who asked us about the existence of an O(M (n) log n) algorithm for the Jacobi symbol, Arnold Sch¨ onhage for his comments and a pointer to the work of his former student Andr´e Weilert, Damien Stehl´e who suggested adapting the binary gcd algorithm, and Marco Bodrato and Niels M¨oller for testing our implementation. We also thank the two anonymous reviewers, especially the one who actually implemented our new algorithm in Magma! We thank INRIA for its support of the ANC “´equipe associ´ee”. The first author acknowledges the support of the Australian Research Council.
References 1. Bach, E.: A note on square roots in finite fields. IEEE Trans. on Information Theory 36(6), 1494–1498 (1990) 2. Bach, E., Shallit, J.O.: Algorithmic Number Theory: Efficient Algorithms, vol. 1. MIT Press, Cambridge (1996) (Solution to problem 5.52) 3. Bachmann, P.: Niedere Zahlentheorie, Teubner, Leipzig, vol. 1 (1902); Reprinted by Chelsea, New York (1968) 4. Brent, R.P.: Twenty years’ analysis of the binary Euclidean algorithm. In: Davies, J., Roscoe, A.W., Woodcock, J. (eds.) Millennial Perspectives in Computer Science: Proceedings of the 1999 Oxford - Microsoft Symposium in honour of Professor Sir Antony Hoare, Palgrave, New York, pp. 41–53 (2000), http://wwwmaths.anu.edu.au/~brent/pub/pub183.html 5. Daireaux, B., Maume-Deschamps, V., Vall´ee, B.: The Lyapunov tortoise and the dyadic hare. In: Proceedings of the 2005 International Conference on Analysis of Algorithms, DMTCS Proc. AD, pp. 71–94 (2005), http://www.dmtcs.org/dmtcs-ojs/index.php/proceedings/issue/view/81 6. Gauss, C.F.: Theorematis fundamentalis in doctrina de residuis quadraticis, demonstrationes et ampliatones novæ. Comm. Soc. Reg. Sci. Gottingensis Rec. 4 (presented February 10, 1817) (1818); Reprinted in Carl Friedrich Gauss Werke, Bd. 2: H¨ ohere Arithmetik, G¨ ottingen, pp. 47–64 (1876)
An O(M (n) log n) Algorithm for the Jacobi Symbol
95
7. Knuth, D.E.: The Art of Computer Programming. In: Seminumerical Algorithms, 3rd edn., vol. 2, Addison-Wesley, Reading (1997) 8. M¨ oller, N.: On Sch¨ onhage’s algorithm and subquadratic integer GCD computation. Mathematics of Computation 77(261), 589–607 (2008) 9. Sch¨ onhage, A.: Schnelle Berechnung von Kettenbruchentwicklungen. Acta Informatica 1, 139–144 (1971) 10. Sch¨ onhage, A.: Personal communication by email (December 2009) 11. Sch¨ onhage, A., Grotefeld, A.F.W., Vetter, E.: Fast Algorithms: A Multitape Turing Machine Implementation. BI-Wissenschaftsverlag, Mannheim (1994) 12. Shallit, J., Sorenson, J.: A binary algorithm for the Jacobi symbol. ACM SIGSAM Bulletin 27(1), 4–11 (1993), http://euclid.butler.edu/~sorenson/papers/binjac.ps 13. Stehl´e, D., Zimmermann, P.: A binary recursive gcd algorithm. In: Buell, D.A. (ed.) ANTS 2004. LNCS, vol. 3076, pp. 411–425. Springer, Heidelberg (2004) 14. Vall´ee, B.: A unifying framework for the analysis of a class of Euclidean algorithms. In: Gonnet, G.H., Viola, A. (eds.) LATIN 2000. LNCS, vol. 1776, pp. 343–354. Springer, Heidelberg (2000) 15. Weilert, A.: Fast Computation of the Biquadratic Residue Symbol. Journal of Number Theory 96, 133–151 (2002)
New Families of ECM Curves for Cunningham Numbers ´ Eric Brier1 and Christophe Clavier2,3
2
1 Ingenico S.A. 1, rue Claude Chappe, B.P. 346, 07530 Guilherand-Granges, France
[email protected] Institut d’Ing´enierie Informatique de Limoges (3iL) 43, rue Sainte Anne F-87000 Limoges
[email protected] 3 Universit´e de Limoges – XLIM D´epartement de Math´ematiques et Informatique 83, rue d’Isle F-87000 Limoges
[email protected]
Abstract. In this paper we study structures related to torsion of elliptic curves defined over number fields. The aim is to build families of elliptic curves more efficient to help factoring numbers of special form, including numbers from the Cunningham Project. We exhibit a family of curves with rational Z/4Z × Z/4Z torsion and positive rank over the field Q(ζ8 ) and a family of elliptic curves with rational Z/6Z × Z/3Z torsion and positive rank over the field Q(ζ3 ). These families have been used in finding new prime factors for the numbers 2972 + 1 and 21048 + 1. Along the way, we classify and give a parameterization of modular curves for some torsion subgroups.
1
Introduction
The Elliptic Curve Method (ECM in short) is a factoring algorithm, whose complexity depends on the size of the smallest prime factor instead of the size of the number to be factored. It can be seen as a variation of the p − 1 method. The idea is to build an elliptic curve over the ring Z/N Z with a point P on it and to compute the scalar multiplication M · P . Since N is not a prime, the elliptic curve is not defined over a field. However, computations are done as if we were working on a field and if something fails, this means that a non-trivial factor of N has been found. The number M is chosen to be the product of powers of small primes and thus, a prime factor p is found as soon as the order of the elliptic curve reduced modulo p is smooth. G. Hanrot, F. Morain, and E. Thom´ e (Eds.): ANTS-IX 2010, LNCS 6197, pp. 96–109, 2010. c Springer-Verlag Berlin Heidelberg 2010
New Families of ECM Curves for Cunningham Numbers
97
Many improvements of the ECM are described in the literature. We will focus on an improvement consisting in choosing the elliptic curve as the reduction modulo N of an elliptic curve defined over the field Q with a non-trivial torsion group and positive rank. The torsion group of an elliptic curve is the group of elements of finite order and the rank is the number of generators of the torsionfree part of the group. As soon as small prime factors have been removed from N , the torsion group is preserved in most cases by the modulo N reduction of the curve, which helps to make the order of the curve smooth. The positive rank is needed to set the starting point P of the algorithm. Possible torsion groups for elliptic curves defined over Q are in finite number, with maximal order 16. For each possible torsion group, at least a family of elliptic curves with positive rank has been found. The idea we follow in this paper is to use a number field K for which reduction modulo N can be made explicit and to build over K an elliptic curve with positive rank and a torsion subgroup as large as possible. Let us give an example : if the number to be factored is of the form N = u2 + 1, we can make use of the field K = Q(i) with mapping i → u. The numbers of the Cunningham Project (i.e. numbers of the form am ±1) allow to use m-th roots of unity. It will be interesting to focus on cyclotomic fields or on their subfields. It is important to note that all quadratic extensions of Q lie in cyclotomic fields. The paper is organized as follows. Section 2 introduces the necessary notions about modular curves and classifies torsion subgroups that can be of any interest for ECM integer factoring. Section 3 is devoted to construction of parameterized elliptic curves with given torsion subgroup over some cyclotomic extensions of the field of rationals. Section 4 focuses on the search for infinite subfamilies of elliptic curves having nonzero rank, which is mandatory to ECM usage. Section 5 rephrases previous sections results in the context of ECM and gives some instances of new prime factors of Cunningham Project numbers discovered thanks to the work presented here. Finally, section 6 concludes and suggests some research areas to go further.
2
Elliptic Curve Torsion and Modular Curves
An elliptic curve E defined over a number field K turns out to be a commutative group. The Mordell-Weil theorem states that this group is finitely generated and can be written as: E(K) ∼ = T ⊗ Zr where the integer r is called rank and T is the so called torsion group, which consists in elements of finite order. Furthermore, T is isomorphic to Z/m1 Z × Z/m2 Z with the constraints that m2 divides m1 and the m2 -th roots of unity all lie in the field K. Whereas it is conjectured that the rank is not constrained, the torsion group can take only finitely many different shapes over the field of rationals:
98
´ Brier and C. Clavier E.
Theorem 1 (Mazur). The torsion group T of an elliptic curve defined over the field Q is isomorphic to one of the following groups: Z/mZ with 1 ≤ m ≤ 10 or m = 12 Z/2mZ × Z/2Z with 1 ≤ m ≤ 4 This theorem is effective in the sense that for each of these cases, it is possible to give equations of elliptic curves. These parameterizations come from modular curves. Over the field C of complex numbers, there is a one-to-one correspondance between isomorphism classes of elliptic curves and the Riemann Surface X(1), which is the quotient H∗ /SL2 (Z), where H∗ is the compactified Poincar´e halfplane. For any subgroup Γ of SL2 (Z), the quotient surface H∗ /Γ is called a modular curve. Extending notations of [3], we define the following subgroups of SL2 (Z): a b Γ (m) = ∈ SL2 (Z), a ≡ d ≡ 1 mod m, b ≡ c ≡ 0 mod m c d Γ1 (m) = Γ0 (m) =
a b c d a b c d
∈ SL2 (Z), a ≡ d ≡ 1 mod m, c ≡ 0 mod m
∈ SL2 (Z), c ≡ 0 mod m
and the quotients: X(m) = H∗ /Γ (m) X1 (m) = H∗ /Γ1 (m) X0 (m) = H∗ /Γ0 (m) X1 (m1 , m2 ) = H∗ /(Γ1 (m1 ) ∩ Γ (m2 )) when m2 |m1 A point on the surface X(m) corresponds to an elliptic curve together with a basis for its [m]-torsion subgroup, up to isomorphism. A point on the surface X1 (m) corresponds, up to isomorphism, to an elliptic curve together with a [m]torsion point. A point on the surface X0 (m) corresponds, up to isomorphism, to an elliptic curve together with a cyclic torsion subgroup of order m. A point on the surface X(m1 , m2 ) corresponds to an elliptic curve with a [m1 ]-torsion point and an independent [m2 ]-torsion point. Though these notions make use of complex number and analytical tools, the modular curves can also be represented as algebraic curves. An algebraic model of X1 (m) can be found over Q and the correspondance with an elliptic curve and a [m]-torsion point on it is algebraic and defined over Q. The curve X(m) involves the full [m]-torsion subgroup and, due to existence of Weil pairing, m-th roots of unity are involved. The rational models and correspondance for X(m) (resp. X1 (m1 , m2 )) are defined over the cyclotomic field Q(ζm ) (resp. Q(ζm2 )). The modular curves associated to torsion
New Families of ECM Curves for Cunningham Numbers
99
subgroups in Mazur’s theorem are genus 0 algebraic curves. This explains why it is possible to give parametric Weierstrass equations. The Elliptic Curve Method needs a non-bounded number of elliptic curves to compute with. Since algebraic curves of genus greater than 2 have only finitely many rational points over a given number field, we will focus only on torsion structures for which the associated modular curve has genus 0 or 1. Computing the genus of an algebraic curve is not an easy task in the general case but the task is easy with a computer for modular curves of rather small level. A theorem from Shimura states that the genus of the modular curve X1 (p) for a prime p ≥ 5 is given by : g=
(p − 5)(p − 7) . 24
This implies that the only primes for which the genus of X1 (p) is 0 or 1 are {2, 3, 5, 7, 11}. When n|m, there is a surjective mapping X1 (m) → X1 (n), and thus the genus of X1 (m) is at least the genus of X1 (n). Computing the genus of X1 (m) for rather small values of m being easy, we can increase the power of these primes until the genus is strictly greater than 1 and we get that the only prime powers for which the genus of X1 (pe ) is 0 or 1 are {2, 4, 8, 3, 9, 5, 7, 11}. Now, combining this finite set, it is possible to check the following proposition with a finite amount of work: Proposition 1. The integers m such that X1 (m) is of genus 0 or 1 are {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15} When m2 |m1 , there is a surjective mapping X1 (m1 , m2 ) → X1 (m1 ), and thus the genus of X1 (m1 , m2 ) is at least the genus of X1 (m1 ). This implies that if the genus of the modular curve X1 (m1 , m2 ) is 0 or 1, the number m1 is in the list given in proposition 1. Building on this, for any m1 in this list, we can check if the genus of X1 (m1 , m2 ) is 0 or 1 for all divisors m2 of m1 . The result is given in next proposition. Proposition 2. The torsion groups for which the associated modular curve is of genus 0 are: Z/2Z, Z/3Z, Z/4Z, Z/5Z, Z/6Z, Z/7Z Z/8Z, Z/9Z Z/10Z Z/12Z
Z/2Z × Z/2Z Z/3Z × Z/3Z Z/4Z × Z/2Z, Z/5Z × Z/5Z Z/6Z × Z/2Z, Z/8Z × Z/2Z
Z/4Z × Z/4Z Z/6Z × Z/3Z
100
´ Brier and C. Clavier E.
The torsion groups for which the associated modular curve is of genus 1 are: Z/6Z × Z/6Z Z/8Z × Z/4Z Z/9Z × Z/3Z Z/10Z × Z/2Z Z/11Z Z/12Z × Z/2Z Z/14Z Z/15Z
3
Parameterization of Elliptic Curves with Given Torsion Structure
When the base field is Q, several papers (e.g. [8] and [4]) describe the construction of elliptic curves with prescribed torsion groups. We will study cases that need to work over extensions. 3.1
Construction of Z/3Z × Z/3Z
To study torsion points, one can use the division polynomials, whose roots a