Diffie-Hellman starts with public arithmetic parameters. This lesson pins the tiny prime and generator before any secrets appear.

highlighted = computed this step

Why parameters are public

Diffie-Hellman starts with a prime modulus and a generator. These values are public, so both sides can compute in the same arithmetic space.

p,g publicp,g\ \text{public}
Public parametersDiffie-Hellman exchange values recomputed from the toy modulus.Public parameters - shared=2quantityvaluep23g5a (secret)6A=g^a mod p8b (secret)15B=g^b mod p19shared=B^a=A^b2A^b mod p2

Pin p and g

The toy prime is p=23, and the generator is g=5.

p=23,g=5p=23,\quad g=5
Public parametersDiffie-Hellman exchange values recomputed from the toy modulus.Public parameters - shared=2quantityvaluep23g5a (secret)6A=g^a mod p8b (secret)15B=g^b mod p19shared=B^a=A^b2A^b mod p2

Why a tiny modulus is inspectable

Because p is small, every modular exponentiation row can be displayed and checked. That makes the toy useful for learning and useless for security.

small p means checkable, not secure\text{small p means checkable, not secure}
Public parametersDiffie-Hellman exchange values recomputed from the toy modulus.Public parameters - shared=2quantityvaluep23g5a (secret)6A=g^a mod p8b (secret)15B=g^b mod p19shared=B^a=A^b2A^b mod p2

Summary

The public parameters are p=23 and g=5. NOTE: toy-modulus; no-side-channel; no-production; never-roll-your-own. Exact arithmetic on a deliberately tiny toy modulus; real DH uses 2048+ bit groups inside authenticated reviewed protocols.

p,g publicp,g\ \text{public}
Public parametersDiffie-Hellman exchange values recomputed from the toy modulus.Public parameters - shared=2quantityvaluep23g5a (secret)6A=g^a mod p8b (secret)15B=g^b mod p19shared=B^a=A^b2A^b mod p2