aries-framework-dotnet icon indicating copy to clipboard operation
aries-framework-dotnet copied to clipboard

Procedure for Creating and Retrieving Backup of the Wallet

Open naman20sharma opened this issue 3 years ago • 5 comments

CreateBackupAsync and RetrieveBackupAsync(or RestorFromBackupAsync) in Hyperledger.Aries.Routing.IEdgeClientService

I have few questions regarding Wallet Backups:

  1. Are these methods capable of creating and restoring wallet backups if I reinstall the application on different phone? Well I tried it myself, but as these methods have Context as an argument, which doesn't have an instance before the wallet is created. So, the backup was restored, but only in the case where app wasn't uninstalled. eg. I just deleted the credential and connection after creating the backup and restored it(using same seed), but didn't work if I uninstalled the app.

  2. Does Mediator's Inbox(in .IndyClient folder ) contains a backup or copy of the wallet? If 'yes' than can we access that for restoring wallet?

  3. Should I be looking into Hyperledger.Indy.WalletApi's ExportAsync & ImportAsync methods? As it seems to fix the problem of restoration of backups after reinstalling the application.

naman20sharma avatar Apr 08 '21 07:04 naman20sharma

@naman20sharma,

Types of Backup

  • Cloud Backup: Stored with the Mediator Agent (EdgeClientService.CreateBackupAsync)
  • File Backup: Exported to a file (AgentContext.Wallet.ExportAsync)

Steps to restore the backup

From Cloud Backup

  • Get the backup using the seed (string) (EdgeClientService.RetrieveBackupAsync)
  • Restore the backup (EdgeClientService.RestoreFromBackupAsync)

From File Backup

  • Create an attachment from the contents of the file (Attachment.Data.Base64)
  • Restore the backup (EdgeClientService.RestoreFromBackupAsync)

Below are the answers to your questions, with reference to Mobile Edge Agents

  1. Are these methods capable of creating and restoring wallet backups if I reinstall the application on different phone? A. The backups can be restored on the same device or onto another device (iOS and Android). The same backup can be restored on multiple devices

  2. Does Mediator's Inbox(in .IndyClient folder ) contains a backup or copy of the wallet? If 'yes' than can we access that for restoring wallet? A. Not sure about this. This needs to be explored further

  3. Should I be looking into Hyperledger.Indy.WalletApi's ExportAsync & ImportAsync methods? A. Refer to the steps above to backup and restore a wallet onto the same or a different device

sahil-khanna avatar Apr 15 '21 09:04 sahil-khanna

Hi @sahil-khanna thanks for your reply. I've been using Aries .NET sdk for over a year now. I've tried using the apis mentioned above. But, my concern was that (EdgeClientService.RetrieveBackupAsync) requires agentContext as an argument, and context is available post-provision (includes Creation) of the Wallet. So, do we need to create a new wallet first and only then can we retrieve the backup stored with the mediator agent ? If yes then attributes of the wallet like WalletCredentials.Key and connection with the mediator-agent will be new. So, does this restoration of the wallet replaces these attributes and connectionID (with the mediator) with the older one ?

naman20sharma avatar Apr 26 '21 05:04 naman20sharma

Hi @sahil-khanna thanks for your reply. I've been using Aries .NET sdk for over a year now. I've tried using the apis mentioned above. But, my concern was that (EdgeClientService.RetrieveBackupAsync) requires agentContext as an argument, and context is available post-provision (includes Creation) of the Wallet. So, do we need to create a new wallet first and only then can we retrieve the backup stored with the mediator agent ? If yes then attributes of the wallet like WalletCredentials.Key and connection with the mediator-agent will be new. So, does this restoration of the wallet replaces these attributes and connectionID (with the mediator) with the older one ?

From what I have seen so far

  • A wallet needs to be created before a backup can be restored.
  • When the wallet is restored, the data of the existing wallet is cleared/replaced with the restored data
  • Restoring the wallet will give the new AgentOptions. These need to be used henceforth AgentOptions agentOptions = await EdgeClientService.RestoreFromBackupAsync(AgentContext, seed)

Note: I haven't checked if the connectionId of the MediatorAgent will change after restoration. However, I believe the connectionId of the MediatorAgent will be of the restored (old) one.

sahil-khanna avatar Apr 30 '21 07:04 sahil-khanna

Hi @sahil-khanna,

I try to use the RestoreFromBackupAsync function, but I have a problem. I don't know what to do with the AgentOptions : when i try to use it in _edgeProvisioningService.ProvisionAsync(agentOptions) it return The wallet already exists but the restore works.

Everything is alright until I restart my Wallet : _agentContextProvider.GetContextAsync() return Hyperledger.Indy.WalletApi.WalletNotFoundException: The wallet does not exist.

Even if I store the AgentOption and try to ProvisionAsync when the app start, it doesn't work : GetContextAsync return the same Exception

Am I forgetting to do something?

Acarcan avatar Nov 02 '21 08:11 Acarcan

Hi @sahil-khanna,

I try to use the RestoreFromBackupAsync function, but I have a problem. I don't know what to do with the AgentOptions : when i try to use it in _edgeProvisioningService.ProvisionAsync(agentOptions) it return The wallet already exists but the restore works.

Everything is alright until I restart my Wallet : _agentContextProvider.GetContextAsync() return Hyperledger.Indy.WalletApi.WalletNotFoundException: The wallet does not exist.

Even if I store the AgentOption and try to ProvisionAsync when the app start, it doesn't work : GetContextAsync return the same Exception

Am I forgetting to do something?

Hi @Acarcan, did you get any success ?

naman20sharma avatar Jul 30 '22 13:07 naman20sharma