Skip to main content

decrypt_receipt

Function decrypt_receipt 

Source
pub fn decrypt_receipt(
    encrypted_json: &str,
    key: &ReceiptDecryptionKey,
    location: &str,
) -> Result<Receipt>
Expand description

Decrypts an Encrypted Receipt fetched from a homeserver.

encrypted_json is the stored Encrypted Receipt JSON. key and location normally come from a ReceiptAccess message. The location path is authenticated as additional data, and the decrypted Receipt ID must match that path.

Receipt Decryption Keys are sensitive. ReceiptDecryptionKey redacts its Debug and Display output, but callers must still avoid logging raw values returned by ReceiptDecryptionKey::as_str.

ยงErrors

Returns PaykitError::InvalidData if the encrypted receipt is malformed, fails authenticated decryption, or decrypts to receipt data that does not match the Receipt Location.