pub trait Kem: Sized {
type PublicKey: Clone + Debug + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>;
type PrivateKey: Clone + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>;
type EncappedKey: Clone + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>;
const KEM_ID: u16;
// Required methods
fn sk_to_pk(sk: &Self::PrivateKey) -> Self::PublicKey;
fn derive_keypair(ikm: &[u8]) -> (Self::PrivateKey, Self::PublicKey);
// Provided method
fn gen_keypair<R: CryptoRng + RngCore>(
csprng: &mut R
) -> (Self::PrivateKey, Self::PublicKey) { ... }
}
Expand description
Represents authenticated encryption functionality
Required Associated Types§
sourcetype PublicKey: Clone + Debug + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>
type PublicKey: Clone + Debug + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>
The key exchange’s public key type. If you want to generate a keypair, see
Kem::gen_keypair
or Kem::derive_keypair
sourcetype PrivateKey: Clone + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>
type PrivateKey: Clone + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>
The key exchange’s private key type. If you want to generate a keypair, see
Kem::gen_keypair
or Kem::derive_keypair
sourcetype EncappedKey: Clone + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>
type EncappedKey: Clone + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>
The encapsulated key for this KEM. This is used by the recipient to derive the shared secret.
Required Associated Constants§
Required Methods§
sourcefn sk_to_pk(sk: &Self::PrivateKey) -> Self::PublicKey
fn sk_to_pk(sk: &Self::PrivateKey) -> Self::PublicKey
Computes the public key of a given private key
sourcefn derive_keypair(ikm: &[u8]) -> (Self::PrivateKey, Self::PublicKey)
fn derive_keypair(ikm: &[u8]) -> (Self::PrivateKey, Self::PublicKey)
Deterministically derives a keypair from the given input keying material
Requirements
This keying material SHOULD have as many bits of entropy as the bit length of a secret key,
i.e., 8 * Self::PrivateKey::size()
. For X25519 and P-256, this is 256 bits of
entropy.
Provided Methods§
sourcefn gen_keypair<R: CryptoRng + RngCore>(
csprng: &mut R
) -> (Self::PrivateKey, Self::PublicKey)
fn gen_keypair<R: CryptoRng + RngCore>( csprng: &mut R ) -> (Self::PrivateKey, Self::PublicKey)
Generates a random keypair using the given RNG
Object Safety§
This trait is not object safe.