encrypt function

Uint8List encrypt({
  1. required Uint8List sign1,
  2. required Object? msgToAuth,
  3. required PublicKey recipient,
  4. required Uint8List domain,
})

Encrypts an already-signed COSE_Sign1 to a recipient.

For most use cases, prefer seal which signs and encrypts in one step. Use this only when re-encrypting a message (from decrypt) to a different recipient without access to the original signer's key.

  • sign1: The COSE_Sign1 structure (e.g., from decrypt)
  • msgToAuth: The same additional authenticated data used during sealing
  • recipient: The xHPKE public key to encrypt to
  • domain: Application domain for HPKE key derivation

Returns the serialized COSE_Encrypt0 structure.

Implementation

Uint8List encrypt({
  required Uint8List sign1,
  required Object? msgToAuth,
  required xhpke.PublicKey recipient,
  required Uint8List domain,
}) => ffi.coseEncrypt(
  sign1: sign1,
  msgToAuth: _encode(msgToAuth),
  recipient: recipient.inner,
  domain: domain,
);