getHcPartyKeyByOwner method
Implementation
Future<Uint8List?> getHcPartyKeyByOwner(String delegateId, String ownerId, RSAPrivateKey? myPrivateKey) async {
RSAPrivateKey? privateKey = myPrivateKey ?? rsaKeyPairs[ownerId]?.privateKey;
if (privateKey == null) {
throw FormatException("Missing key for hcp $delegateId");
}
Future<Map<String, Tuple2<String, Uint8List>>?>? keyMapFuture = dataOwnerResolver.getDataOwner(ownerId).then((hcp) {
var hcpnn = Map<String, String>.fromEntries(findKeysToDecrypt(hcp));
return decryptHcPartyKeys(hcpnn, delegateId, privateKey);
});
final Map<String, Tuple2<String, Uint8List>>? keyMap = await keyMapFuture;
if (keyMap == null) {
throw FormatException("Unknown hcp $ownerId");
}
return keyMap[delegateId]?.item2;
}