Skip to main content

Import Key

Import key allows to transit from an EOA wallet to an MPC wallet. This is a common use case in the digital wallet ecosystem where a wallet provider wants to onboard existing users from other wallets.

Although converting an EOA wallet to an MPC wallet increases security, it's important to note that the original private key still exists in full form. Therefore, we cannot provide the same level of security guarantees as with a natively generated MPC wallet, where the full private key is never assembled.

Step 1 : Create Session


Step 2 : Perform Import


  • Call duoSession.import() with all the required params (as explained below) which returns Result of Success with the keyId (a String) or Failure with exception. The imported keyshare is persisted to your StorageClient and addressed by that keyId.

Example


Example.kt
// import brings an existing private key under two-party MPC and returns the new
// keyId. The keyshare is persisted to your StorageClient — keep the keyId to
// address it in later operations (sign, refresh, export, delete, …).
suspend fun performKeyImport(keysharePrivateKey: ByteArray, duoSession: DuoSession): String {
return withContext(Dispatchers.IO) {
duoSession.import(
keysharePrivateKey = keysharePrivateKey, rootChainCode = getRootChainCode(),
).getOrThrow()
}
}
  • keysharePrivateKey: This is the private key to be imported. It's a 32 bytes ByteArray.
  • rootChainCode: This is the BIP32 root chain code used along with this private key. If it doesn't exist, please use a cryptographically secure random 32 bytes ByteArray.

You have now successfully imported an existing private key into an MPC wallet! 🎉