Import Key
Please refer to the Session creation section to learn how to create a new session.
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.
Full example:
- ECDSA
- EdDSA
App.tsx
import { EcdsaSession } from '@silencelaboratories/silent-shard-sdk';
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.publicKeyHex);
};
App.tsx
import { EddsaSession } from '@silencelaboratories/silent-shard-sdk';
export const importKey = async (
session: EddsaSession,
// The private key to be imported. It's a 32 bytes hex string.
privateKey: string = '<PRIVATE_KEY_YOU_WANT_TO_IMPORT_IN_HEX>'
) => {
const importConfig = {
privateKey,
};
const importedKeyshare = await session.import(importConfig);
console.log('Imported keyshare: ', importedKeyshare.publicKeyHex);
};
privateKey
: This is the private key to be imported. It's a 32 bytes hex string.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 hex string.- The
importConfig
contains the required information to import the private key into an MPC wallet. - Import the private key and create a new keyshare using the
session.import()
method.
You have now successfully imported an existing private key into an MPC wallet! 🎉