X25519 key agreement
Computes the shared secret from one side's private key and the peer's public key, checked against RFC 7748.
Overview & Cryptographic Context
X25519 (specified in IETF RFC 7748) is an elliptic-curve Diffie-Hellman (ECDH) function built on the Montgomery curve Curve25519 (y2 = x3 + 486662x2 + x over the prime field 2255 - 19). Designed for constant-time Montgomery ladder execution and immunity to twist and invalid-curve attacks, X25519 uses compact 32-byte little-endian u-coordinates for public keys and 32-byte clamped scalars for private keys.
This workflow reproduces RFC 7748 §6.1, computing the 32-byte shared secret K = X25519(a, B) from Alice's 32-byte private key a and Bob's 32-byte public key B. In production protocols, this raw shared secret should always be passed through a key derivation function such as HKDF (see X25519 + HKDF).
Pipeline Architecture & Wiring Flow
- Key Material Ingress (
Workflow Input): Supplies Alice's 32-bytePrivateKeyand Bob's 32-bytePeerPublicKey. - Scalar Multiplication (
X25519 Key Exchange (ECDH)): Clamps the private scalar (clearing bits 0, 1, 2, 255 and setting bit 254) and evaluates the Montgomery ladder over GF(2255-19). Rejects low-order points that produce an all-zero shared secret. - Shared Secret Egress (
Workflow Output): Outputs the 32-byte shared secret K.
Nodes & Configuration
| Node | Node Role & Key Parameters | Count |
|---|---|---|
| Workflow Input | Supplies PrivateKey (32 B) and PeerPublicKey (32 B) | 1 |
| X25519 Key Exchange (ECDH) | Evaluates RFC 7748 Curve25519 scalar multiplication | 1 |
| Workflow Output | Collects the 32-byte SharedSecret | 1 |
Inputs, Outputs & Test Vector Verification
Verification Source: RFC 7748 §6.1 (Alice private key, Bob public key)
Inputs
| Name | Type | Value (Hex) |
|---|---|---|
PrivateKey | bytes (32 B) | 77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a |
PeerPublicKey | bytes (32 B) | de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f |
Expected Outputs
| Name | Type | Value (Hex) |
|---|---|---|
SharedSecret | bytes (32 B) | 4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 |