Skip to main content

wrap_payload_hpke

Function wrap_payload_hpke 

pub fn wrap_payload_hpke(
    payload: &[u8],
    secondary_payload: &[u8],
    hpke_public_key: &[u8],
    wrapper_algorithm: WrapperAlgorithm,
    label: &str,
) -> Result<(Vec<u8>, Vec<u8>), WrapPayloadError>
Expand description

Wrap a payload (plus optional secondary payload) in an outer layer of HPKE encryption using the specified [WrapperAlgorithm]. The algorithm and public key type MUST match.

label is fed to the HPKE EncryptContext as the domain-separation label. Use xmtp_configuration::WELCOME_HPKE_LABEL for welcome-flow compatibility.

For the XWingMLKEM768Draft6 algorithm, payload and secondary_payload are wrapped using the same HPKE public key. The first returned vec is the HpkeCiphertext with TLS serialization. The second vec is just ciphertext.