pqcrypto_traits/
kem.rs

1/// Traits for Key-Encapsulation Mechanisms
2use crate::Result;
3
4/// A public key for a KEM
5pub trait PublicKey {
6    fn as_bytes(&self) -> &[u8];
7    fn from_bytes(bytes: &[u8]) -> Result<Self>
8    where
9        Self: Sized + Clone;
10}
11
12/// A secret key for a KEM
13pub trait SecretKey {
14    fn as_bytes(&self) -> &[u8];
15    fn from_bytes(bytes: &[u8]) -> Result<Self>
16    where
17        Self: Sized + Clone;
18}
19
20/// The ciphertext to be sent to the other party to decapsulate.
21pub trait Ciphertext {
22    fn as_bytes(&self) -> &[u8];
23    fn from_bytes(bytes: &[u8]) -> Result<Self>
24    where
25        Self: Sized + Clone + Copy;
26}
27
28/// The shared secret that should be agreed on.
29pub trait SharedSecret {
30    fn as_bytes(&self) -> &[u8];
31    fn from_bytes(bytes: &[u8]) -> Result<Self>
32    where
33        Self: Sized + Clone + Copy;
34}