Skip to main content

encapsulate_to_public

Function encapsulate_to_public 

Source
pub fn encapsulate_to_public(
    public_bytes: &[u8],
) -> Result<(Vec<u8>, [u8; 32]), CryptoError>
Expand description

Encapsulate a fresh shared secret to a foreign X-Wing public key pk_M ‖ pk_X — the sender side when you hold only the recipient’s public half (e.g. a web-upload guest sealing an asset key to the link’s Drop Key, which travels in the URL fragment). Returns the X-Wing ciphertext ct_M ‖ ct_X (DEK_CIPHERTEXT_LEN bytes) and the 32-byte combined shared secret. Draws the encapsulation randomness from the OS CSPRNG.

A wrong-length public_bytes, or one whose ML-KEM half fails decoding, is rejected (CryptoError::Malformed / CryptoError::Key).