K039 / Asymmetric encryption, signatures and key exchange
ECDH
ECDH is a key-agreement protocol using elliptic-curve key pairs to establish a shared secret between two parties.
CRYPTOGRAPHY LAB / K039
Cryptography Lab · ECDH
Run real computations and inspect intermediate states step by step.
Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.
ECDH (toy curve y²=x³+2x+2 mod 17)
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- ECDH is a key-agreement protocol using elliptic-curve key pairs to establish a shared secret between two parties. Source document ↗
- Classification and reversibility
- Asymmetric key agreement/exchange, not direct data encryption or decryption. Source document ↗
- Key or secret requirements
- Each party keeps its EC private key secret and sends only the public key. Source document ↗
- Operating principle and structure
- Compute public key nG from private scalar n and public curve generator G; scalar-multiply peer public key to obtain shared secret. Source document ↗
- Key size, block size and parameters
- Common key/curve sizes include 256, 384 and 521 bits. Source document ↗
- Security strength and recommendation
- NIST equates 256-bit elliptic curve strength roughly to 3072-bit finite-field strength. Source document ↗
- Known attacks and vulnerabilities
- Ephemeral-ephemeral/plain ECDH is anonymous and vulnerable to MITM; authentication is needed. Source document ↗
- Standards and certification
- NIST standardized ECC and key establishment in FIPS 186 and SP 800-56A. Source document ↗
- Typical uses
- Used to obtain a shared secret for key material or derivation of other keys. Source document ↗
- Implementations, libraries and tools
- Libraries such as eciesjs implement ECDH/ECIES. Source document ↗
- Decryption or decoding
- Use ECDH-derived symmetric key with AES-256-GCM or similar for data encryption/decryption. Source document ↗
- Advantages
- 256-bit curve comparable to 3072-bit finite field, providing equivalent security with smaller parameters. Source document ↗
- Limitations and cautions
- Plain ECDH must be authenticated with signature schemes such as ECDSA/RSA. Source document ↗
- Distinguishing encryption, encoding and hashing
- ECDH is key agreement, not encryption, encoding or hashing; encrypt actual data through a symmetric hybrid scheme. Source document ↗
Practical examples
Example
A and B generate ephemeral EC key pairs and exchange public keys only. Each computes identical shared secret with own private/peer public key, derives session key via KDF and uses AEAD for messages.
Procedure
Choose curve/domain parameters and authentication; generate ephemeral pairs, exchange/validate public keys; compute shared secret; derive symmetric key via KDF; encrypt/decrypt using AEAD. ECDH itself has no decryption.
Scenario
TLS/QUIC uses ephemeral ECDHE to agree session keys. ECIES/HPKE combines receiver public key and sender ephemeral key for hybrid file/message encryption. Use vetted ECDH+KDF+AEAD patterns.
Pitfalls and alternatives
Unauthenticated plain/static ECDH risks MITM; use ECDHE with signatures/TLS 1.3 or HPKE/ECIES. Do not skip KDF; avoid ephemeral key reuse, unvalidated parameters and obsolete curves. Distinguish Base64 from encryption.
References
- Elliptic-curve Diffie–Hellman ↗
- ECC Encryption / Decryption | Practical Cryptography for Developers ↗
- Diffie‒ ↗
- Elliptic Curve Cryptography ↗
- What are the steps involved in the Elliptic Curve Diffie-Hellman (ECDH) key exchange protocol? - EITCA Academy ↗
- Elliptic curve Diffie-Hellman key exchange ↗
- Elliptic Curve Diffie-Hellman - Crypto++ Wiki ↗
- Elliptic Curve Cryptography | CSRC ↗
- eciesjs | js ↗
- Mechanism and Implementation in JavaScript | js ↗