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 { type EcdsaSession } from '@silencelaboratories/silent-shard-sdk';
export const importKey = async (
session: EcdsaSession,
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);
};
App.tsx
import { type EddsaSession } from '@silencelaboratories/silent-shard-sdk';
export const importKey = async (
session: EddsaSession,
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.- The
importConfig(EcdsaImportConfig) contains the required information to import the private key into an MPC wallet. - Import the private key and create a new keyshare(Keyshare) using the
session.import()method.
You have now successfully imported an existing private key into an MPC wallet! 🎉