Skip to main content
Platform

Import Key

Import an existing private key into an MPC wallet. The key is split into two shares, one on the device, one on the Duo Server, so that after import it is never held in one place again. This is a common use case when onboarding existing EOA wallets into MPC custody.

Importing means the original private key existed in full at some point, so it does not carry the same "never assembled" guarantee as a key generated with keygen. The MPC security guarantees only apply after the import is complete. Handle the source key carefully.

App.tsx
import { type EcdsaSession } from '@silencelaboratories/silent-shard-sdk/ecdsa';

export const importKey = async (
session: EcdsaSession,
privateKey: string = '<PRIVATE_KEY_YOU_WANT_TO_IMPORT_IN_HEX>',
rootChainCode: string = '<BIP32 ROOT CHAIN CODE>'
) => {
const importConfig = {
privateKey,
rootChainCode,
};
const importedKeyshare = await session.import(importConfig);
console.log('Imported keyshare: ', importedKeyshare.keyIdHex);
};

Please refer to the Session creation guide to learn how to create a session.

  • session.import() takes an importConfig (an EcdsaImportConfig) object with privateKey and rootChainCode.
  • privateKey is the hex string of the private key to import (32 bytes).
  • rootChainCode is the BIP32 root chain code as a 32-byte hex string. If you don't have one, use a cryptographically secure random 32 bytes.
  • Returns a new keyshare (an Keyshare) representing the client's share of the now-split MPC wallet.