getDelegateHcPartyKey method
Implementation
Future<Uint8List?> getDelegateHcPartyKey(String delegateId, String ownerId, RSAPrivateKey? myPrivateKey) async {
final delegateIdOwnerIdKey = _getDelegateIdOwnerIdKeyForCache(delegateId, ownerId);
Future<Uint8List?>? keyFuture = delegateHcpartyKeysCache[delegateIdOwnerIdKey];
if (keyFuture == null) {
RSAPrivateKey? privateKey = myPrivateKey ?? rsaKeyPairs[delegateId]?.privateKey;
if (privateKey == null) {
throw FormatException("Missing key for hcp $delegateId");
}
keyFuture = dataOwnerResolver.getDataOwnerKeysForDelegate(delegateId).then((hcpk) async {
final keyMap = await hcpk.let((hcpnn) => decryptHcPartyKeys(hcpnn, delegateId, privateKey));
var response = keyMap[ownerId]?.item2;
if (response == null) {
throw FormatException("Missing share for $ownerId");
}
return response;
});
delegateHcpartyKeysCache[delegateIdOwnerIdKey] = keyFuture;
}
return keyFuture;
}