Post-quantum key generator: try an ML-KEM shared secret

  • Free
  • No sign-up
  • Runs in your browser
  • Version 1.0.0
  • Last updated 2026-12-04
Report a problem

Generate a NIST-standard ML-KEM key pair and follow how a public-key holder and a secret-key holder arrive at the same 32-byte shared secret.

Treat the secret key and shared secrets like passwords. This page does not store or upload them.

1. Generate key pair

2. Encapsulate shared secret

3. Recover shared secret

Everything you enter is processed in your browser and is never sent to a server.

How to use

  1. Choose a parameter set and generate a key pair. ML-KEM-768 is selected initially as a balanced default.
  2. Use the public key to encapsulate a shared secret. This produces a ciphertext and the sender's shared secret; the shared secret is not sent to the recipient.
  3. Recover the shared secret with the ciphertext and secret key. Check that both values match, then clear the secret values when you are done.

Examples

Generate an ML-KEM-768 key pair, encapsulate and decapsulate
→ An 1184-byte public key, 2400-byte secret key, 1088-byte ciphertext and matching 32-byte shared secrets
The screen uses Base64, so the displayed character counts are longer than the byte sizes.
Generate ML-KEM-512 keys, switch to ML-KEM-1024 and paste the old key
→ An error saying that the value has the wrong length
Keys and ciphertexts only work with the same parameter set.

How it works

ML-KEM is a key-encapsulation mechanism, or KEM. The recipient creates a public and secret key and sends only the public key. The sender uses it to create a ciphertext and a shared secret. The recipient combines that ciphertext with the secret key to recover the same shared secret. The shared secret itself does not cross the network.

This page represents keys and ciphertexts as Base64 so they can be copied as text. Base64 is not encryption; it is only a text representation of binary data. Do not paste a secret key or shared secret into public documents, chats or issue reports.

ML-KEM does not identify the other party on its own. Preventing a man-in-the-middle attack requires an authenticated public key, a digital signature or an already authenticated channel. A matching result here confirms the calculation chain, not anybody’s identity.

Sources

Frequently asked questions

Can this tool encrypt a file?
No. ML-KEM does not directly encrypt files. It lets two parties establish a shared secret. A real protocol derives a symmetric key from that secret and uses authenticated encryption such as AES-GCM for the data.
Should I choose ML-KEM-512, 768 or 1024?
Larger parameter sets provide a higher security strength with larger keys and ciphertexts. ML-KEM-768 is a balanced choice for this demonstration. Production systems should follow the relevant protocol and threat model.
Does decapsulation reject every bad ciphertext?
Not necessarily. ML-KEM uses implicit rejection and can return a different shared secret for an invalid or mismatched ciphertext. A protocol still needs sender authentication and authenticated messages.
Can I use a generated secret key in production?
This page is for learning and interoperability checks. Production use also needs a reviewed protocol, protected key storage, lifecycle management, authentication and side-channel defenses. A pure JavaScript implementation alone does not provide those guarantees.
Are the keys or shared secrets uploaded?
No. Generation and calculation stay in this browser. Browser extensions, screen sharing, clipboard history and downloaded key files can still expose secrets outside the page.
Version history
  • 1.0.0 — First release.

Last updated: