liveBook · Manning

Euclid's algorithm

As explained in Elliptic Curve Cryptography for Developers

The Euclidean algorithm computes the greatest common divisor of two elements by repeatedly replacing a pair with the divisor and remainder.

Euclid’s algorithm repeatedly divides polynomials, retaining each remainder until the remainder degree is smaller than the divisor. It supplies quotient and remainder routines for polynomial arithmetic over finite fields, including elliptic-curve extension fields. section 10.0 section 10.1

A polynomial division pass follows this execution flow:

  • Initialize the remainder r to a and the quotient q to zero. section 10.1
  • While deg(r) ≥ deg(b), divide the leading coefficients, place the result at degree deg(r) − deg(b), and subtract the shifted multiple of b. section 10.1
  • Stop when the remainder degree is lower than the divisor; the remaining r is the division remainder. section 10.1 section 10.3
  • For the polynomial gcd, repeatedly replace the higher-degree argument with the lower-degree argument and the remainder, handling zero inputs first. section 10.1
Figure 10.1 Polynomial Euclid’s algorithm, which is the guts of inversion in elliptic curve pairing algorithms.
figure

Use the flow diagram to connect degree comparisons, leading-coefficient division, shifted subtraction, and termination. section 10.1

The low-level C routine separates initialization, the degree-checked main loop, temporary-polynomial subtraction, and cleanup. An extra r-degree check handles division by a degree-zero polynomial. section 10.3

The extended form feeds quotient and remainder data into polynomial inversion. It tracks prior values, normalizes remainders, and stops when the remainder becomes one; division modulo an irreducible polynomial then becomes inversion followed by multiplication. section 10.5 section 10.8

How Elliptic Curve Cryptography for Developers covers it

How deep it goes
Descends from quotient-and-remainder notation to coefficient-level C loops, edge checks, gcd iteration, and extended inversion.
Examples
Demonstrates simple polynomial divisions, degree-based equations, a C division routine, and an inversion main loop.
What it assumes
Assumes polynomial addition and multiplication while teaching degree comparison, leading coefficients, division flow, and remainder-based gcd from implementation details.
What you can do after
Build it from scratch as a polynomial quotient-remainder routine and use it to implement gcd and modular inversion.
How it connects
Connects polynomial division, greatest common divisors, irreducible polynomials, finite fields, elliptic curves, and the extended Euclidean algorithm.

Also explained in

Compare how 3 books explain Euclid's algorithm →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elliptic Curve Cryptography for Developers. The section links point to the parts of the book it draws on.