1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use rand::{ Rng, CryptoRng };
use crate::{ Packing, Error };
pub mod kyber;
pub trait KeyExchange {
type PrivateKey: Packing;
type PublicKey: Packing;
type Message: Packing;
const SHARED_LENGTH: usize;
fn keypair<R: Rng + CryptoRng>(r: R) -> (Self::PrivateKey, Self::PublicKey);
fn exchange_to<R: Rng + CryptoRng>(r: R, sharedkey: &mut [u8], pk: &Self::PublicKey) -> Self::Message;
fn exchange_from(sharedkey: &mut [u8], sk: &Self::PrivateKey, m: &Self::Message);
}
pub trait CheckedExchange: KeyExchange {
fn exchange_from(sharedkey: &mut [u8], sk: &Self::PrivateKey, m: &Self::Message) -> Result<(), Error>;
}