Skip to main content

Module crypto

Module crypto 

Source
Expand description

Cryptographic primitives for secure RPC communication.

This module provides:

  • Ed25519 digital signatures for request envelope authentication
  • Diffie-Hellman key exchange (Ristretto255 or ECDH P-256 in FIPS mode)
  • Chained MACs for streaming response authentication
  • Backend abstraction for KDF and MAC operations

§Chained MAC

Streaming responses use chained MACs where each chunk’s MAC depends on the previous chunk’s MAC. This provides cryptographic ordering without explicit sequence numbers:

mac_0 = MAC(key, request_id_bytes || data_0)
mac_n = MAC(key, mac_{n-1} || data_n)

§Feature Flags

  • Default: Blake3 for KDF and MAC (~10+ GB/s with SIMD)
  • fips: HKDF-SHA256 + HMAC-SHA256 (NIST SP 800-56C, FIPS 198-1)

Key exchange:

  • Default: Ristretto255 (prime-order group, no cofactor issues)
  • fips: ECDH P-256 for FIPS 140-2 compliance

Re-exports§

pub use key_exchange::derive_notification_keys;
pub use key_exchange::derive_stream_keys;
pub use key_exchange::DefaultKeyExchange;
pub use key_exchange::KeyExchange;
pub use key_exchange::NotificationKeys;
pub use key_exchange::SharedSecret;
pub use key_exchange::StreamKeys;
pub use signing::generate_signing_keypair;
pub use signing::signing_key_from_bytes;
pub use signing::verifying_key_from_bytes;
pub use key_exchange::blinded_dh;
pub use key_exchange::blinded_dh_raw;
pub use key_exchange::generate_ephemeral_keypair;
pub use key_exchange::reconstruct_blinded_pub_raw;
pub use key_exchange::rerandomize_pubkey;
pub use key_exchange::ristretto_dh;
pub use key_exchange::ristretto_dh_raw;
pub use key_exchange::RistrettoKeyExchange;
pub use key_exchange::RistrettoPublic;
pub use key_exchange::RistrettoSecret;

Modules§

backend
Cryptographic backend abstraction for KDF and MAC operations.
broadcast_primitives
Broadcast crypto primitives preserved from the removed NotificationService.
cose_encrypt
Canonical COSE_Encrypt0 sealing over Hyprstream’s pinned hybrid-KEM suite.
cose_sign
Nested-COSE hybrid composite signing for the hyprstream SignedEnvelope (EdDSA + ML-DSA-65).
cose_sign1
COSE_Sign1 (RFC 9052) detached-payload signing for the hyprstream SignedEnvelope.
event_crypto
Cryptographic primitives for EventService transport.
group_key
Controller-managed hybrid group epochs for record-backed fan-out.
hmac
Stream block HMAC for authenticating streaming responses.
hybrid_kem
Hybrid multi-KEM key agreement (“HyKEM”) — #551 / S0 of epic #550.
key_exchange
Diffie-Hellman key exchange for stream MAC key derivation.
pq
Post-quantum hybrid cryptographic primitives (ML-DSA-65 + ML-KEM-768).
signing
Ed25519 digital signatures for request envelope authentication.

Structs§

SigningKey
ed25519 signing key which can be used to produce signatures.
StreamHmacState
Chained HMAC state for stream block authentication, matching wire format.
VerifyingKey
An ed25519 public key.

Enums§

CryptoPolicy
Policy-selected envelope/token signature suite.

Functions§

derive_key
Derive a 32-byte key from input material with domain separation.
keyed_mac
Compute a 32-byte keyed MAC.
keyed_mac_truncated
Compute a 16-byte truncated keyed MAC (for wire format).
keyed_mac_truncated_parts
Multi-part variant of keyed_mac_truncated — authenticates the concatenation of parts without allocating a joined buffer.