decrypt function

Uint8List decrypt({
  1. required Uint8List msgToOpen,
  2. required Object? msgToAuth,
  3. required SecretKey recipient,
  4. required Uint8List domain,
})

Decrypts a sealed message without verifying the signature.

This allows inspecting the signer before verification. Use signer to extract the signer's fingerprint, then verify to verify.

  • msgToOpen: The serialized COSE_Encrypt0 structure
  • msgToAuth: The same additional authenticated data used during sealing
  • recipient: The xHPKE secret key to decrypt with
  • domain: Application domain for HPKE key derivation

Returns the decrypted COSE_Sign1 structure (not yet verified). Throws if the envelope is malformed, was encrypted to another key, or does not decrypt under recipient, msgToAuth and domain. Strips trailing zeros after the signed envelope and throws if any padding byte is nonzero.

Implementation

Uint8List decrypt({
  required Uint8List msgToOpen,
  required Object? msgToAuth,
  required xhpke.SecretKey recipient,
  required Uint8List domain,
}) => ffi.coseDecrypt(
  msgToOpen: msgToOpen,
  msgToAuth: _encode(msgToAuth),
  recipient: recipient.inner,
  domain: domain,
);