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.

note

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 Keyshare bytes as Data or Failure with error.

Example


Example.swift
func performKeyImport(keysharePrivateKey: Data, duoSession: DuoSession) async -> Data?
{
let result = await duoSession.import(
privateKey: keysharePrivateKey, rootChainCode: getRootChainCode())
// returns nil if operation fails
switch result {
case .success(let dataBytes):
do {
// do something with Keyshare bytes
Swift.print(dataBytes)
return dataBytes
}
case .failure(let error):
do {
// show error to user or abort process
Swift.print(error)
return nil
}
}
}
  • keysharePrivateKey: This is the private key to be imported. It's a 32 bytes as Data.
  • 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 Data.

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