liveBook · Manning

Extended Euclidean algorithm

As explained in Elliptic Curve Cryptography for Developers

The extended Euclidean algorithm computes a greatest common divisor together with coefficients expressing it as a linear combination of the input elements.

The extended Euclidean algorithm computes a polynomial inverse by combining Euclidean division with coefficient updates. For polynomials irrd and b, it maintains t · b = r; when r becomes 1, t is the inverse of b modulo the irreducible polynomial irrd. section 10.2 section 10.8

A polynomial-inversion implementation follows this flow:

  • Initialize v = irrd, u = b, coefficient trackers w = 0, y = 0, and normalization data including y₀ = lc(b). section 10.2
  • Repeatedly divide v by u to obtain quotient q and remainder r, normalize r, and compute t = ρ(w − qy), where ρ = 1/lc(r). section 10.2
  • Shift the coefficient and remainder variables until r = 1; the resulting t satisfies t · b = 1 modulo irrd. section 10.2

Turning inversion into division

To divide polynomials modulo an irreducible polynomial, first compute 1/b with the extended algorithm, then multiply: a/b = a · (1/b). section 10.2 section 10.8

Equation 10.5
\[\begin{gathered} \begin{split} v \longleftarrow irrd\\ u \longleftarrow b\\ r \longleftarrow 0\\ w \longleftarrow 0\\ q \longleftarrow 0\\ t \longleftarrow 0\\ y_0 \longleftarrow lc(b) \end{split}\label{eainv1} \end{gathered}\]

Use the initialization equation alongside the loop equation to map each mathematical variable directly to an implementation state. section 10.2

How Elliptic Curve Cryptography for Developers covers it

How deep it goes
Derives initialization, quotient-remainder updates, normalization, termination, and the maintained invariant, but omits a full concrete computation.
Examples
Uses a simple polynomial inversion computation and the reduction of division to inversion followed by multiplication.
What it assumes
Assumes polynomial addition and multiplication, then builds polynomial division, normalization, gcd, and inversion incrementally.
What you can do after
Apply polynomial inversion modulo an irreducible polynomial and implement division as inversion followed by multiplication.
How it connects
Connects Euclidean division, greatest common divisors, irreducible polynomials, polynomial inversion, elliptic curves, and pairings.

Also explained in

Compare how 2 books explain extended Euclidean 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.