openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
275 stars 202 forks source link

Create a migration script for AFJ updating an SQLite Indy SDK wallet to an SQLite Aries Askar wallet #1193

Closed TimoGlastra closed 1 year ago

TimoGlastra commented 1 year ago

Related to: https://github.com/hyperledger/aries-framework-javascript/issues/1164

Can be based on: andrewwhitehead/acapy-wallet-upgrade@main/bin/askar-upgrade.py (raw)

We need to create a migration script that allows to update an Indy based wallet to an Aries Askar based wallet.

In this issue only focus on the upgrade of an SQLite based Indy SDK to an SQLite based Aries Askar wallet. We'll likely make it a separate addon (TBD) because it requires an sqlite execution environment which is different per platform.

The steps (taken from the acapy upgrade script) are:

  1. Run Pre Upgrade script that directly executes SQLite on the encrypted storage
  2. Register a new Askar profile using SQLite (which uses the indy key)
  3. Loop through all items stored in the indy database and re-encrypt them in the askar structure
  4. remove old indy SDK tables
  5. Apply post upgrade transformations directly using Askar. See "Updates" for the list of updates

Updates

Once the wallet database has been transformed to an Askar compliant interface there's still records that use the Indy SDK style context structure. All records that aren't created by AFJ, but internal by the Indy SDK (e.g. the private parts of a credential definition) need to be fetched, transformed to an storage record and the re-saved.

Using storage records for all those objects means that from now on the storage storage is completely separated from the rest of the codebase (i.e. you can swap out askar and it will work fine)

The updates that need to happen (may be missing things):

berendsliedrecht commented 1 year ago

I think it looks good, not too familiar with the storage internals.

You mentioned Indy::Schema twice where the second one misses the point about the private parts and to my knowledge there are no private parts, as that would mean that you cannot reuse someone else's schema, right?

Re Indy::CredentialDefinition, I think it would be good to split the private parts from the public parts. We will likely fetch the public parts a lot for issuance and such and not directly work with the private parts all that much (I assume). When we fetch the public parts from the wallet, it would be good not to load the private parts into memory.

Re Indy::Credential, I have never heard of an indy-isms, what is that?

TimoGlastra commented 1 year ago

Relevant repo currently being worked on: https://github.com/Indicio-tech/acapy-wallet-upgrade