X25519 + HKDF
Key agreement followed by HKDF-SHA-256 with a salt and context info to derive a 32-byte session key.

Overview & Cryptographic Context
A raw elliptic-curve Diffie-Hellman shared secret represents an algebraic curve coordinate in GF(2255-19), not a uniformly distributed bit string, and must never be wired directly as an AES or ChaCha20 key. Modern key exchange standards (TLS 1.3 RFC 8446, HPKE RFC 9180, Signal X3DH) always feed the ECDH shared secret into HKDF as Input Keying Material (IKM) alongside a protocol salt and domain-separation context string (info).
This two-stage workflow chains X25519 Key Exchange (ECDH) (using the RFC 7748 §6.1 Alice/Bob key pair) into HKDF Key Derivation with SHA-256, a 13-byte salt, and the ASCII context label "nodecrypto session key" (6e6f646563727970746f2073657373696f6e206b6579) to derive a 32-byte (256-bit) symmetric session key.
Pipeline Architecture & Wiring Flow
- Stage 1 — Curve25519 Key Agreement (
X25519 Key Exchange (ECDH)): Computes the 32-byte raw shared secret4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742fromPrivateKeyandPeerPublicKey. - Stage 2 — HKDF Extract & Expand (
HKDF Key Derivation): Receives the raw shared secret on itsikmport, combines it withSaltandInfofromWorkflow Input, and expands a 32-byteSessionKey.
Nodes & Configuration
| Node | Node Role & Key Parameters | Count |
|---|---|---|
| Workflow Input | Supplies PrivateKey, PeerPublicKey, Salt, and Info | 1 |
| X25519 Key Exchange (ECDH) | Computes 32-byte raw Curve25519 shared secret | 1 |
| HKDF Key Derivation | Configured with hashAlgorithm = "SHA-256", keyLength = 32 | 1 |
| Workflow Output | Collects the 32-byte SessionKey | 1 |
Inputs, Outputs & Test Vector Verification
Verification Source: RFC 7748 §6.1 shared secret; HKDF-SHA-256 output cross-checked with Node.js crypto.hkdfSync
Inputs
| Name | Type | Value (Hex) |
|---|---|---|
PrivateKey | bytes (32 B) | 77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a |
PeerPublicKey | bytes (32 B) | de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f |
Salt | bytes (13 B) | 000102030405060708090a0b0c |
Info | bytes (22 B, ASCII "nodecrypto session key") | 6e6f646563727970746f2073657373696f6e206b6579 |
Expected Outputs
| Name | Type | Value (Hex) |
|---|---|---|
SessionKey | bytes (32 B) | 7d87f69eef5eee6ad11c518723db4f5f8708a99c84e9a3589df85d62d7b14c9b |