hyperledger-archives / aries-framework-dotnet

Aries Framework .NET for building multiplatform SSI services
https://wiki.hyperledger.org/display/aries
Apache License 2.0
84 stars 74 forks source link

Procedure for Creating and Retrieving Backup of the Wallet #182

Open naman20sharma opened 3 years ago

naman20sharma commented 3 years ago

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.

sahil-khanna commented 3 years ago

@naman20sharma,

Types of Backup

Steps to restore the backup

From Cloud Backup

From File Backup

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

naman20sharma commented 3 years ago

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 ?

sahil-khanna commented 3 years ago

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

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.

Acarcan commented 2 years ago

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?

naman20sharma commented 2 years ago

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 ?