lib-q-hpke 0.0.2

HPKE implementation for lib-q
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! KEM trait definitions

#[cfg(feature = "alloc")]
use alloc::vec::Vec;

use crate::error::HpkeError;

/// Trait for KEM implementations
pub trait Kem {
    /// Generate a key pair
    fn generate_keypair(&self) -> Result<(Vec<u8>, Vec<u8>), HpkeError>;

    /// Encapsulate a shared secret
    fn encapsulate(&self, public_key: &[u8]) -> Result<(Vec<u8>, Vec<u8>), HpkeError>;

    /// Decapsulate a shared secret
    fn decapsulate(&self, secret_key: &[u8], ciphertext: &[u8]) -> Result<Vec<u8>, HpkeError>;
}