decryptDocument method
Implementation
Future<DecryptedDocumentDto> decryptDocument(String dataOwnerId, DocumentDto document) async {
final es = document.encryptedSelf;
if (es != null) {
final secret = (await this.crypto.decryptEncryptionKeys(dataOwnerId, document.encryptionKeys)).firstOrNull?.formatAsKey().fromHexString();
if (secret == null) {
throw FormatException("Cannot get encryption key fo ${document.id} and hcp $dataOwnerId");
}
return this.unmarshaller(document, base64.decoder.convert(es).decryptAES(secret));
} else {
return this.unmarshaller(document, null);
}
}