Enjoying Wikipedia Content? DONATE TO WIKIPEDIA

## Key establishment protocol

The following example illustrates how a shared key is established. Suppose Alice wants to establish a shared key with Bob, but the only channel available for them may be eavesdropped by a third party. Initially, the domain parameters (that is, ${\displaystyle (p,a,b,G,n,h)}$ in the prime case or ${\displaystyle (m,f(x),a,b,G,n,h)}$ in the binary case) must be agreed upon. Also, each party must have a key pair suitable for elliptic curve cryptography, consisting of a private key ${\displaystyle d}$ (a randomly selected integer in the interval ${\displaystyle [1,n-1]}$) and a public key represented by a point ${\displaystyle Q}$ (where ${\displaystyle Q=d\cdot G}$, that is, the result of adding ${\displaystyle G}$ to itself ${\displaystyle d}$ times). Let Alice's key pair be ${\displaystyle (d_{\text{A}},Q_{\text{A}})}$ and Bob's key pair be ${\displaystyle (d_{\text{B}},Q_{\text{B}})}$. Each party must know the other party's public key prior to execution of the protocol.

Alice computes point ${\displaystyle (x_{k},y_{k})=d_{\text{A}}\cdot Q_{\text{B}}}$. Bob computes point ${\displaystyle (x_{k},y_{k})=d_{\text{B}}\cdot Q_{\text{A}}}$. The shared secret is ${\displaystyle x_{k}}$ (the x coordinate of the point). Most standardized protocols based on ECDH derive a symmetric key from ${\displaystyle x_{k}}$ using some hash-based key derivation function.

The shared secret calculated by both parties is equal, because ${\displaystyle d_{\text{A}}\cdot Q_{\text{B}}=d_{\text{A}}\cdot d_{\text{B}}\cdot G=d_{\text{B}}\cdot d_{\text{A}}\cdot G=d_{\text{B}}\cdot Q_{\text{A}}}$.

The only information about her key that Alice initially exposes is her public key. So, no party except Alice can determine Alice's private key (Alice of course knows it by having selected it), unless that party can solve the elliptic curve discrete logarithm problem. Bob's private key is similarly secure. No party other than Alice or Bob can compute the shared secret, unless that party can solve the elliptic curve Diffie–Hellman problem.

The public keys are either static (and trusted, say via a certificate) or ephemeral (also known as ECDHE, where final 'E' stands for "ephemeral"). Ephemeral keys are temporary and not necessarily authenticated, so if authentication is desired, authenticity assurances must be obtained by other means. Authentication is necessary to avoid man-in-the-middle attacks. If one of either Alice's or Bob's public keys is static, then man-in-the-middle attacks are thwarted. Static public keys provide neither forward secrecy nor key-compromise impersonation resilience, among other advanced security properties. Holders of static private keys should validate the other public key, and should apply a secure key derivation function to the raw Diffie–Hellman shared secret to avoid leaking information about the static private key. For schemes with other security properties, see MQV.

If Alice maliciously chooses invalid curve points for her key and Bob does not validate that Alice's points are part of the selected group, she can collect enough residues of Bob's key to derive his private key. Several TLS libraries were found to be vulnerable to this attack.[4]

The shared secret is uniformly distributed on a subset of ${\displaystyle [0,p)}$ of size ${\displaystyle (n+1)/2}$. For this reason, the secret should not be used directly as a symmetric key, but it can be used as entropy for a key derivation function.

### Discover more about Key establishment protocol related topics

Source: "Elliptic-curve Diffie–Hellman", Wikipedia, Wikimedia Foundation, (2023, January 29th), https://en.wikipedia.org/wiki/Elliptic-curve_Diffie–Hellman.