← Cryptography guide

K040 / Asymmetric encryption, signatures and key exchange

X25519

X25519 Curve25519 · Survey date 2026-12-05

X25519 is a key-exchange method using point operations on the Curve25519 elliptic curve.

CRYPTOGRAPHY LAB / K040

Cryptography Lab · X25519

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.

Scope: Standard operation

X25519 (RFC 7748 Montgomery ladder)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
X25519 is a key-exchange method using point operations on the Curve25519 elliptic curve. Source document ↗
Classification and reversibility
Asymmetric DH/ECDH key-exchange primitive computing shared secret from private and peer public key, not ciphertext decryption or encoding. Source document ↗
Key or secret requirements
Uses a 32-byte secret key, derives a 32-byte public key and needs peer public key. Source document ↗
Operating principle and structure
Multiply Curve25519 point P by private scalar for public key, then peer public key by own scalar to obtain same shared secret. Source document ↗
Key size, block size and parameters
Curve25519 parameters p=2^255−19, A=486662, cofactor 8, base u=9. Source document ↗
Security strength and recommendation
No practical classical key-exchange break recorded, but quantum migration planning is needed. Source document ↗
Known attacks and vulnerabilities
Vulnerable to Shor's algorithm on quantum computers. Source document ↗
Standards and certification
Added to NIST FIPS 186-5/SP 800-186; related to IETF RFC 7748/8032 standards. Source document ↗
Typical uses
TLS 1.3 key exchange and session-key agreement in HTTPS/messaging. Source document ↗
Implementations, libraries and tools
Monocypher provides crypto_x25519() for X25519 exchange. Source document ↗
Decryption or decoding
No decryption/decoding in X25519 itself; derive key from shared secret via KDF for symmetric decryption. Source document ↗
Advantages
Fast among ECC methods, no known patents, public-domain reference implementation. Source document ↗
Limitations and cautions
Raw ECDH alone lacks peer authentication and key derivation; requires authentication protocol and KDF. Source document ↗
Distinguishing encryption, encoding and hashing
X25519 is DH key exchange, not encryption, hash or encoding; pass shared secret through KDF. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Alice and Bob generate X25519 key pairs, exchange public keys and compute the same shared secret with own private and peer public key. Derive session keys via KDF and protect actual data using AEAD.

Procedure

Generate key pairs, authenticate/exchange public keys, compute X25519 shared secret, derive purpose-specific keys via KDF, encrypt/decrypt with AEAD. Key exchange is not decryption; Base64/UTF-8 encoding is separate.

Scenario

Used for TLS 1.3 ephemeral ECDH session keys, end-to-end messaging with X25519+HKDF+AEAD, backup/device key agreement; design authentication and derivation layers together.

Pitfalls and alternatives

Use KDF instead of raw secret as encryption key. Raw ECDH without peer authentication risks MITM; use vetted protocols. Consider post-quantum hybrid migration; distinguish X25519 from encryption, hashing and encoding.

Diagram source ↗

References