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
- Create TrioSession if you haven't already.
Step 2 : Perform Import
- Call trioSession.import() with
keysharePrivateKey(explained below) which returns Result of Success with akeyId(String) or Failure with exception.
Example
Example.kt
// import places an existing private key under three-party MPC and returns the
// new keyId. The resulting keyshare is persisted to your StorageClient — keep
// the keyId to address it in later operations.
suspend fun performKeyImport(keysharePrivateKey: ByteArray, trioSession: TrioSession): String {
return withContext(Dispatchers.IO) {
trioSession.import(
keysharePrivateKey = keysharePrivateKey
).getOrThrow()
}
}
keysharePrivateKey: This is the private key to be imported. It's a 32 bytesByteArray.
You have now successfully imported an existing private key into an MPC wallet! 🎉