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 generated by this crate.

Structs