WritingSecurity

Sharing keys between people with X25519 and ML-KEM-768

How Henedo seals a file key for another family member with a hybrid classical and post-quantum key exchange, why the transcript is bound in, and what post-quantum cryptography does not fix.

Flavian Ene4 min read

Most of the cryptography in Henedo is symmetric. Every file is encrypted with its own random AES-256-GCM key, and those keys are wrapped under the owner's Master Key. Symmetric encryption at 256 bits is not the quantum worry: the best known quantum attack, Grover's algorithm, roughly halves the effective strength, which still leaves a comfortable margin.

The quantum worry starts the moment two people share something. To give a family member access to a file, the file's key has to be sealed to their keys, and that step has classically been done with elliptic-curve Diffie–Hellman, which is exactly what a large quantum computer would break.

For most data that is a distant concern. For a family archive it is not. The threat is "harvest now, decrypt later": record the encrypted envelopes today, open them when the hardware exists. A family's private history is supposed to stay private for generations, which is longer than anyone's confidence in today's elliptic curves.

Why hybrid, not post-quantum alone

ML-KEM, standardised as FIPS 203 in 2024, is the obvious replacement. But it is young as deployed cryptography, and young implementations have bugs. Replacing X25519 outright would trade a well-understood future risk for a less understood present one.

So new sharing envelopes in Henedo use both. Every member publishes an X25519 public key and an ML-KEM-768 encapsulation key; both private halves are wrapped under that member's own Master Key. Sealing a file key requires both shared secrets, which means opening one requires breaking both. This is the same reasoning behind the hybrid key exchange browsers now use in TLS.

The construction

Simplified, sealing a file key for one recipient looks like this:

ss_x            = X25519(ephemeral_secret, recipient_x25519_public)
(ct, ss_pq)     = ML-KEM-768.Encapsulate(recipient_mlkem_public)
transcript      = SHA-256(ephemeral_public ‖ ct ‖ recipient_x25519_public ‖ recipient_mlkem_public)
wrapping_key    = HKDF-SHA-256(ss_x, ss_pq, transcript; info = "henedo-kex-hybrid-v3")
envelope        = AES-256-GCM(wrapping_key, file_key)

The byte-level layout is in Henedo's security document; the shape is what matters here.

Both secrets feed the key derivation. An attacker who breaks X25519 still faces ML-KEM-768, and the reverse.

The transcript is bound in. Naively concatenating two shared secrets is not enough for a sound combiner. Hashing the ephemeral key, the KEM ciphertext and both recipient public keys into the derivation ties the wrapping key to this exact exchange with this exact recipient. One practical consequence: an envelope copied into another member's slot fails its authentication tag instead of silently decrypting.

Only the file key is sealed. The file itself is never re-encrypted to share it. An envelope is small, so adding a member, removing one or upgrading the envelope format means rewrapping a key, not re-uploading a photo library.

The primitives come from the noble libraries for X25519 and ML-KEM, and from WebCrypto for AES-GCM and HKDF. In practice, the expensive operation in Henedo's client is not the key exchange; it is Argon2id at 128 MiB when a vault is unlocked with a password.

Signatures: both, always

Sealing proves only that the right person can open something. It does not prove who sealed it. Every shared file and folder also carries its owner's signatures over the item and the digests of every recipient envelope: Ed25519 and ML-DSA-65, the post-quantum signature scheme standardised as FIPS 204.

The rule that matters is in the verifier: every signature a format version requires must verify. Never "either signature will do". An "either" rule quietly reduces a hybrid scheme to its weakest member, and invites a downgrade attack where a forger simply strips the signature they cannot produce.

Versions are a security feature

Henedo's envelopes have changed twice. Version 1 used raw X25519. Version 2 added proper key derivation. Version 3 is the hybrid described above.

Old envelopes stay readable and are never written by current clients. An unknown version is refused rather than guessed. If I were starting again, the one thing I would insist on from the first commit is exactly this: a version byte on every envelope, and a verifier that refuses anything it does not recognise. It is the difference between a cheap migration and an impossible one.

The part cryptography cannot do

Public-key encryption is only as good as the public key. If the server could swap in its own key when one member shares with another, the strongest KEM in the world would encrypt directly to the attacker.

The defence is old-fashioned: safety numbers. The first time two people share on a device, they compare a short code derived from each other's keys, through a channel they already trust. It is the same idea messaging apps use. It is also the step people skip, which is why it has to be easy.

There is an honest limit here too. Questions sent to relatives through Henedo's "Ask" links carry no fingerprint, so those trust the served key on first use.

What post-quantum does not fix

  • Old ciphertext does not upgrade itself. Envelopes sealed under versions 1 and 2 keep their original, classical security until they are rewrapped.
  • Not everything is hybrid yet. Release manifests, which prove the web app's code is authentic, are still signed with Ed25519 alone.
  • Standards are not guarantees. Using FIPS 203 and 204 algorithms is not the same as a certified module, and these choices reduce known risks rather than guarantee future security.

Post-quantum migration is mostly unglamorous work: versioning, combiners, verifiers that fail closed, and a clear list of what is not done yet. The algorithms are the easy part.

  • post-quantum
  • ml-kem
  • x25519
  • cryptography
  • henedo

Flavian Ene

Founder and CEO of Henedo, founder of nordo. MSc in Cybersecurity. Writes about security-first ventures, AI systems and what did not work. About