Agree on a value without exchanging private exponents
We only use the insecure teaching case p=23,q=11,g=2 with integer exponents 1…10. Parameters,A and B are public; a and b remain private. The shared residue is not a derived session key. The historical RFC supports the algebra, not a recommendation of its older supplementary algorithms.[1]
Understand the calculation
- Publicly agree on prime p and a generator g of a suitable subgroup. In the teaching case p=23,q=11,g=2, g11 mod23=1 and g≠1.
- Privately choose a or b and publish only A=gᵃ mod p and B=gᵇ mod p.
- One side computes Bᵃ mod p; the other computes Aᵇ mod p. Exponent laws give gᵃᵇ mod p on both sides.
- The result is initially a shared group residue. Practical protocols also need secure parameters, authentication and suitable key derivation; these small numbers provide no protection.
Public values and shared residue[1]
Visualize the learning idea
The same residue through two calculations
Free with a Quanta account. Your download stays ready after registration.
Two fully checked examples
Exchange public values
- Given
- Public p=23,q=11,g=2. Private a=6,b=7.
- Find
- Calculate A,B and the same shared residue on both sides.
Compute public modular powers for exchange.
The first side raises the received value to its private exponent.
The other side uses its own private exponent.
Result: Both obtain Z=6. They exchanged A=18 and B=13, not private exponents.
Check: 242 mod23=29 mod23=512 mod23=6 because the generator has order 11.
Check exponent laws with different exponents
- Given
- Same public teaching parameters; a=3,b=4.
- Find
- Check a second complete exchange.
Calculate A and B.
The two modular powers share the same unreduced value here.
Divide by p and retain the remainder.
Result: Both sides obtain Z=2, a group residue rather than a fully derived session key.
Check: ab=12≡1 mod11, so 2ᵃᵇ mod23=21 mod23=2.
Recall the method later with the formula’s flashcards.
11 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Interpret the quantities
All values are integer residues without a physical unit. The RSA teaching calculation also uses modular exponentiation but solves a different task. Shared arithmetic does not make their key roles or protocols interchangeable.
Five solved exercises
Calculate · Foundation
Teaching parameters p=23,g=2,a=1,b=5: find A,B,Z.
Show hint
With a=1, the received residue remains unchanged.
Learning goal: Calculate both exchange paths.
Show solution and calculation
A=2,B=25 mod23=9,Z=91 mod23=9.
Other side: A5 mod23=9.
Rearrange · Application
Explain symbolically why (gᵃ)ᵇ and (gᵇ)ᵃ have the same residue.
Show hint
Use exponent laws and ab=ba.
Learning goal: Separate correctness from the inverse problem.
Show solution and calculation
Both equal gᵃᵇ modulo p.
This proves agreement but gives no general efficient method from public A back to private a.
Interpret · Foundation
Is Z itself an encrypted message?
Show hint
Separate agreement from message encryption.
Learning goal: Identify the purpose of key agreement.
Show solution and calculation
No.
Z is a shared group residue.
A complete protocol derives key material and subsequently uses appropriate encryption and integrity mechanisms.
Error analysis · Application
For a=3,b=4, someone claims Z=2ᵃ+ᵇ mod23=13.
Show hint
Nested powers multiply exponents.
Learning goal: Distinguish addition from multiplication of exponents.
Show solution and calculation
Incorrect: Z=2ᵃᵇ mod23=212 mod23=2.
Exponents are not added in nested powers.
Transfer · Challenge
Does algebraic agreement alone authenticate the other participant?
Show hint
Consider exchanged public values without identity evidence.
Learning goal: Recognize a real protocol requirement.
Show solution and calculation
No.
Without authentication, an attacker can substitute public values and establish separate agreements.
Practical protocols must bind the values to expected identities.
Check your understanding with the formula’s reference test.
8 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Limits and connections
Agreement of both calculation paths proves correctness, not secure parameters or authentication. This calculator does not generate production keys or process real secrets; it only demonstrates the explicitly fixed teaching numbers.
The upper formula reference also contains the insecure hand example p=23,g=5,a=6,b=15, with A=8,B=19 and shared residue 2. There g=5 has order 22; this is a different parameter set from the order-11 subgroup generated by g=2. The calculator and both detailed article examples explicitly retain the fixed-subgroup case. Do not transfer its exponent limits or reduction modulo 11 to the g=5 example.[1]
Sources for this explanation
Quanta · Updated November 21, 2026
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Distinguished the alternate upper hand example from the fixed-subgroup calculator and made numeric MC arithmetic readable.
- Expanded a fixed prime-order teaching model with both exchange paths, integer modular arithmetic and explicit protocol limits.
Cite this reference page
Quanta. Diffie–Hellman key exchange (teaching model). Updated November 21, 2026. https://quanta-study.de/en/formula-sheet/diffie-hellman-schluesselaustausch
When citing a specific scientific statement, also cite the specialist source linked to that statement.