Crate crypto_kx

Source
Expand description

§Usage

use crypto_kx::*;
use rand_core::OsRng;

// Each generates a key on their machine.
let alice = Keypair::generate(&mut OsRng);
let betty = Keypair::generate(&mut OsRng);

// Then Alice decides to send a message to Betty, so she computes the shared keys.
let alice_keys = alice.session_keys_to(betty.public());
// Upon connection, Betty computes the same keys on her side.
let betty_keys = betty.session_keys_from(alice.public());

// By the beauty of math, they have generated the same keys on both side.
assert_eq!(alice_keys.tx.as_ref(), betty_keys.rx.as_ref());
assert_eq!(alice_keys.rx.as_ref(), betty_keys.tx.as_ref());

Modules§

errors
Errors generated by this crate.

Structs§

ClientSessionKeys
Tuple of keys for the client, the one opening the connection.
Keypair
A SecretKey with its related PublicKey.
PublicKey
PublicKey which can be freely shared.
SecretKey
SecretKey that should be kept private.
ServerSessionKeys
Tuple of keys for the server, the one receiving the connection.
SessionKey
SessionKey used in a session.