recoverAndVerifySelfHierarchyKeys method

Future<Map<String, RecoveredKeyData>> recoverAndVerifySelfHierarchyKeys(
  1. List<KeyDataRecoveryRequest> keysData,
  2. KeyPairRecoverer keyPairRecoverer
)

Method called during initialisation of the crypto API to validate keys recovered through iCure's recovery methods and/or to allow recovery of missing keys using means external to iCure. On startup the iCure sdk will try to load all keys for the current data owner and its parent hierarchy: if the sdk can't find some of the keys for any of the data owners (according to the public keys for the data owner in the iCure server) and/or the sdk could recover some private keys but can't verify the authenticity of the key pairs this method will be called. The recovered and verified keys will automatically be cached using the current api {@link KeyStorageFacade} and {@link StorageFacade}

The input is a list containing an object for each data owner part of the current data owner hierarchy. The objects are ordered from the data for the topmost parent of the current data owner hierarchy (first element) to the data for the current data owner (last element).

The returned value must be an object associating to each data owner id an object with:

  • recoveredKeys:
  • keyAuthenticity: an object @param keysData all information on unknown and unavailable keys for each data owner part of the current data owner hierarchy. @param cryptoPrimitives cryptographic primitives you can use to support the process. @param keyPairRecoverer a key pair recoverer you can use to support the process @return a map that associates to each given data owner id the recovered data.

Implementation

Future<Map<String, RecoveredKeyData>> recoverAndVerifySelfHierarchyKeys(
  List<KeyDataRecoveryRequest> keysData,
  KeyPairRecoverer keyPairRecoverer
) {
  final res = <String, RecoveredKeyData>{};
  for (final it in keysData) {
    res[it.dataOwnerDetails.dataOwner.id] = const RecoveredKeyData(recoveredKeys: {}, keyAuthenticity: {});
  }
  return Future.value(res);
}