ML-KEM encapsulation key vs ML-KEM decapsulation key: which key goes where

The ML-KEM encapsulation key is the public key that produces ciphertexts, and the decapsulation key is the secret key that recovers the shared secret. This page shows which side holds each, how large each is and where each appears.

On this page

Which ML-KEM key does the peer send, and which one do you keep?

If you have seen both ML-KEM encapsulation key and ML-KEM decapsulation key in a vendor document, a TLS capture or a key-handling spec, the first thing to settle is which one is public. In ML-KEM the encapsulation key is the public key, used to produce ciphertexts. The decapsulation key is the secret key, used to recover the shared secret, and it stays with its holder. Engineers configuring key storage and reviewers checking key handling both need this split, because it decides what can be shared, what must be protected and where each file belongs. The names appear in the Go crypto/mlkem package, where EncapsulationKey768 and EncapsulationKey1024 are the public types and DecapsulationKey768 and DecapsulationKey1024 are the secret types, and in draft-ietf-tls-mlkem-11, which describes the same roles in TLS.

In a TLS 1.3 key exchange using ML-KEM, the client's key share carries the encapsulation key and the server's key share carries the ciphertext. The decapsulation key therefore never leaves the client, and the server only ever holds the public key it receives. The draft also requires a server to run the FIPS 203 encapsulation key check on the client's key and abort with illegal_parameter if the check fails, so a malformed public key is rejected rather than used. Confirm this behavior in the TLS library and version you run, since the draft is a work in progress and implementations may differ in how they report the failure.

For storage, the two keys differ in size and in how they are encoded. Encapsulation key sizes are 800, 1184 and 1568 bytes for the three parameter sets, while expanded decapsulation keys are 1632, 2400 and 3168 bytes. RFC 9935 lets the private key be stored as a 64-octet seed, which it recommends as the most compact form, or as the expanded key, or both. OpenSSL 3.5 supports several of these formats and lists seed-priv first by default. Check which form your key store, HSM or backup tool expects before you move keys between systems, because a seed and an expanded key are not interchangeable without the matching input format.

Encapsulation key and decapsulation key side by side

This table sets the public encapsulation key against the secret decapsulation key for each ML-KEM parameter set, with sizes from draft-ietf-tls-mlkem-11 and the encodings defined in RFC 9935. Read each row across the three parameter sets to see how sizes grow, and confirm the seed option against the library you run. The main takeaway is that the encapsulation key is the part that travels to the peer, while the decapsulation key stays with the party that receives the ciphertext.

AttributeEncapsulation keyDecapsulation key
RolePublic key used to produce ciphertextsSecret key used to recover the shared secret
Who holds itSent to the peer, for example in a TLS 1.3 client key shareStays with the party that decapsulates, for example the TLS client
Size for ML-KEM-512800 bytes1632 bytes expanded
Size for ML-KEM-7681184 bytes2400 bytes expanded
Size for ML-KEM-10241568 bytes3168 bytes expanded
64-byte seed optionNot applicable, the public key is derived from the seedCan be generated from a 64-byte seed, which RFC 9935 recommends as the most compact form
Go crypto/mlkem typesEncapsulationKey768 and EncapsulationKey1024DecapsulationKey768 and DecapsulationKey1024
Defining documentsFIPS 203, draft-ietf-tls-mlkem-11 and RFC 9935 (SubjectPublicKey BIT STRING)FIPS 203, draft-ietf-tls-mlkem-11 and RFC 9935 (private key CHOICE)

What each key is for and where practitioners meet it

The encapsulation key is the public key in ML-KEM. The party that wants to establish a shared secret uses it to produce a ciphertext and the shared secret that goes with it. Go's crypto/mlkem package names the types EncapsulationKey768 and EncapsulationKey1024, and the same role applies to ML-KEM-512, whose key is 800 bytes. In a TLS 1.3 key exchange with ML-KEM, the encapsulation key is carried in the client share, so it is the value a server receives from the client and must check before using.

  • Sizes: The encapsulation key is 800 bytes for ML-KEM-512, 1184 bytes for ML-KEM-768 and 1568 bytes for ML-KEM-1024.
  • Go types: EncapsulationKey768 and EncapsulationKey1024 are the public key types. NewEncapsulationKey768 and NewEncapsulationKey1024 return an error when an encoded key is not valid.
  • TLS role: The draft requires a server to run the FIPS 203 Section 7.2 encapsulation key check on the client's key and to abort with illegal_parameter if the check fails.
  • Certificates: In RFC 9935 X.509 certificates, the subjectPublicKey BIT STRING holds the raw encapsulation key bytes, 800, 1184 or 1568 octets, with no ASN.1 wrapping.
  • OpenSSL 3.5: OpenSSL can output the public key in the ML-KEM key formats it supports, and the provider setting ml-kem.output_formats controls which formats are produced.

Before deploying, confirm that your library validates encoded encapsulation keys on input and that certificate tooling accepts the raw byte encoding for the parameter set you run.

How the two ML-KEM keys move in a TLS 1.3 key exchange

The diagram starts with the client, which generates an ML-KEM decapsulation key and places the matching encapsulation key in its key share. The server receives that encapsulation key and first runs the FIPS 203 Section 7.2 encapsulation key check; if the check fails, the server aborts with illegal_parameter. When the check passes, the server encapsulates a shared secret and returns the ciphertext in its key share. The client then uses its decapsulation key to recover the shared secret. Check that the encapsulation key is the one sent by the client and that the decapsulation key never leaves the client.

Client holds the decapsulation key, server sends back the ciphertext.

Which differences change how you store, send and check keys

ML-KEM has two keys with different jobs, and each one carries different handling rules. The cards below cover where each key is held, how large it is, how the private key can be stored, and what a receiver should check before it trusts an input.

The decapsulation key stays with its holder

In a TLS 1.3 key exchange with ML-KEM, the client's share carries its encapsulation key and the server's share carries the ciphertext. The decapsulation key is never sent, so it stays with the client. Systems that terminate or proxy TLS should confirm which side holds the decapsulation key for each group they advertise, and should not assume that a server-side load balancer or inspection device needs a copy of it. The sources list these roles for the TLS draft only, so confirm the behavior against the protocol version and library you run.

TLS ML-KEM draft

Encapsulation key size is fixed per set

The encapsulation key is 800 bytes for ML-KEM-512, 1184 bytes for ML-KEM-768 and 1568 bytes for ML-KEM-1024. In an X.509 certificate, the subjectPublicKey BIT STRING holds these raw bytes with no ASN.1 wrapping. Storage, message buffers and certificate fields sized for a classical key will need to be checked against these lengths, and any field that rejects an unexpected length will fail on a key from the wrong set.

RFC 9935 text

Store the decapsulation key as a seed

RFC 9935 lets an ML-KEM private key be a 64-octet seed, an expanded decapsulation key, or both, and recommends the seed as the most compact form. OpenSSL 3.5 can output seed-priv, seed-only, priv-only or bare formats, and by default writes seed-priv first and priv-only second. Teams choosing a storage format should confirm which form their tools read and write, since an expanded key takes 1632 to 3168 bytes depending on the set, against 64 bytes for the seed.

OpenSSL ML-KEM docs

Validate encapsulation keys on input

Go's NewEncapsulationKey768 and NewEncapsulationKey1024 return an error when an encoded encapsulation key is not valid, so the constructor is the place to reject a bad key. The TLS draft requires a server to run the FIPS 203 Section 7.2 encapsulation key check and abort with illegal_parameter if it fails. Any custom code that parses keys from requests, files or certificates should run the same check before using the key.

Go crypto/mlkem docs

Wrong-length ciphertexts fail, invalid ones do not

Go decapsulation returns an error for a ciphertext of the wrong length. A ciphertext of the correct length that is otherwise invalid does not return an error; it yields a key that does not match the sender's. Error handling that only checks for a returned error will therefore miss a failed exchange, and the session will fail later, when the two sides compare keys or decrypt. Tests should cover both cases.

Go crypto/mlkem docs

Where each key appears in protocols, certificates and libraries

In a TLS 1.3 key exchange using ML-KEM, the client's key share carries the encapsulation key and the server's key share carries the ciphertext. The decapsulation key never leaves the client, so the server only ever handles the public half. The draft-ietf-tls-mlkem-11 draft also requires a server to run the FIPS 203 Section 7.2 encapsulation key check on the client's key and abort with illegal_parameter if the check fails. Engineers reviewing a TLS deployment should confirm that their TLS library performs this check and that the failure path is tested. The sources listed here do not cover every TLS library or product, so confirm the behavior of the specific version you run.

In X.509 certificates under RFC 9935, the subjectPublicKey BIT STRING holds the raw encapsulation key bytes, 800, 1184 or 1568 octets depending on the parameter set, with no ASN.1 wrapping of the key itself. For private key storage, RFC 9935 allows a CHOICE of a 64-octet seed, which the document recommends as the most compact form, the expanded decapsulation key, or both. Teams building certificate tooling should check which private key form their tools write and read, since a parser that expects one form may reject the other.

Libraries differ in how they store the same key. Go's crypto/mlkem separates the public types EncapsulationKey768 and EncapsulationKey1024 from the secret types DecapsulationKey768 and DecapsulationKey1024, and its constructors return an error for an invalid encoded encapsulation key. In OpenSSL 3.5, the EVP_PKEY-ML-KEM provider stores the private key as seed-priv, seed-only, priv-only or bare formats, and outputs seed-priv first by default. The settings ml-kem.retain_seed, ml-kem.prefer_seed, ml-kem.input_formats and ml-kem.output_formats control this, and generated keys retain their seed by default. Before exchanging keys between systems, confirm which format each side expects, and verify the settings against the OpenSSL or Go version you deploy.

How to check which key your system should hold

This sequence establishes which ML-KEM key your system should hold, the encapsulation key or the decapsulation key, by checking the specification, the library, your storage and the vendor. Each step produces a recorded answer you can compare against your configuration and sizes.

  1. Confirm which key the peer sends in the specification

    Read the protocol or certificate specification your deployment follows and find which party sends which value. In a TLS 1.3 key exchange using ML-KEM, the client share carries the encapsulation key and the server share carries the ciphertext, so the decapsulation key stays with the client. For X.509 certificates, RFC 9935 places the raw encapsulation key in the subjectPublicKey field. Record the specification section and the party for each message. You are done when you can state, for your protocol, which party holds the decapsulation key.

  2. Check library type names and key handling defaults

    Open the documentation for the cryptographic library your application uses and identify the type names it exposes for ML-KEM. In Go's crypto/mlkem, EncapsulationKey768 and EncapsulationKey1024 are the public key types, and DecapsulationKey768 and DecapsulationKey1024 are the secret key types. Check the constructors and whether they return errors on invalid encoded input. Confirm the library's defaults for generating and exporting keys. You are done when each type your code uses maps to the role the specification assigns it.

  3. Inspect key storage for seed and expanded formats

    Look at how your system stores the ML-KEM private key. RFC 9935 allows the private key to be a 64-octet seed, the expanded decapsulation key, or both. OpenSSL 3.5 can store keys as seed-priv, seed-only, priv-only or bare formats, and by default outputs seed-priv first. Check the storage format of every key file, configuration entry or secret store entry. You are done when you have listed each stored key and its format, and confirmed whether it holds a seed, an expanded key, or both.

  4. Verify the parameter set by encapsulation key size

    Measure the length of the encapsulation key your system holds or receives and compare it with the published sizes. The sizes are 800 bytes for ML-KEM-512, 1184 bytes for ML-KEM-768 and 1568 bytes for ML-KEM-1024. A key that does not match one of these lengths indicates a wrong parameter set, an encoding problem or a wrapping layer you have not removed. Record the measured length alongside the key type. You are done when every key in scope maps to exactly one parameter set by length.

  5. Confirm with the vendor which key they generate

    Ask the vendor of each product in scope which key their software generates, which key it stores and which key it sends to peers. Request the answer in writing and ask for the version and configuration it applies to. Compare the vendor's answer with the specification and library checks from the earlier steps. The sources listed on this page do not say how any particular vendor behaves, so treat this answer as the authority for that product. You are done when each in-scope product has a written answer that matches your other findings.

How the two keys are used together in one exchange

The encapsulation key and the decapsulation key are a matched pair produced by one key generation, and neither works without the other. In a TLS 1.3 exchange using ML-KEM, the flow runs in one direction: the client's key share carries the encapsulation key, the server uses that encapsulation key to produce a ciphertext, and the server's key share carries the ciphertext back to the client. The client then runs decapsulation with its own decapsulation key to recover the shared secret. The decapsulation key therefore stays with the client for the life of that exchange and is never sent on the wire. Per draft-ietf-tls-mlkem-11, the server must run the FIPS 203 Section 7.2 encapsulation key check on the client's key and abort with illegal_parameter if the check fails, so an invalid public key is rejected before any ciphertext is produced.

The pair cannot be swapped between roles. A server cannot take the client's decapsulation key and reuse it as its own encapsulation key, and a client cannot use an encapsulation key in place of its decapsulation key to recover the secret. The shared secret is 32 bytes for all three ML-KEM parameter sets, which is the same length the exchange will derive from either side, so a wrong pairing does not produce an obvious error at the size level. Go's crypto/mlkem types make the roles explicit: DecapsulationKey768 and DecapsulationKey1024 are the secret key types, and EncapsulationKey768 and EncapsulationKey1024 are the public key types. Go's decapsulation returns an error only for a wrong-length ciphertext, so a correct-length ciphertext built from the wrong key yields a secret that does not match the sender's rather than a failure. Confirm your library's behavior in testing before relying on error handling to catch a mismatched key.

When you review an implementation, check the key roles against the exchange diagram in the TLS draft and the library types your code calls. Confirm that the client generates and keeps the decapsulation key, that the server only reads the client's encapsulation key after the validity check, and that stored keys are not exchanged between roles during configuration or migration. Where keys are stored as files or certificates, the encoding decides what a reader will find: RFC 9935 places the raw encapsulation key bytes in the subjectPublicKey BIT STRING and lets the private key be stored as a 64-octet seed, an expanded decapsulation key, or both. Confirm with your vendor which form they store and whether they can reproduce the decapsulation key from the seed.

Questions people ask about ML-KEM encapsulation and decapsulation keys

Which ML-KEM key is the public key, the encapsulation key or the decapsulation key?

The encapsulation key is the public key. It is used to produce ciphertexts, and anyone who holds it can run encapsulation to create a shared secret for the key holder. The decapsulation key is the secret key. It recovers the shared secret from a ciphertext, so it must stay with the party that is meant to receive the secret. Go's crypto/mlkem package reflects this split in its type names: EncapsulationKey768 and EncapsulationKey1024 are the public key types, while DecapsulationKey768 and DecapsulationKey1024 are the secret key types. When you review a design, check that each party holds only the key its role requires, and that the public key is the one that gets published or sent to peers.

Can the ML-KEM decapsulation key be sent to the peer during a key exchange?

No. In a TLS 1.3 key exchange using ML-KEM, the client's key share carries the encapsulation key and the server's key share carries the ciphertext. The decapsulation key never appears on the wire, and it stays with the client that generated it. Sending it to the peer would expose the secret that recovers the shared secret, which defeats the purpose of the exchange. The same division applies in any protocol that uses ML-KEM as a KEM: the public half travels, and the decapsulation half stays local. If a vendor's documentation or export feature moves the decapsulation key off the host, treat that as a finding to investigate, not a normal operating mode.

Why is the ML-KEM encapsulation key larger than a classical public key?

Encapsulation key sizes depend on the parameter set. The draft TLS specification lists 800 bytes for ML-KEM-512, 1184 bytes for ML-KEM-768 and 1568 bytes for ML-KEM-1024. These are the encoded public key lengths, and they are larger than the public keys of many classical key exchange groups. Because the encapsulation key travels in the client's key share, the size affects handshake message length and the packet fragmentation that network teams see. Ask the vendor which parameter set the deployment uses, since the byte count changes with it. Size is a property you can check directly in the configuration or in a captured handshake, so confirm the figure against the vendor's own test output rather than relying on a general comparison.

Are the ML-KEM seed and the expanded decapsulation key interchangeable?

Not in every context. RFC 9935 allows the ML-KEM private key to be encoded as a 64-octet seed (the RFC says this is the most compact option), as the expanded decapsulation key, or as both. The draft TLS specification states that the decapsulation key can be generated from a 64-byte seed, and the expanded form is 1632, 2400 or 3168 bytes depending on the parameter set. OpenSSL 3.5 can store the key as seed-priv, seed-only, priv-only or bare formats, and by default outputs seed-priv first and priv-only second. OpenSSL's ml-kem.retain_seed setting keeps the seed for generated keys by default, and ml-kem.prefer_seed controls which form is used. Before you move keys between systems or libraries, confirm which formats each side accepts, because a consumer that expects only the expanded form may reject a seed-only file.

What should a vendor confirm about how ML-KEM private keys are stored?

Ask the vendor to state, in writing, which private key format it generates, stores and exports: the 64-byte seed, the expanded decapsulation key, or both. Ask whether the seed is retained after generation, because a retained seed lets the expanded key be regenerated and therefore needs the same protection as the expanded key. Ask where the key lives at rest, whether it is held in software or in a hardware module, and whether it can be exported in plaintext. Ask how the vendor handles the encapsulation key check that the TLS draft requires a server to run, and what happens when that check fails. Ask which library and version implement these functions, since format defaults differ between releases and implementations. Record the answers and test them yourself, because the vendor's statement describes the intended behavior, not your deployment.

Which ML-KEM key does an X.509 certificate carry?

An X.509 certificate carries the encapsulation key, the public key, and never the decapsulation key. Under RFC 9935, the subjectPublicKey BIT STRING holds the raw encapsulation key bytes, at 800, 1184 or 1568 octets depending on the parameter set, with no ASN.1 wrapping around them. The private half is handled separately, under the private key formats discussed above. When a certificate-based design lists a key in its inventory, check which of the two keys is meant, because an inventory that records only the certificate will show the public key and say nothing about where the decapsulation key is held. For a review, pair the certificate's public key with the private key storage record, and confirm that the two correspond to the same parameter set.

What goes wrong if an ML-KEM key is mixed up with the wrong parameter set?

If a party uses an encapsulation key from one parameter set with a decapsulation key from another, the length check at the boundary is the first line of defense, since the byte counts differ across ML-KEM-512, ML-KEM-768 and ML-KEM-1024. Go's NewEncapsulationKey768 and NewEncapsulationKey1024 return an error when the encoded key is not valid, and decapsulation returns an error for a wrong-length ciphertext. A correct-length ciphertext that is otherwise invalid does not produce an error. It yields a shared secret that does not match the sender's, so the handshake fails later and less clearly. Test deliberately malformed keys and ciphertexts in your environment, and confirm that the failure is logged and the connection aborted. Review how the system reports these failures, because a silent mismatch can look like a generic connection error.

How DeployOpen works on this

DeployOpen approaches ML-KEM encapsulation and decapsulation keys by first mapping which system holds each key in your key exchange, then configuring storage and validation to match. Work is scoped in writing before any changes are made to your environment.

How we scope

  • We map which components generate, publish and hold ML-KEM encapsulation keys and decapsulation keys in your environment.
  • We record the key sizes and formats each system expects, so the scope covers the real data your components exchange.
  • Engagements are fixed-scope, with the systems, deliverables and timelines agreed in writing before work starts.

How we build

  • We configure key generation and storage so decapsulation keys stay on the side that performs key recovery.
  • We check that encapsulation keys are validated on receipt, with failures handled as errors rather than accepted.
  • We test the configured key handling against the formats your chosen libraries and protocols document.

How we hand over

  • We document which key goes to which system, with sizes and storage locations for each key type.
  • We deliver configuration files and test results so your security and compliance teams can review the setup.
  • We walk your engineers through the handover so they can operate and change the key handling afterward.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers for key handling changes over time.
  • When library or protocol versions change, we review whether key formats or validation behavior are affected.
  • Confirm current key formats and validation requirements in the FIPS 203 and library documentation for your versions.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.