Diffie-Hellman is a simple public-key algorithm that enables two users to establish a secret key using a public-key scheme based on discrete logarithms.
- Principals share a prime number and an integer that is a primitive root of . Both and may be public, or could send them in the first message.
- and generate random numbers and both less than . (these are private keys)
- computes , computes . (these are public keys, also known as “Diffie-Hellman half keys”)
- and exchange and .
- computes , computes . (the keys are equal, i.e. )