wire / wire-format / diffie-hellman
Diffie-Hellman (DH) is a key exchange protocol. Two parties agree on a public prime p and generator g. Alice sends A = g^a mod p. Bob sends B = g^b mod p. Both compute shared secret s = B^a = A^b = g^(ab) mod p. Eavesdropper sees g, p, A, B but cannot compute s (discrete logarithm problem). Finite field DH (FFDHE) and elliptic curve DH (ECDH/X25519) are the modern variants.
aka: Diffie-Hellman key exchange
spec: Diffie-Hellman (1976)
Diffie-Hellman (DH) is a key exchange protocol. Two parties agree on a public prime p and generator g. Alice sends A = g^a mod p. Bob sends B = g^b mod p. Both compute shared secret s = B^a = A^b = g^(ab) mod p. Eavesdropper sees g, p, A, B but cannot compute s (discrete logarithm problem). Finite field DH (FFDHE) and elliptic curve DH (ECDH/X25519) are the modern variants.
| field | size | meaning |
|---|---|---|
| Prime (p) | variable (2048+ bits) | Large prime modulus. Must be a safe prime (p = 2q+1 where q is also prime) for security. |
| Generator (g) | variable | Generator of the multiplicative group mod p. Usually 2 or 5. |
| Alice's private key (a) | variable | Random secret (256+ bits). |
| Alice's public key (A) | variable | A = g^a mod p. Sent to Bob. |
| Bob's private key (b) | variable | Random secret (256+ bits). |
| Bob's public key (B) | variable | B = g^b mod p. Sent to Alice. |
| Shared secret (s) | variable | s = B^a = A^b = g^(ab) mod p. Used as key material (after KDF). |
| X25519 (ECDH) | variant | Elliptic curve DH on Curve25519. 32-byte keys, 32-byte shared secret. Faster and simpler than FFDHE. |
example:
00 00
Diffie-Hellman (placeholder)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/diffie-hellman
or /wire-format/diffie-hellman.json