Expand description
X25519 key exchange for secure P2P communication.
This module provides Diffie-Hellman key exchange using the X25519 elliptic curve, enabling peers in the CHIE network to establish secure encrypted channels.
§Features
- X25519 Diffie-Hellman key exchange
- Ephemeral and static key support
- Shared secret derivation with HKDF
- Key serialization for network transmission
§Example
use chie_crypto::keyexchange::{KeyExchange, KeyExchangeKeypair};
// Alice generates a keypair
let alice = KeyExchangeKeypair::generate();
// Bob generates a keypair
let bob = KeyExchangeKeypair::generate();
// Exchange public keys and derive shared secret
let alice_shared = alice.exchange(bob.public_key());
let bob_shared = bob.exchange(alice.public_key());
// Both parties now have the same shared secret
assert_eq!(alice_shared.as_bytes(), bob_shared.as_bytes());Structs§
- KeyExchange
Keypair - Key exchange keypair for X25519 Diffie-Hellman.
- Shared
Secret - Shared secret derived from key exchange (32 bytes).
Enums§
- KeyExchange
Error - Errors that can occur during key exchange operations.
Traits§
- KeyExchange
- Key exchange trait for performing Diffie-Hellman.
Functions§
- ephemeral_
keypair - Create an ephemeral keypair for one-time key exchange.
- exchange_
and_ derive - Perform a complete key exchange and derive an encryption key.