liveBook · Manning

Fermat’s Little Theorem

Fermat’s Little Theorem states that for a prime p and integer a not divisible by p, a^(p−1) is congruent to 1 modulo p.

How 2 Manning books explain it

Elliptic Curve Cryptography for Developers

Fermat's little theorem states that a number raised to the appropriate power modulo a prime satisfies a fixed congruence, and its field-extension analogue gives the corresponding finite-field exponent relation.

How it is used
Powers modular square-root tests, prime-field square-root algorithms, and exponent calculations in finite-field extensions.
How deep it goes
Defines the congruence and translates it into direct exponentiation and Tonelli–Shanks, with detailed code but no proof.
Examples
Uses square roots modulo 23 and polynomial powers modulo x² + x + 3 over the prime 43.
What you can do after
Apply modular exponentiation to test residues, compute selected square roots, and verify extension-field powers.

Read how Elliptic Curve Cryptography for Developers explains Fermat’s Little Theorem →

Hacking Cryptography

Fermat's little theorem states that for a prime p, every integer a not divisible by p satisfies a^(p−1) ≡ 1 modulo p.

How it is used
Supports probabilistic primality testing before generating large asymmetric-key numbers.
How deep it goes
Derives equivalent congruences and explains randomized testing, but stops short of a guaranteed primality method.
Examples
Uses equations 8.3 and 8.4, random candidate bases, and Carmichael numbers as a failure case.
What you can do after
Apply it via a probabilistic primality test that rejects candidates after one failed congruence.

Read how Hacking Cryptography explains Fermat’s Little Theorem →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.