# Sanctum: "Swap the classical ECDH part of the exchange from x25519 to secp384r1"

> Source: <https://github.com/jorisvink/sanctum/commit/c0972c36ad9fcbd790427a08d7e8ea1cc2327d9e>
> Published: 2026-12-05 21:22:44+00:00

**Key takeaway:** Sanctum's hybrid handshake now derives session keys via KMAC256 from an ECC (secp384r1) shared secret plus an ML-KEM-1024 shared secret, so implementations must replace X25519-KEYGEN/X25519-SCALAR-MULT with ECC-KEYGEN/ECC-DERIVE.

| @@ -18,7 +18,7 @@ construction are fixed as there is no risk for (key, nonce) | 
| `18` | `18` | pair re-use in this specific scenario. | 
| `19` | `19` |  | 
| `20` | `20` | Key derivation for session keys is done by combing unique | 
| `21` |  | `-` per-direction shared secrets from ECDH (x25519) and ML-KEM-1024, | 
|  | `21` | `+` per-direction shared secrets from ECDH and ML-KEM-1024, | 
| `22` | `22` | together with a derivative of our shared symmetrical key. | 
| `23` | `23` |  | 
| `24` | `24` | IKM = len(ecdh_ss) \|\| ecdh_ss \|\| len(mlkem1024_ss) \|\| mlkem1024_ss \|\| | 
| @@ -133,13 +133,13 @@ these can be distributed via a cathedral as an ambry, see docs/cathedral.md. | 
| `133` | `133` |  | 
| `134` | `134` | Session keys (SK) are derived from the **traffic_base_rx** or | 
| `135` | `135` | **traffic_base_tx** keys in combination with directional unique | 
| `136` |  | `-` ECDH (x25519) and ML-KEM-1024 shared secrets, using KMAC256() as the KDF. | 
|  | `136` | `+` ECDH and ML-KEM-1024 shared secrets, using KMAC256() as the KDF. | 
| `137` | `137` |  | 
| `138` | `138` | Both sides start by sending out offerings that contain an ML-KEM-1024 | 
| `139` |  | `-` public key and an x25519 public key. | 
|  | `139` | `+` public key and an ECDH public key. | 
| `140` | `140` |  | 
| `141` | `141` | Both sides upon receiving these offerings will perform ML-KEM-1024 | 
| `142` |  | `-` encapsulation and send back the ciphertext and their own x25519 | 
|  | `142` | `+` encapsulation and send back the ciphertext and their own ECDH | 
| `143` | `143` | public key which differs from the one sent in the initial offering. | 
| `144` | `144` |  | 
| `145` | `145` | When a side performs encapsulation it will derive a fresh | 
| @@ -150,7 +150,7 @@ When a side performs decapsulation it will derive a fresh | 
| `150` | `150` | TX session key using all of that key material and install the | 
| `151` | `151` | key as the active TX key. | 
| `152` | `152` |  | 
| `153` |  | `-` In both cases this results in unique shared secrets for x25519 | 
|  | `153` | `+` In both cases this results in unique shared secrets for ECDH | 
| `154` | `154` | and ML-KEM-1024 in each direction, while allowing us to gracefully | 
| `155` | `155` | install pending RX keys so that we do not miss a beat. | 
| `156` | `156` |  | 
| @@ -166,7 +166,7 @@ derive_offer_encryption_key(seed): | 
| `166` | `166` |     return wk | 
| `167` | `167` |  | 
| `168` | `168` | offer_create(): | 
| `169` |  | `-`    offer.ecdh   = X25519-KEYGEN() | 
|  | `169` | `+`    offer.ecdh   = ECC-KEYGEN() | 
| `170` | `170` |     offer.kem    = ML-KEM-1024-KEYGEN() | 
| `171` | `171` |     offer.now    = TIME(WALL_CLOCK), 64-bit | 
| `172` | `172` |     offer.id     = PRNG(64-bit), unique sanctum id | 
| @@ -204,7 +204,7 @@ offer_recv_pk(offer): | 
| `204` | `204` |     dk = derive_offer_encryption_key(packet.header.seed) | 
| `205` | `205` |     pt = AES256-GCM(dk, nonce=1, aad=packet.header, packet.data) | 
| `206` | `206` |  | 
| `207` |  | `-`    ecdh_ss = X25519-SCALAR-MULT(pt.ecdh.pub, offer.ecdh.private) | 
|  | `207` | `+`    ecdh_ss = ECC-DERIVE(pt.ecdh.pub, offer.ecdh.private) | 
| `208` | `208` |     offer.kem.ct, kem_ss = ML-KEM-1024-ENCAP(pt.kem.pk) | 
| `209` | `209` |  | 
| `210` | `210` |     if pt.instance < local_id | 
| @@ -249,7 +249,7 @@ offer_recv_ct(offer): | 
| `249` | `249` |     dk = derive_offer_encryption_key(packet.header.seed) | 
| `250` | `250` |     pt = AES256-GCM(dk, nonce=1, aad=packet.header, packet.data) | 
| `251` | `251` |  | 
| `252` |  | `-`    ecdh_ss = X25519-SCALAR-MULT(pt.ecdh.pub, offer.ecdh.private) | 
|  | `252` | `+`    ecdh_ss = ECC-DERIVE(pt.ecdh.pub, offer.ecdh.private) | 
| `253` | `253` |     kem_ss = ML-KEM-1024-DECAP(offer.kem, pt.kem.ct) | 
| `254` | `254` |  | 
| `255` | `255` |     if pt.instance < local_id | 
|  |
