Skip to main content

encapsulate_kem

Function encapsulate_kem 

Source
pub fn encapsulate_kem(
    public_key: &[u8],
    rng: &mut impl CryptoRng,
) -> Result<(Bytes, Bytes), CryptoError>
Expand description

Encapsulate a shared secret for the holder of public_key.

Returns (ciphertext, shared_secret) — both as raw bytes. Ciphertext is 1568 bytes; shared secret is 32 bytes.

§Errors

Returns CryptoError::InvalidKeyLength if public_key is not 1568 bytes, or CryptoError::EncapsulationFailed if the key bytes are otherwise invalid.