unwrapKey method
Decrypt key and validate decryption, if applicable
Implementation
JsonWebKey unwrapKey(List<int> data, {String? algorithm}) {
_assertCanDo('unwrapKey');
algorithm ??= this.algorithm;
var decrypter =
_keyPair.privateKey!.createEncrypter(_getAlgorithm(algorithm));
var v = decrypter.decrypt(EncryptionResult(Uint8List.fromList(data)));
return JsonWebKey.fromJson({
'kty': 'oct',
'k': encodeBase64EncodedBytes(v),
'use': 'enc',
'keyOperations': ['encrypt', 'decrypt']
})!;
}