findAndDecryptPotentiallyUnknownKeysForDelegate method

  1. @override
Future<Set<String>> findAndDecryptPotentiallyUnknownKeysForDelegate(
  1. String myId,
  2. String delegateId,
  3. Map<String, Set<DelegationDto>> keys
)
override

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;
}