/// <inheritdoc /> public async Task <List <Attachment> > RetrieveBackupAsync(IAgentContext context, string seed, DateTimeOffset offset = default) { var provRecord = await provisioningService.GetProvisioningAsync(context.Wallet); var publicKey = provRecord.GetTag("backup_key"); if (string.IsNullOrEmpty(publicKey)) { throw new ArgumentException("No such key exists"); } var decodedKey = Multibase.Base58.Decode(publicKey); var publicKeySigned = await Crypto.SignAsync(context.Wallet, publicKey, decodedKey); var retrieveBackupResponseMessage = new RetrieveBackupAgentMessage() { BackupId = publicKey, Signature = publicKeySigned.ToBase64String() }; var connection = await GetMediatorConnectionAsync(context).ConfigureAwait(false); if (connection == null) { throw new AriesFrameworkException(ErrorCode.RecordNotFound, "Couldn't locate a connection to mediator agent"); } var response = await messageService.SendReceiveAsync <RetrieveBackupResponseAgentMessage>(context.Wallet, retrieveBackupResponseMessage, connection).ConfigureAwait(false); return(response.Payload); }
/// <inheritdoc /> public async Task <List <Attachment> > RetrieveBackupAsync(IAgentContext context, string seed, long offset = default) { var publicKey = await EnsureBackupKeyAsync(context, seed); var decodedKey = Multibase.Base58.Decode(publicKey); var publicKeySigned = await Crypto.SignAsync(context.Wallet, publicKey, decodedKey); var retrieveBackupResponseMessage = new RetrieveBackupAgentMessage() { BackupId = publicKey, Signature = publicKeySigned.ToBase64String() }; var connection = await GetMediatorConnectionAsync(context).ConfigureAwait(false); if (connection == null) { throw new AriesFrameworkException(ErrorCode.RecordNotFound, "Couldn't locate a connection to mediator agent"); } var response = await messageService.SendReceiveAsync <RetrieveBackupResponseAgentMessage>(context.Wallet, retrieveBackupResponseMessage, connection).ConfigureAwait(false); return(response.Payload); }