COSEPubKeyEncryption.deserialize constructor

COSEPubKeyEncryption.deserialize(
  1. CborTagValue<CborObject<Object?>> cbor
)

Implementation

factory COSEPubKeyEncryption.deserialize(CborTagValue cbor) {
  if (!BytesUtils.bytesEqual(tags, cbor.tags)) {
    throw ADAPluginException(
      "Invalid COSEPubKeyEncryption CBOR tag.",
      details: {"expected": tags, "tags": cbor.tags},
    );
  }
  final values = cbor.valueAs<CborListValue>('COSEPubKeyEncryption');
  return COSEPubKeyEncryption(
    headers: COSEHeaders(
      protected: COSEProtectedHeaderMap.deserialize(
        values.elementAt<CborBytesValue>(0),
      ),
      unprotected: COSEHeaderMap.deserialize(
        values.elementAt<CborMapValue>(1),
      ),
    ),
    ciphertext: values.elementAtBytes<List<int>?>(2),
    recipients: COSERecipients.deserialize(values.elementAt(3)),
  );
}