Close

How Key Exchange Works

A project log for Selectric-256

What if E2E encrypted chat was a hardware peripheral?

legionlabsLegionlabs • 09/20/2026 at 04:34•0 Comments

This diagram goes over the steps in key exchange.

NB without the use of ephemeral channels, someone could replay an old connection message. This won't let them decode your messages, but will let them prevent key exchange and generally be a nuisance. The ephemeral channels should follow the same rules as a nonce -- they don't have to be secret, but do need to be unpredictable and should not be re-used.

The ML-KEM key exchange is quite heavy compared to ECC 25519 (800 bytes vs. 32 bytes, then the ciphertext is even bigger!). To make matters worse, I encode the bytes as hex strings, doubling that already large size! We have enough memory to handle it, and for now this makes it easier for me to validate communications (e.g. because I can copy-paste them, decode, and validate). However I should eventually fix this so that I just send raw bytes over MQTT.

Discussions