Recovery of ID from previous uPort app #346
Replies: 3 comments 5 replies
-
One interesting point: uPort generates a mnemonic seed of 12 words but the default I get from the entropyToMnemonic inside here is 24 words. |
Beta Was this translation helpful? Give feedback.
-
There are several things to be aware of before attempting this migration. Unfortunately, it's not as straight forward as just migrating the private key of the DID. I will try to list some of the things that are required to deal with the uPort data.
1. The uPort DID & key derivation pathsTo get from the mnemonic to the base account private key, the simplest way is something like so: import { HDNode } from '@ethersproject/hdnode'
const mnemonic = 'your mnemonic phrase here'
const UPORT_ROOT_DERIVATION_PATH = "m/7696500'/0'/0'/0'"
const hdnode = HDNode.fromMnemonic(mnemonic).derivePath(UPORT_ROOT_DERIVATION_PATH)
console.log(hdnode.privateKey)
//you can also quickly list the corresponding DID like so
console.log(`did:ethr:${hdnode.address}`) Using bip32 / bip39 is also possible to get to the private key. Make sure to not confuse mnemonic, entropy, seed, and private keys. import * as bip32 from 'bip32'
import * as bip39 from 'bip39'
const mnemonic = 'your mnemonic phrase here'
const UPORT_ROOT_DERIVATION_PATH = "m/7696500'/0'/0'/0'"
const seed = bip39.mnemonicToSeedSync(mnemonic)
const root = bip32.fromSeed(seed)
const node = root.derivePath(UPORT_ROOT_DERIVATION_PATH)
const privateKey = node.privateKey.toString("hex")
console.log("0x" + privateKey) a) app-specific accountsThe uPort app also uses app-specific accounts. These other addresses / accounts can be derived using the same method from above, but changing the derivation path to the corresponding account number: "m/7696500'/0'/1'/0'"
"m/7696500'/0'/2'/0'"
"m/7696500'/0'/3'/0'" If you are using multiple identities then these sub-account paths will look something like: "m/7696500'/1'/0'/0'"
"m/7696500'/1'/1'/0'"
"m/7696500'/1'/2'/0'"
"m/7696500'/1'/3'/0'" 2. uPort data backupDIDs, claims, credentials, interactions with various dApps and messaging between DIDs, etc... are all local to the uPort mobile app. There is no central server that manages these, nor are they stored in a global state machine like the ethereum network. There is an encrypted backup solution that you can enable from the mobile app but the protocol is very tightly coupled with the app architecture and it is not trivial to recover everything without using the app. This means that if you are not using the uPort app, it is not enough to recover the private key of the root DID to recover all the credentials. See also #202 about data synchronization between agents. How backup works in the uPort appThe app is built using If you want to recover all the credentials and interactions, you will have to recover the signing and encryption keys and then emulate the same calls to the backup service to rebuild the same state locally. Then, you'll probably want to extract all the credentials from this state tree and store them in a veramo agent. 3. A note on protocolsAll of the above is just about the data. While this would not be particularly difficult to achieve using custom veramo plugins, it is not on our roadmap at the moment because of resource constraints and the fact that the We can offer support only on a best effort basis, but I think it would be a testament to SSI if this kind of contributions came from the community of users. |
Beta Was this translation helpful? Give feedback.
-
@trentlarson Note that Veramo by default stores private keys in the database. In RN this is not encrypted or in a secure enclave (beyond manufacturers default device encryption) so ideally you would need create a HD identity plugin that creates and imports HD keys and stores them in the secure enclave. We have looked in using React Native KeyChain for this. It is something on our horizon but we don't have a specific timeline for it yet however if you decide to build this plugin, we of course could provide help / guidance with as it would be a valuable contribution. |
Beta Was this translation helpful? Give feedback.
-
My group and I have been using uPort (ie. the app on our phones) and I'd like to convert us to these new tools. I just tried by testing out the export into a mnemonic seed and then an import, and I can do both of those operations inside Veramo with the entropyToMnemonic/mnemonicToEntropy functions inside the bip39 library. Export is easy by calling the entropyToMnemonic on the privateKeyHex on the identifier; import is a bit harder, but I think this is the right way:
Unfortunately, this doesn't give me the same DID at the end.
Are there other ways to export from the mobile app? Can anyone comment on whether I've got problems in my import approach? I appreciate any help because I've got to find a way to migrate our IDs before I can start using this more extensively.
Beta Was this translation helpful? Give feedback.
All reactions