openwallet-foundation / credo-ts

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

Importing the wallet using askar in react native fails #1526

Closed ghost closed 1 year ago

ghost commented 1 year ago

When using the Askar wallet in React Native import wallet fails with the following error

ERROR  ERROR: Error importing wallet 'newWalletId': Error decrypting profile key
Caused by: AEAD decryption error {
  "error": {
    "name": "Error",
    "stack": "Error: Error decrypting profile key\nCaused by: AEAD decryption error\n    at construct (native)\n    at Wrapper (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.testexport&modulesOnly=false&runModule=true:27130:64)\n    at construct (native)\n    at _createSuperInternal (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.testexport&modulesOnly=false&runModule=true:253087:406)\n    at call (native)\n    at AriesAskarError (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.testexport&modulesOnly=false&runModule=true:253102:26)\n    at _cb (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.testexport&modulesOnly=false&runModule=true:256038:109)",
    "message": "Error decrypting profile key\nCaused by: AEAD decryption error",
    "code": 4
  },
  "errorMessage": "Error decrypting profile key\nCaused by: AEAD decryption error"
}

Observation while debugging the error was:

I have created a repo that reproduces this error here - Askar-Walllet-React-Native

berendsliedrecht commented 1 year ago

You have to explicitly migrate the structure of the wallet from Indy sdk to askar. https://aries.js.org/guides/0.4/updating/update-indy-sdk-to-askar

ghost commented 1 year ago

@berendsliedrecht While exporting the wallet also I am using the Askar wallet only.

berendsliedrecht commented 1 year ago

@berendsliedrecht While exporting the wallet also I am using the Askar wallet only.

Ah, my bad. I am not too familiar with the exporting mechanism but from the error I assume that one of the keys you used is incorrect.

ghost commented 1 year ago

@berendsliedrecht Yes, the error is being shown as the key is incorrect but I am using the same backup key still it is showing the same I have created a repo for the same here. @genaris Can you also please check this. ?

genaris commented 1 year ago

@sairanjitAW thank you very much to generate a repo to easily reproduce the issue!

It seems it's a problem with Aries Askar wrapper for React Native. Store rekey is not calling the right method, so the key is in fact never changed. I opened a PR in aries-askar to fix it.

For the time being you can use a patched version that I added as a PR for your repo.

ghost commented 1 year ago

Thank You @genaris for the fix