Saltar al contenido
ecdsa.com

Laboratorio de ML-KEM online: Kyber, X-Wing y el híbrido X25519MLKEM768

Encapsula un secreto compartido para una clave pública ML-KEM, X-Wing o híbrida de TLS y vuelve a desencapsularlo; cada parte de la clave, del texto cifrado y del secreto aparece etiquetada. Pega un key share capturado de un ClientHello o un ServerHello para desglosarlo, o invierte un bit de un texto cifrado para ver el rechazo implícito de ML-KEM.

100 % local: las claves, la aleatoriedad y los secretos compartidos se quedan en tu navegador; el motor se ejecuta en un Web Worker cargado desde este sitio y no envía nada a ninguna parte

X25519MLKEM768 de un vistazo

Definido en
RFC 10024
Categoría de seguridad del NIST
3
Clave de encapsulación (key share del cliente)
1216 bytes
Texto cifrado (key share del servidor)
1120 bytes
Secreto compartido
64 bytes
Grupo de TLS (NamedGroup)
0x11ec (registrado en la IANA)
ID de KEM de HPKE
ninguno
OID de X.509
ninguno
Clave de encapsulación / key share del cliente
AlgoritmoTamaño
X25519MLKEM768
1216 bytes38× X25519
X25519
32 bytes
ECDH P-256
65 bytes
ECDH P-384
97 bytes
Texto cifrado / key share del servidor
AlgoritmoTamaño
X25519MLKEM768
1120 bytes35× X25519
X25519
32 bytes
ECDH P-256
65 bytes
ECDH P-384
97 bytes

Un handshake TLS 1.3 transporta 2336 bytes para este intercambio de claves, frente a los 64 de X25519. En X25519 y ECDH, el «texto cifrado» es la clave pública efímera (puntos sin comprimir para P-256 y P-384).

Qué hacer

1 · Destinatario: par de claves

Formato de clave
Privada: se queda en este navegador y nunca va en enlaces para compartir

2 · Remitente: encapsular

Déjalo vacío: se genera aleatoriedad nueva. Solo se rellena para reproducir un vector de prueba; quien conozca este valor conoce el secreto.

3 · Destinatario: desencapsular

Key encapsulation in three steps

A key encapsulation mechanism agrees on a secret in one round trip. The recipient generates a key pair and publishes the encapsulation key. The sender runs Encaps on it and gets two values: a ciphertext to send and a shared secret to keep. The recipient runs Decaps on the ciphertext with the decapsulation key and arrives at the same secret. The lab walks through exactly these three steps, with every value labelled and sized.

ML-KEM is the KEM NIST standardized in FIPS 203 on 13 August 2024, derived from CRYSTALS-Kyber. FIPS 203 changed Kyber in small ways, so round-3 Kyber and ML-KEM do not interoperate. It has three parameter sets. ML-KEM-768, the one TLS uses, has an encapsulation key of 1,184 bytes and a ciphertext of 1,088 bytes; X25519 needs 32 bytes for each. The shared secret is 32 bytes in every set.

The hybrids TLS 1.3 actually sends

Browsers did not switch to ML-KEM alone. They negotiate a hybrid: the client sends an ML-KEM encapsulation key and an ECDH public key in one key share, the server answers with an ML-KEM ciphertext and its own ECDH key, and both secrets go into the key schedule. The connection stays confidential as long as either algorithm holds, which is the point while ML-KEM is young. RFC 10024 (August 2026) defines three such groups:

GroupCode pointClient shareServer shareSecretOrder
X25519MLKEM7680x11EC1,216 B1,120 B64 BML-KEM first
SecP256r1MLKEM7680x11EB1,249 B1,153 B64 BECDH first
SecP384r1MLKEM10240x11ED1,665 B1,665 B80 BECDH first

The order is the detail that breaks home-grown implementations: X25519MLKEM768 puts the ML-KEM part first in the client share, the server share and the shared secret, against the order its name suggests, for historical reasons. The NIST-curve groups put the ECDH part first, and use only the x-coordinate of the ECDH result. The lab shows the byte ranges of each part, so a key share captured with Wireshark or openssl s_client -trace can be checked against the RFC: paste it in "Take apart a TLS key share", with or without its four-byte group and length header.

The lab also runs X-Wing (draft-connolly-cfrg-xwing-kem-11), a hybrid designed as a single KEM: ML-KEM-768 and X25519 combined through SHA3-256 into one 32-byte secret, with a 32-byte seed as its whole private key. It is registered as HPKE KEM 0x647A and has an OID, but it is still an Internet-Draft, and its TLS code point is only requested.

What the lab checks

  • Encapsulation keys. FIPS 203 §7.2 requires a type check (the length) and a modulus check: every 12-bit coefficient of the key must already be reduced modulo 3329. A key that fails is rejected before encapsulation, as a conforming peer would reject it. For hybrids, the ECDH half is checked too: X25519 small-order points, which force an all-zero secret, and P-256 or P-384 points off the curve or not in uncompressed form, as RFC 8446 requires.
  • Decapsulation keys. FIPS 203 §7.3: the stored hash of the encapsulation key must match, and a pairwise test encapsulates and decapsulates once. Keys in PKCS #8 follow RFC 9935, where a private key can be the 64-byte seed, the expanded key or both; when both are present, they must agree, including the implicit-rejection secret z that a pairwise test alone would miss.
  • Implicit rejection. Decaps never reports a damaged ciphertext. It returns a pseudo-random value derived from the secret z and the ciphertext instead, so an attacker learns nothing from error messages. Flip one bit of the ciphertext and decapsulate: the lab detects that this happened and shows that the two sides now hold different secrets.

Known-answer examples

The ML-KEM examples are NIST ACVP-Server encapsulation tests. Each carries the 32-byte encapsulation randomness m, so the lab's Encapsulate reproduces the expected ciphertext and shared secret byte for byte. The hybrid examples join the ML-KEM-768 or ML-KEM-1024 test with the X25519 vector of RFC 7748 §6.1 or the P-256 and P-384 vectors of RFC 5903, in the order RFC 10024 prescribes. The X-Wing example is Appendix C of its draft. Supplying randomness is for test vectors only. Whoever knows it knows the secret, so the field is never put into a share link.

Further reading

How the hybrid fits into the TLS 1.3 handshake, and who enables it by default, is covered in X25519MLKEM768 explained and shown byte by byte in the illustrated post-quantum handshake. X25519MLKEM768 vs X25519 weighs the cost. To check what your own browser negotiates, use the browser post-quantum check; to use ML-KEM for encrypting data rather than for a handshake, try the HPKE playground.