← LibraryThe Jacobi Sum Primality TestEngineering · MathematicsLesson 4/5← PrevNext →
GuidePublished 6 Aug 20264 min readBy Kevin JoginComputational Number TheoryPrimalityJacobi Sum TestAPR-CL
Skip to the main content

MathematicsPrimality

The Jacobi Sum Primality Test

A general-purpose proving method with almost polynomial running time, built on Gauss and Jacobi sums in cyclotomic extensions.

Executive summary

Almost polynomial, and for decades the only general proving method

The Jacobi sum test generalises Fermat's test to characters of higher order. Working in cyclotomic extensions of ℤ/nℤ, it verifies congruences involving Jacobi sums that must hold when n is prime. Passing them constrains the residue of n modulo a large auxiliary integer to a small set, and a final trial division stage eliminates the remaining candidates. The running time is (log n)O(log log log n) — not polynomial, but the triple logarithm makes it behave as though it were.

Learning objectives

  • Explain the role of the auxiliary integers s and t.
  • Describe how characters of order q generalise the Fermat test.
  • Outline the structure of the basic test and the final stage.
  • Compare the Jacobi sum test with ECPP on cost and certification.

Section 01The construction

Choose a squarefree t whose prime divisors q satisfy: q − 1 divides t. Set s to be the product of all such primes q. The key requirement is

s2 > n

which is achievable with t remarkably small — the highly composite structure means s grows very rapidly with t. That disparity is the source of the near-polynomial running time.

Why s can be so large for small t

The primes q with q − 1 dividing a highly composite t are numerous, and their product s grows super-exponentially in t. A t of a few thousand yields an s with hundreds of digits, so the number of conditions to check grows only slowly as n grows.

Section 02Characters and the basic test

For a prime power qk dividing t, work in the cyclotomic ring ℤ[ζqk] reduced modulo n. Characters of order qk and their Jacobi sums satisfy congruences that follow from n being prime.

  1. Stage 01Set upChoose t and s with s² > n; verify gcd(n, st) = 1.
  2. Stage 02Test each pairFor each prime power dividing t and each prime dividing s, verify the Jacobi sum congruence in the appropriate cyclotomic extension.
  3. Stage 03Extract the conditionPassing tests establish that every prime factor of n is congruent to a power of n modulo s.
  4. Stage 04Final stageTest the candidate residues ni mod s for i = 1, …, t−1; if none divides n, then n is prime.
The final stage is a genuine trial division

After all the cyclotomic machinery, the conclusion rests on checking at most t − 1 candidate divisors. That stage is elementary, cheap, and is what converts the accumulated congruence conditions into a proof.

Section 03Comparison with ECPP

Jacobi sum test versus elliptic curve proving
AspectJacobi sum (APR-CL)ECPP
Running time(log n)O(log log log n), deterministic in practiceHeuristically O(log4+ε n), randomised
CertificateNone short — the proof is the computationShort and independently verifiable
ImplementationIntricate cyclotomic arithmetic, but a fixed procedureRequires CM curve construction and point counting
Sweet spotA few hundred to a few thousand digits, where it is often fastestLarge numbers, and anywhere a certificate is required
Failure modeRuns to completionMay need to retry with different curves
No certificate is a real limitation

A Jacobi sum proof cannot be handed to a third party for cheap verification — re-running the whole computation is the only check. Where a result must be independently verifiable, ECPP is the appropriate choice even when it is slower.

ReferenceFrequently asked questions

Why is the running time not polynomial?

Because the number of auxiliary primes, and hence the number of conditions to verify, grows slightly faster than any fixed power of log n. The growth involves a triple logarithm, which for any conceivable input behaves like a constant — so the distinction is theoretical rather than practical.

Is the test deterministic?

The core is deterministic. Some implementations randomise the search for suitable characters to improve speed, but the conclusion does not depend on chance, and the test always terminates with a definite answer.

Why did the Cohen-Lenstra refinement matter?

The original APR formulation was theoretically important but impractical. The reformulation using Jacobi sums rather than Gauss sums reduced the arithmetic to manageable size and made the test implementable — which is what turned a theoretical advance into the standard proving method for over a decade.

NavigateContinue in this stream

Curated next steps from this page. The site also surfaces algorithmically related reading below.

ProvenanceSources and further reading

This page is an original KEVOS explanatory article. It presents the underlying mathematics — definitions, algorithms, complexity results and selection criteria — in KEVOS editorial voice. No text is reproduced from any copyrighted source. Where numerical tables are relevant, KEVOS links to live authoritative databases rather than republishing static values.

Page ID
KV-MATH-0047
Taxonomy
ENG-MATH — Engineering / Mathematics
Collection
COL-CANT-001
Topic stream
CANT-PRIMALITY
Version
1.1.0 / content 2026.08
Last reviewed
2026-08-06

Continue learning

Classical Primality Proofs: Pocklington and LehmerGuide · MathematicsNEXT LESSON →Elliptic Curve Primality ProvingGuide · MathematicsCompositeness Tests: Fermat and Miller–RabinGuide · MathematicsPrimality Testing versus FactoringGuide · Mathematics