Trident: a triple-hybrid KEM

·5 min read

Most of the post-quantum key exchange being deployed today combines X25519 with ML-KEM. This is a sensible approach, but I increasingly think we should be hedging against two things: quantum computers and AI.

We know what a sufficiently large quantum computer does to elliptic curves. What we don't know is what increasingly capable AI will do to cryptanalysis. Lattices have a rich algebraic structure, and I'm willing to bet that we will see meaningful advances in lattice cryptanalysis as AI gets better at mathematics.

If elliptic curves fall and lattices are significantly weakened, we are effectively relying on a single (weaker) security assumption.

Adding a third, mathematically distinct security assumption doesn't solve the underlying problem, but it does give an adversary another problem to solve. It is not particularly elegant, but given the uncertainty around the future of cryptanalysis, I think it's a reasonable mitigation.

Trident is a small Rust library I built to explore how practical this would be. It extends the X-Wing construction to include HQC, a code-based KEM.

Why three?

Trident combines three primitives from three different families of cryptography:

PrimitiveHardness assumption
X25519Elliptic curve discrete logarithm
ML-KEM-768Module learning with errors
HQC-192Quasi-cyclic syndrome decoding

The interesting addition is HQC. NIST selected HQC for standardisation in March 2025 specifically because it relies on different mathematics to ML-KEM.

Nobody knows whether lattices or codes will hold up better over the next 20 years. The nice thing about a hybrid KEM is that we don't have to make that decision.

If a quantum computer breaks elliptic curves, we still have lattices and codes. If advances in lattice cryptanalysis significantly reduce the security of ML-KEM, we still have HQC (and vice versa).

The design goal is that any one of the three components remaining secure is sufficient to protect the shared key.

How it works

Trident largely follows the design of X-Wing, which I wrote about earlier this year.

All three components establish their own shared secret, and we combine them using SHA3-256:

SHA3-256(
    ss_M || ss_X || ss_H ||
    ct_X || pk_X ||
    ct_H || pk_H ||
    "Trident-v1"
)

Here, ss, ct and pk are the shared secret, ciphertext and public key respectively.

Like X-Wing, we can omit the ML-KEM public key and ciphertext from the combiner because of the binding properties of ML-KEM. I've included both for HQC rather than assuming that the same analysis carries over. The computational savings from omitting them would be marginal anyway.

All three private keys are derived from a single 32-byte seed using SHAKE256 with domain separation.

What does it cost?

The obvious downside of adding HQC is size.

X-WingTrident
Public key1,216 B5,730 B
Serialized private key32 B32 B
Ciphertext1,120 B10,098 B
Shared key32 B32 B

We are adding roughly 13.5 KB of key exchange data in return for a second post-quantum hardness assumption.

I also benchmarked Trident against RustCrypto's X-Wing implementation on my MacBook Air (Apple M5, 32 GB RAM, Rust 1.96.1).

OperationX-WingTridentSlowdown
Key generation28.3 µs361.4 µs12.8×
Encapsulation47.7 µs716.3 µs15.0×
Decapsulation30.3 µs1,063 µs35.1×

X-Wing's public API re-expands the private key on each decapsulation, so I benchmarked its underlying primitives with pre-expanded keys instead. The implementations also use slightly different versions of their underlying cryptographic dependencies.

Trident is considerably slower than X-Wing, but we are still talking about less than 2 ms for encapsulation and decapsulation combined.

Whether this overhead is worth it depends on the application. For a browser establishing millions of connections, the additional bandwidth and computation matter. For encrypting a backup containing sensitive data that needs to remain private for 30 years, an additional 13.5 KB and 1.7 ms are probably irrelevant.

The less opportunity we have to change our cryptography after deploying it, the more I think it makes sense to pay for diversity up front. Encrypted data that has already been captured by an adversary is the extreme example of this.

Implementation

Trident is written in Rust, supports no_std and does not require heap allocations.

Using it is pretty straightforward:

let (dk, ek) = trident::generate_key_pair();

let (ct, ss_sender) = ek.encapsulate();
let ss_receiver = dk.decapsulate(&ct);

assert_eq!(ss_sender, ss_receiver);

Trident is experimental. It has not been formally analysed or independently audited, and the HQC standard is not yet finalised.

There is nothing particularly novel about combining three cryptographic primitives into a hybrid KEM. I was mostly interested in how practical it would be to have a hybrid KEM that hedges against both quantum computers and advances in post-quantum cryptanalysis.

The code is open source and available on GitHub.