wcV1Decrypt function

String wcV1Decrypt(
  1. WcV1Payload payload,
  2. Uint8List key32
)

Verify HMAC then AES-256-CBC decrypt, returning the UTF-8 plaintext.

Implementation

String wcV1Decrypt(WcV1Payload payload, Uint8List key32) {
  if (!wcV1VerifyHmac(payload, key32)) {
    throw FormatException('WC v1: invalid HMAC');
  }
  final pt = aes256CbcDecrypt(
    key32,
    hexDecode(payload.iv),
    hexDecode(payload.data),
  );
  return utf8.decode(pt);
}