Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Procedure for Creating and Retrieving Backup of the Wallet #182

Open
naman20sharma opened this issue Apr 8, 2021 · 5 comments
Open

Procedure for Creating and Retrieving Backup of the Wallet #182

naman20sharma opened this issue Apr 8, 2021 · 5 comments

Comments

@naman20sharma
Copy link

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
Copy link

@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

@naman20sharma
Copy link
Author

naman20sharma commented Apr 26, 2021

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
Copy link

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.

@Acarcan
Copy link

Acarcan commented Nov 2, 2021

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
Copy link
Author

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 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants