findAndDecryptPotentiallyUnknownKeysForDelegate method
Implementation
@override
Future<Set<String>> findAndDecryptPotentiallyUnknownKeysForDelegate(String myId, String delegateId, Map<String, Set<DelegationDto>> keys) async {
final allDecrypted = await decryptEncryptionKeys(myId, keys);
final Map<String, Set<DelegationDto>> meAndDelegateKeys = {};
final delegateToMeKeys = (keys[myId] ?? {}).where((element) => element.owner == delegateId).toSet();
final meToDelegateKeys = (keys[delegateId] ?? {}).where((element) => element.owner == myId).toSet();
if (delegateToMeKeys.isNotEmpty) {
meAndDelegateKeys[myId] = delegateToMeKeys;
}
if (meToDelegateKeys.isNotEmpty) {
meAndDelegateKeys[delegateId] = meToDelegateKeys;
}
final decryptedForDelegate = await decryptEncryptionKeys(myId, meAndDelegateKeys);
allDecrypted.removeAll(decryptedForDelegate);
return allDecrypted;
}