Overview

2 Description of finite field mathematics

Finite fields are the mathematical setting that makes elliptic curve cryptography work, because they provide a closed system of values where addition, multiplication, and division all behave in a controlled way. The chapter builds that idea from the ground up using prime numbers as the modulus, showing how arithmetic wraps around just like a clock and why a prime modulus gives the structure needed for inverses. It also connects these abstract rules to the elliptic curve equation used throughout the book, emphasizing that the simplified form over finite fields is enough for cryptographic use.

From there, the text explains how points on an elliptic curve over a finite field form cyclic groups, sometimes with subgroups determined by the factors of the total number of points. This group structure is what allows practical cryptographic operations, since multiplying a point by certain factors moves it into predictable subsets. The chapter then shifts from theory to implementation, introducing reusable modular-arithmetic routines built on the GMP library so large integer computations can be performed reliably and consistently across the rest of the codebase.

A major focus is determining whether square roots exist modulo a prime and, if they do, computing them. The chapter defines quadratic residues and nonresidues, uses the Legendre symbol to test whether a square root is possible, and then presents two methods for extracting the root depending on the prime’s form: a direct exponentiation shortcut when the modulus is congruent to 3 mod 4, and the Tonelli-Shanks algorithm when it is congruent to 1 mod 4. The section closes by turning these ideas into code for square roots, modular division, modular exponentiation, and related helper routines, all of which support later elliptic curve operations.

Adding 6 + 9 modulo 12 and modulo 24
figure
Finite field over prime numbers viewed as a clock (\(p=43\))
figure
Compute square root mod p
figure

Summary

  • A finite field allows addition, multiplication, and inversion with every element to another element in the field.
  • Elliptic curve groups are finite fields consisting of points. The order of each point is some combination of the factors from the total number of points on the curve.
  • Subroutines to compute over prime fields include addition, subtraction, multiplication, inversion, and division. These routines will be used throughout the book.
  • A quadratic residue is an element in a finite field, which is a perfect square.
  • Computing square roots uses a power function for primes congruent to 3 mod 4 and Tonelli and Shanks algorithm for primes congruent to 1 mod 4.

FAQ

What is a finite field in the context of elliptic curve cryptography?A finite field is a set of numbers that can be added, multiplied, and divided, but only within a fixed number of elements. In this chapter, finite fields are built from prime numbers, and all arithmetic is done modulo that prime.
Why are prime numbers important for finite fields?Prime numbers are used to define prime fields because arithmetic modulo a prime always supports inverses for nonzero elements. That property makes the set behave like a field, which is essential for elliptic curve cryptography.
What does “congruent modulo n” mean?Two numbers are congruent modulo n if they give the same remainder when divided by n. For example, 15 is congruent to 3 modulo 12 because both represent the same position on a 12-hour clock.
Why does the book compare finite fields to clocks?The clock example shows how modular arithmetic “wraps around” after reaching the modulus. This makes it easy to understand addition in a finite field, such as 6 + 9 = 3 mod 12.
What is the simplified elliptic curve equation used in the book?The book uses the simplified form y² = x³ + a₄x + a₆. This is possible because the work is done over finite fields, so the general equation can be reduced to this shorter form.
Why do elliptic curves over finite fields form groups of points?The points on an elliptic curve over a finite field obey special algebraic rules that allow them to be organized into cyclic groups. These groups can also have subgroups depending on the factorization of the total number of points.
What does the modular division routine do if the divisor has no inverse?If the divisor cannot be inverted modulo n, the routine treats it as division by zero, prints an error message, and exits. This is a safeguard because valid modular division requires a multiplicative inverse.
What is a quadratic residue?A quadratic residue modulo p is a number that has a square root in that field. If no square root exists, the number is called a nonresidue.
How does the book determine whether a square root can be computed modulo p?The book uses the Legendre symbol, which indicates whether a number is a quadratic residue, zero modulo p, or a nonresidue. GMP provides a built-in routine for computing this test.
How is the square root modulo p computed in the book?If p ≡ 3 mod 4, the square root can be computed directly using exponentiation. If p ≡ 1 mod 4, the book uses the Tonelli and Shanks algorithm, which is more general and handles the harder case.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Elliptic Curve Cryptography for Developers Elliptic Curve Cryptography for Developers ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Elliptic Curve Cryptography for Developers Elliptic Curve Cryptography for Developers ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Elliptic Curve Cryptography for Developers Elliptic Curve Cryptography for Developers ebook for free