An implementation that transmits a point of an elliptic curve—a pair of field elements satisfying an equation , as constructed in 10—need not send both coordinates. For a given the equation determines exactly, hence determines up to sign, so wire formats send together with a single bit selecting one of the two candidates, and the transmission halves in size. The receiver is then left with two number-theoretic tasks: decide whether is a square modulo at all—if not, no point has this -coordinate—and, if it is, compute a square root of it. Both tasks must run in the time of a few modular exponentiations, on numbers hundreds of bits long. The same constructions make a complementary demand in the opposite direction: they publish powers of a known group element while the exponent is a secret key, so exponentiation must be easy to perform and yet infeasible to invert. This section assembles the classical number theory behind both demands: the totient and the Chinese Remainder Theorem, Fermat’s little theorem and Euler’s theorem in their role as workhorses of modular exponentiation, multiplicative orders and primitive roots, quadratic residues with the Euler criterion, square-root extraction modulo a prime, and finally the discrete logarithm problem together with the reason prime group order is so important for cryptographic hardness.
Throughout, and denote positive integers and denotes a prime. The section builds directly on the arithmetic of 2, the group theory of 3, and the cyclicity theorem of 6; several statements proved there reappear here, restated in the arithmetic language in which cryptography uses them, with proofs reduced to citations.
Recall from 2 that a class is a unit if and only if (Theorem 2.24), that the units form a finite abelian group (Proposition 3.8), and that Euler’s totient counts them: (Definition 2.26). In particular for a prime (Example 2.27), so has order . These counts govern everything that follows: the totient is the exponent in Euler’s theorem, the order of the group whose cyclic structure the next subsections exploit, and—through the orders of elliptic-curve groups—a quantity that the parameter choices of Halo 2 and Orchard are built around. What 2 did not provide is a way to compute beyond direct enumeration. Two facts close the gap: the totient’s value on prime powers, and its behaviour on coprime factors.
For a prime and an integer ,
Among , we claim the integers not coprime to are exactly the multiples of . If then , so the gcd exceeds . Conversely, if , then has a prime factor ; from and Euclid’s lemma for primes (Lemma 2.17) we get , and gives . The multiples of in the range are , of which there are ; subtracting them from the integers in the range leaves . □
The behaviour on coprime factors is a consequence of a structural theorem that will be used again, in a quite different role, at the end of the section: a residue modulo a product of two coprime moduli carries exactly the same information as a pair of residues, one modulo each factor. The natural home for the statement is the language of rings (4): recall the product ring with componentwise operations (Example 4.5), and call a bijective ring homomorphism (Definition 4.21) a ring isomorphism, mirroring Definition 3.41 for groups.
If , then the map
is a ring isomorphism. It restricts to a group isomorphism
The map is well defined: if then , hence and , so the two components agree. It is a ring homomorphism because each component is: reduction modulo (and modulo ) sends sums to sums, products to products, and to (Theorem 4.6), and the product ring’s operations are componentwise.
For injectivity it suffices, since the map is in particular a homomorphism of additive groups, to check that the kernel is trivial (Proposition 3.40). Suppose and , that is, and . Since , Euclid’s lemma (Proposition 2.15(2)) gives , i.e. .
Both sides have exactly elements (Theorem 4.6 for each factor), and an injective map between finite sets of equal size is bijective: the distinct inputs have distinct images, which must exhaust the codomain. Hence the map is a ring isomorphism.
For the multiplicative statement, a ring isomorphism matches units with units: if then , and the same applies to . The units of the product ring are exactly the pairs of units, existing precisely when both components are invertible. Restricting to unit groups therefore gives a bijection that respects multiplication: a group isomorphism. □
If then . Hence if is the prime factorisation of , then
the last product running over the distinct primes dividing .
The unit-group isomorphism of Theorem 7.2 is in particular a bijection, and the cardinality of a product of two sets is the product of the cardinalities, so .
For the product formula, the prime powers are pairwise coprime: a common divisor exceeding of two of them would have a prime factor dividing both, which by Euclid’s lemma for primes (Lemma 2.17) would equal both and . Moreover each is coprime to the product of the others, by repeated application of Proposition 2.15(3). Induction on the number of factors therefore extends multiplicativity to , and Proposition 7.1 evaluates each factor:
The congruences of this subsection were proved once, as Corollary 3.32, where they fell out of Lagrange’s theorem in three lines. We restate them here in the arithmetic form in which cryptography uses them; the proofs are citations, not repetitions.
If , then
The hypothesis says that is a unit (Theorem 2.24), i.e. an element of the finite group , whose order is (Definition 2.26). By Corollary 3.31—every element of a finite group of order satisfies , a consequence of Lagrange’s theorem—we get , which is the stated congruence. This is Corollary 3.32 verbatim. □
Let be prime. If , then . Moreover for every integer .
Euler’s theorem underlies RSA: if , say , then
whenever : raising to the -th power is undone by raising to the -th, which is what makes one exponent a public encryption key and the other its private inverse. The elliptic-curve cryptography of Orchard instead exploits Fermat’s little theorem in the field : every nonzero satisfies , so inversion is computable as (6.4), and Fermat is the engine of the Euler criterion for square roots developed below.
Let . The multiplicative order of modulo , written , is the least positive integer with . Such a exists because by Theorem 7.4.
The quantity is exactly the order of as an element of the group , so the order theory of 3 applies verbatim: if and only if (Proposition 3.12(1))—in particular , by Euler’s theorem—and
(Corollary 3.23).
A primitive root modulo is an element with ; equivalently, generates as a cyclic group, so that lists all the units.
Primitive roots need not exist for every modulus. The unit group has order , yet every one of its elements squares to (Example 3.22): the element orders are for the identity and for each of , , , so no element has order and no primitive root modulo exists. Indeed the unit group is a copy of the Klein four-group of Example 3.10: every element is its own inverse, and the product of two distinct non-identity elements and is neither (which would force ) nor nor (which would force or ), so it is the third. The decisive case for cryptography is prime, where the multiplicative group is always cyclic.
For every prime , the group is cyclic of order . In particular primitive roots modulo exist, and there are exactly of them; Example 6.21 exhibits the two primitive roots and of .
Cyclicity is why the prime-order groups of elliptic-curve cryptography behave exactly like under addition once a generator is fixed: a cyclic group of order is isomorphic to via (Theorem 3.43). For completeness we record, without proof and without needing it later, the full classification: primitive roots modulo exist exactly when for an odd prime .
We turn to squares modulo a prime. They control whether a curve point with a given -coordinate exists—the first of the two tasks posed at the head of the section—and they are the objects from which square roots in will be extracted.
Let be an odd prime and an integer with . We say is a quadratic residue modulo (a QR) if the congruence has a solution, and a quadratic non-residue (a QNR) otherwise.
For an odd prime , exactly of the nonzero residues modulo are quadratic residues and are non-residues. The squaring map is exactly two-to-one on .
Consider , ; its image is exactly the set of quadratic residues. For ,
the middle equivalence because a field has no zero divisors (Proposition 4.28). Since is odd, for (otherwise with and nonzero), so every fibre of over its image has exactly two elements. Counting, , and the complement—the non-residues—has the same size. □
Let be an odd prime and . Then
First, the value is always . Fermat’s little theorem (Corollary 7.5) gives , and the only square roots of modulo a prime are : from we get , so or by Euclid’s lemma for primes (Lemma 2.17), i.e. . Hence .
If is a residue, say with , then , again by Fermat. Thus every one of the quadratic residues (Proposition 7.12) is a root of the polynomial over . That polynomial has degree , so it has at most roots (Theorem 5.18); the residues therefore account for all of them. A non-residue is consequently not a root, yet still satisfies ; the remaining possibility is . □
The standard notation for quadratic-residue status is the Legendre symbol.
For an odd prime and an integer , the Legendre symbol is
Euler’s criterion (Theorem 7.13) then reads, uniformly,
so the symbol is computable by a single modular exponentiation—an affair by square-and-multiply (6.2). The criterion also shows that the symbol is completely multiplicative in :
Both observations carry weight in the worked example that follows, which verifies a constant deployed in Orchard.
The Pasta hash-to-curve construction used by Orchard—a procedure, taken up in later volumes, that maps arbitrary byte strings to curve points and requires a fixed non-square constant in the base field—fixes as a verifiably non-square constant in both base fields. Let and be the Pasta primes of 10; both satisfy . We verify the non-squareness here, working modulo ; the computation modulo is identical.
First, is a square modulo any prime : the exponent is even, so Euler’s criterion gives
By complete multiplicativity,
so is a non-square precisely when is. Whether is a square is settled by one Euler-criterion exponentiation in each field, a computation any computer-algebra system reproduces in milliseconds:
whence . Thus , and with it , is a quadratic non-residue modulo both Pasta primes, exactly as the hash-to-curve design requires.
The same one-line test settles a second constant on which later volumes lean, this time in the curve equation itself. Pallas is the curve over (10), and the arithmetic circuits of Halo 2 encode its point at infinity as the coordinate pair (10.13). The encoding is unambiguous only if no genuine point has -coordinate , i.e. only if has no solution in : the question is whether is a square in the base field of Pallas, not in its scalar field . Euler’s criterion decides it in one exponentiation:
so . The constant is a quadratic non-residue modulo the Pallas base-field prime, and no point of Pallas has . (The same computation modulo gives , so Vesta has no such point either.) That no point has is a different fact— is not a cube in —which 10.26 reads off from the oddness of the group order; the two together are the hypotheses of 10.14.
Deciding that is a residue is one matter; producing an with is another, and the point decompression of the section’s opening needs the production, not just the decision: the receiver must reconstruct the coordinate from . How hard this is depends on .
Let be prime and let be a quadratic residue modulo with . Then
is a square root of , and the two square roots of are .
The single-exponentiation shortcut requires , which is one reason cryptographers often favour such primes. For a closed-form variant (Atkin’s formula) still exists. In general the cost of square-root extraction grows with the -adic valuation of : writing with odd, the Tonelli–Shanks algorithm below performs up to corrective iterations. The Pasta primes have , a value chosen deliberately for FFT-friendliness (9.10), so their implementations use Tonelli–Shanks.
When one writes with odd and . The algorithm operates inside the subgroup of of order —the unique such subgroup, since is cyclic (Corollary 7.9 and Theorem 3.24(3))—where the obstruction to the naive exponentiation trick lives, and clears that obstruction one power of two at a time.
Let be an odd prime, with odd, and let be a quadratic residue with . Given any quadratic non-residue modulo , one can compute a square root of modulo using modular multiplications.
Write for the unique cyclic subgroup of order . Set . We claim generates . By Euler’s criterion (Theorem 7.13) , so
by Fermat (Corollary 7.5); hence divides but not , forcing and .
Initialise
(the exponent is an integer because is odd). We maintain three invariants:
;
the current has order exactly ;
the order of divides .
Initially (1) holds since ; (2) was just proved; and (3) holds because by Euler’s criterion (Theorem 7.13), being a residue.
Now iterate. If , then by (1) and we are done. Otherwise let , found as the least with by repeatedly squaring ; invariant (3) gives . Set
and update
The invariants survive. For (1), , which is times the new . For (2), the old has order , so (Corollary 3.23), and the new has order —exactly to the new . For (3), both the old and have order exactly , so and each have order ; the only element of order in is , because the square roots of are (as in the proof of Theorem 7.13); hence
so the new has order dividing , which is for the new .
Each iteration strictly decreases , from through a descending chain of nonnegative integers, so after at most iterations the order of reaches , i.e. , and is the desired root. For the cost: locating and computing each take at most squarings, so the loop costs multiplications per iteration and in total; the three initial exponentiations, with exponents smaller than , cost multiplications each by square-and-multiply (6.2). □
The one ingredient the theorem presupposes is a quadratic non-residue , and here—for the only time in this section—randomness enters. A uniformly random element of is a non-residue with probability exactly , since precisely half the elements qualify (Proposition 7.12), and each candidate is checked by one Euler-criterion exponentiation (Definition 7.14), i.e. modular multiplications. A handful of random trials therefore finds almost immediately, and implementations simply hard-code one non-residue per field, verified once—as the constant of Example 7.15 is. No deterministic polynomial-time method for finding a non-residue is invoked anywhere in this volume.
In every case the square roots of a residue come in a pair (Proposition 7.12), so a canonical root must be pinned down by a convention—for instance “choose the root whose least nonnegative representative is even”, as elliptic-curve point encodings do; the compressed point’s extra bit selects between the two. If is not a residue, both algorithms above detect the failure, in different ways. The shortcut of Proposition 7.17 still outputs a candidate , and that candidate fails the final check —one squaring suffices to detect failure. The variable-time Tonelli–Shanks algorithm just given cannot complete its update on a non-residue: Euler’s criterion gives , so satisfies and has order exactly , and already the first search for the least with returns , which invariant (3) of the proof of Theorem 7.19 forbids and for which the update exponent is undefined. This variant can report “not a residue” the moment occurs; equivalently it may verify up front, at the same cost as the initial exponentiations.
The second demand of the section’s opening—exponentiation easy forward, infeasible backward—now takes centre stage. We phrase it for a generic cyclic group, written multiplicatively, because in Orchard the group in question is the group of points of an elliptic curve, written additively, of large prime order; every statement below transfers by renaming the operation.
Let be a finite cyclic group of order with generator . Given , the discrete logarithm of to base , written , is the unique residue with . The discrete logarithm problem (DLP) is to compute from .
Existence and uniqueness of are the content of the classification of cyclic groups: the map is a group isomorphism (Theorem 3.43, whose map this is), so it has a well-defined inverse, and is that inverse. The two directions could not differ more in cost. Computing from takes group operations by square-and-multiply (6.2); computing from is the DLP, for which no efficient algorithm is known in well-chosen groups. This asymmetry—a bijection cheap in one direction and expensive in the other—is the one-wayness on which elliptic-curve cryptography rests.
Two generic algorithms solve the DLP in any group of order , using nothing but the group operation. Baby-step giant-step is deterministic: set and write the unknown as with ; tabulate the “baby steps” for all , then walk the “giant steps” for until one equals a tabulated , at which point gives . Both the table and the walk are , so the cost is time and space. Pollard’s rho (not developed here) is a randomised alternative with the same expected running time—on a heuristic analysis, made explicit in 10—but only space, and is what attackers would run in practice. In the other direction, Shoup’s theorem shows that group operations are necessary for any generic algorithm when is prime, so for generic attacks the square-root cost is exact. Reaching a -bit security level—no attack cheaper than operations—therefore requires . This is why the Pallas and Vesta scalar fields have prime order roughly bits long, targeting roughly -bit security (10). The qualifier generic matters: in sub-exponential index-calculus attacks exist, which exploit the ring structure of the integers behind the group, and this is why elliptic-curve groups—where no such attack is known—permit much smaller parameters than multiplicative groups of comparable security.
The next theorem makes the phrase “well-chosen” precise: if the group order is composite with small prime factors, the DLP falls apart into small pieces, and the Chinese Remainder Theorem—proved in this section for a purely arithmetic purpose—reassembles the pieces into the secret.
Let be cyclic of order , the distinct primes. The discrete logarithm in is computable by solving discrete logarithms in subgroups of prime order — of them for each —and combining the answers with the Chinese Remainder Theorem, at a total cost of
group operations. When has a large prime factor the term dominates; when is smooth—a product of primes bounded polynomially in —every term is polynomial in and the DLP is easy. Corollary 7.24 draws the design consequence.
Let with the unknown. The reduction has two stages.
Stage (a): splitting across coprime factors. For each set and project:
By Corollary 3.23, , so generates the unique subgroup of of order (Theorem 3.24(3)). Moreover , and since has order , the exponent matters only modulo (Proposition 3.12(2)): writing ,
Solving the smaller DLPs yields for every ; since the prime powers are pairwise coprime, the Chinese Remainder Theorem (Theorem 7.2, iterated across the factors as in the proof of Corollary 7.3) determines modulo uniquely. Each projection costs operations by square-and-multiply.
Stage (b): lifting a prime power digit by digit. Fix one prime power (dropping the subscript ), with of order and , . Write in base :
The element has order (Corollary 3.23 again). Raise to the power : every digit beyond the first is multiplied by a multiple of in the exponent and vanishes, leaving
a single DLP in the group of prime order , which baby-step giant-step (Remark 7.22) solves in operations. With in hand, strip them off and repeat: the element equals raised to , so
and digit is again one order- DLP. Each of the digits costs one such DLP plus operations for the exponentiations.
Summing over the digits of all the prime-power factors gives order- DLPs at apiece plus bookkeeping for each, which is the stated bound. □
If has a small prime factor , an attacker can recover the discrete logarithm modulo in group operations— to project into the order- subgroup and for the small DLP there—leaking part of the secret . Security therefore requires to have a large prime factor; the safest and simplest choice is to make itself a large prime, so that has no proper nontrivial subgroups and the Pohlig–Hellman reduction offers no purchase at all. This is precisely why the elliptic-curve groups used in Halo 2 and Orchard have large prime order.
For the first claim, run stage (a) of Theorem 7.23 for the single factor : the projections , cost operations, and the resulting DLP in a group of order costs by baby-step giant-step—yielding . For the second, if is prime then has no subgroups besides and (Corollary 3.34), so the reduction’s only output is the original problem, and the generic floor of Remark 7.22 stands at full height. □
In practice an elliptic curve over has group order , where is a large prime and is a small cofactor, and cryptographic operations stay confined to the subgroup of prime order . If a protocol neglects to check that incoming points lie in that subgroup (or fails to clear the cofactor), an adversary can supply a point of low order and run Pohlig–Hellman in the small factor to extract information about the secret modulo —a real-world small-subgroup attack. The Pasta curves of Halo 2 have cofactor : their group orders are themselves prime (the primes recorded in 10), which eliminates this class of attacks at the level of the group itself rather than by protocol-level checks.
The two demands with which the section opened are now both met. A receiver handed a compressed point decides in one modular exponentiation whether is a square—Euler’s criterion—and, when it is, extracts a root by Proposition 7.17 or by Tonelli–Shanks (Theorem 7.19), the transmitted bit selecting between the pair (Remark 7.20); for the Pasta fields, with their deliberately large -adic valuation , Tonelli–Shanks is the deployed route. On the security side, exponentiation runs in operations while its inverse, the discrete logarithm, costs any generic attacker —a floor that composite group orders would undermine through Pohlig–Hellman, and that the prime, roughly -bit orders of the Pasta groups preserve in full, with no small subgroup left to attack. The structure of for a large prime thus supplies both the functionality—a field of scalars acting on the group—and the security of the constructions built on it. The curves themselves, and the primes and that this section has treated as black boxes, are the business of 10.