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
main.dart
import 'package:silent_shard_sdk/silent_shard_sdk.dart' as sdk;
Future<void> importKey(
sdk.EcdsaSession session,
String privateKey, // PRIVATE_KEY_YOU_WANT_TO_IMPORT_IN_HEX
String? rootChainCode // BIP32 ROOT CHAIN CODE
) async {
final keyshare = await session.import(privateKey: privateKey, rootChainCode: rootChainCode);
print('Imported keyshare ${keyshare.publicKeyHex}');
}
main.dart
import 'package:silent_shard_sdk/silent_shard_sdk.dart' as duo;
Future<void> importKey(
duo.EddsaSession session,
String privateKey, // PRIVATE_KEY_YOU_WANT_TO_IMPORT_IN_HEX
) async {
final keyshare = await session.import(privateKey: privateKey);
print('Imported keyshare ${await keyshare.publicKeyHex()}');
}
- Import the private key and create a new keyshare using the
session.import()
method. 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.
You have now successfully imported an existing private key into an MPC wallet! 🎉