liveBook · Manning

Prime number

As explained in Real-World Cryptography

A prime number is an integer greater than one with no positive divisors other than one and itself, used in finite-field Diffie-Hellman as the modulus.

A prime number is an integer greater than one divisible only by 1 and itself. The first examples are 2, 3, 5, 7, and 11. In Diffie-Hellman (DH), a large prime supplies the modulus for the multiplicative group of integers from 1 through p−1. section 5.2.1

The size and quality of p matter. DH security depends on the discrete logarithm problem, so larger parameters provide more security against known attacks. Cryptographic libraries may use probable primes to accelerate generation, but faulty prime generation has caused serious vulnerabilities, including ROCA in 2017. section 5.2.1 section 5.2.3

Practical DH parameter guidance includes:

  • Use a sufficiently large prime; 2,048-bit p is identified as current best practice. section 5.2.3
  • Prefer carefully specified groups such as those in RFC 7919 rather than ad hoc or blindly trusted parameters. section 5.2.3
  • Remember that even standardized groups can be broken: historical DH parameters in Socat and RFC 5114 caused concern. section 5.2.3

A clock that wraps around

With modulus 5, arithmetic wraps around: 5 becomes 0, 6 becomes 1, 7 becomes 2, and 10 becomes 0. This illustrates the modular arithmetic used with a prime modulus in DH. section 5.2.1

Figure 5.5 The group of integers modulo the prime number 5 can be pictured as a clock that resets to 0 after the number 4. Thus 5 is represented as 0, 6 as 1, 7 as 2, 8 as 3, 9 as 4, 10 as 0, and so on.

Use the clock diagram to visualize how integers wrap around modulo the prime number 5. section 5.2.1

How Real-World Cryptography covers it

How deep it goes
Defines primality, relates size to discrete-logarithm security, and stops short of proving primality or deriving DH attacks.
Examples
Uses small primes, a modulus-5 clock, probable-prime generation, ROCA, and historical broken DH parameter sets.
What it assumes
Assumes familiarity with Diffie-Hellman and groups while introducing prime numbers and modular arithmetic through small examples.
What you can do after
Configure DH with appropriately sized, carefully specified prime groups and recognize risks from faulty parameter generation.
How it connects
Connects prime numbers to group theory, modular arithmetic, Diffie-Hellman, discrete logarithms, and elliptic-curve Diffie-Hellman.

Also explained in

Compare how 5 books explain prime number →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Real-World Cryptography. The section links point to the parts of the book it draws on.