Model public keys, shared secrets, and verification. Review steps with examples, charts, and export tools. Understand modular arithmetic outcomes through simple inputs and visuals.
Enter a prime modulus, a generator, and private exponents for Alice and Bob. The calculator returns public keys, shared secrets, and validation notes.
| Prime modulus (p) | Generator (g) | Alice private key (a) | Bob private key (b) | Alice public key (A) | Bob public key (B) | Shared secret |
|---|---|---|---|---|---|---|
| 23 | 5 | 6 | 15 | 8 | 19 | 2 |
| 29 | 2 | 11 | 7 | 18 | 12 | 17 |
| 31 | 3 | 9 | 14 | 29 | 14 | 16 |
Public key for Alice: A = ga mod p
Public key for Bob: B = gb mod p
Shared secret for Alice: S = Ba mod p
Shared secret for Bob: S = Ab mod p = gab mod p
Diffie Hellman relies on modular exponentiation. Alice and Bob publish A and B, then each side raises the received public value using its own private exponent.
Because Ba mod p and Ab mod p both reduce to gab mod p, both parties arrive at the same secret.
For standard classroom style setups, use a prime modulus p and a suitable generator g. A primitive root gives the widest nonzero residue coverage.
It computes Alice and Bob public keys, both shared secret values, generator checks, modulus status, multiplicative order, and a modular exponentiation graph.
A prime modulus supports the standard finite field version of Diffie Hellman. It makes generator analysis cleaner and helps create predictable subgroup behavior.
A primitive root is a generator whose powers produce every nonzero residue modulo a prime. It gives the largest possible cycle for the exchange.
Alice computes Ba mod p and Bob computes Ab mod p. Both expressions equal gab mod p, so the final secret matches.
This page is designed for educational and moderate integer examples. Very large production scale parameters usually need specialized big integer libraries and hardened implementations.
It is the smallest positive exponent k for which gk mod p equals 1. It describes the cycle length generated by g.
The graph shows how powers of the generator move through modular residues. It helps visualize cycles, repeats, and whether the chosen generator spreads broadly.
The private exponents must remain secret. Only the public keys are shared. Revealing the private values breaks the confidentiality of the derived secret.
Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.