pub fn derive_stream_keys(
shared_secret: &[u8; 32],
client_pub: &[u8; 32],
server_pub: &[u8; 32],
) -> EnvelopeResult<StreamKeys>Expand description
Derive stream keys (topic and mac_key) from DH shared secret.
Uses the crypto backend (Blake3 or HKDF-SHA256) with:
- IKM: shared_secret || salt (where salt = XOR of client_pub and server_pub)
- Context: “hyprstream stream-keys v1 topic” or “hyprstream stream-keys v1 mac”
§Arguments
shared_secret- 32-byte DH shared secretclient_pub- Client’s ephemeral Ristretto public key (32 bytes)server_pub- Server’s ephemeral Ristretto public key (32 bytes)
§Returns
StreamKeys containing the derived topic (64 hex chars) and mac_key (32 bytes).
§Errors
Returns EnvelopeError::KeyExchange if client and server keys are identical.
§Security
- Ristretto255 eliminates low-order point attacks by construction
- XOR salt ensures both parties’ keys are bound to the derivation
- Self-connection check prevents replay attacks
§Backend
- Default: Blake3
derive_key()(~10+ GB/s with SIMD) - FIPS mode: HKDF-SHA256 (NIST SP 800-56C)