Skip to main content Accessibility help
×
Hostname: page-component-5b777bbd6c-w9n4q Total loading time: 0 Render date: 2025-06-18T19:14:14.598Z Has data issue: false hasContentIssue false

Four primality testing algorithms

Published online by Cambridge University Press:  30 May 2025

J. P. Buhler
Affiliation:
Reed College, Oregon
P. Stevenhagen
Affiliation:
Universiteit Leiden
Get access

Summary

In this expository paper we describe four primality tests. The first test is very efficient, but is only capable of proving that a given number is either composite or ‘very probably’ prime. The second test is a deterministic polynomial time algorithm to prove that a given numer is either prime or composite. The third and fourth primality tests are at present most widely used in practice. Both tests are capable of proving that a given number is prime or composite, but neither algorithm is deterministic. The third algorithm exploits the arithmetic of cyclotomic fields. Its running time is almost, but not quite polynomial time. The fourth algorithm exploits elliptic curves. Its running time is difficult to estimate, but it behaves well in practice.

In Section 2 we discuss the Miller–Rabin test. This is one of the most efficient probabilistic primality tests. Strictly speaking, the Miller–Rabin test is not a primality test but rather a ‘compositeness test’, since it does not prove the primality of a number. Instead, if n is not prime, the algorithm proves this in all likelihood very quickly. On the other hand, if n happens to be prime, the algorithm merely provides strong evidence for its primality. Under the assumption of the Generalized Riemann Hypothesis one can turn the Miller–Rabin algorithm into a deterministic polynomial time primality test. This idea, due to G. Miller, is also explained.

In Section 3 we describe the deterministic polynomial time primality test that was proposed by M. Agrawal, N. Kayal and N. Saxena in 2002 [Agrawal et al. 2004]. At the moment of this writing, this new test, or rather a more efficient probabilistic version of it, had not yet been widely implemented. In practice, therefore, for proving the primality of a given integer, one still relies on older tests that are either not provably polynomial time or not deterministic. In the remaining two sections we present the two most widely used such tests.

Type
Chapter
Information
Algorithmic Number Theory
Lattices, Number Fields, Curves and Cryptography
, pp. 101 - 126
Publisher: Cambridge University Press
Print publication year: 2008

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Book purchase

Temporarily unavailable

Save book to Kindle

To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×