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 returnsResultofSuccesswith the imported key'skeyIdas aStringorFailurewitherror.
Example
Example.swift
// import places a raw private key back under three-party MPC and returns the
// new keyId. The keyshare is persisted to your StorageClient.
func performKeyImport(keysharePrivateKey: Data, trioSession: TrioSession) async -> String? {
let result: Result<String, any Error> = await trioSession.import(
keysharePrivateKey: keysharePrivateKey
)
// returns nil if the operation fails, or handle it however your flow needs
switch result {
case .success(let keyId):
// do something with the keyId
Swift.print(keyId)
return keyId
case .failure(let error):
// show the error to the user or abort the process
Swift.print(error)
return nil
}
}
keysharePrivateKey: This is the private key to be imported. It's a 32 bytes asData.
You have now successfully imported an existing private key into an MPC wallet! 🎉