Create MPC Keys - ECDSA
Create MPC key shares for ECDSA assets using the BitGo SDK. See the Guide.
-
Create MPC key shares for ECDSA assets (such as ETH and MATIC) by exchanging public and encrypted-private shares between all parties (user, backup, and BitGo). The SDK handles the key share exchange automatically.
Unlike multisignature wallets, you must manage the backup key yourself — it can't be managed by a key recovery service (KRS). The
userKeychainandbackupKeychainfields contain a largeencryptedPrv. ThereducedEncryptedPrvfield matches what appears on KeyCards generated in the web UI.Prerequisites: You must have a BitGo account. See Get Started.
// 1. Create Keys
// Use the JavaScript SDK for MPC key creation (see JavaScript tab)
// 1. Create Keys
import * as dotenv from "dotenv";
dotenv.config();
import { EnvironmentName } from "bitgo";
import { BitGoAPI } from "@bitgo/sdk-api";
import { Hteth } from "@bitgo/sdk-coin-eth";
const config = {
USERNAME: process.env.USERNAME as string,
PASSWORD: process.env.PASSWORD as string,
ENV: process.env.ENV as EnvironmentName,
OTP: process.env.OTP as string,
ENTERPRISE_ID: process.env.ENTERPRISE_ID as string,
};
const bitgo = new BitGoAPI({ env: config.ENV });
bitgo.register("hteth", Hteth.createInstance);
const coin = bitgo.coin("hteth");
async function auth() {
await bitgo.authenticate({
username: config.USERNAME,
password: config.PASSWORD,
otp: config.OTP,
});
}
async function main() {
await auth();
const keychains = await coin.keychains().createMpc({
multisigType: "tss",
passphrase: config.PASSWORD,
enterprise: config.ENTERPRISE_ID,
});
console.log(keychains);
}
main().catch((err) => console.error(err));
// 1. Create Keys Response
{
"userKeychain": {
"id": "6674a960bb9d6a5d41228bfcf8d15724",
"source": "user",
"type": "tss",
"commonKeychain": "032ba30f224e85a300fdc94eb28b37c83d0435e706389db33e0b977ad15b94edbc63b15dee6045330287bc9ccd33522a6e50c90a5f7e845e6dbc6299556e3619c6",
"encryptedPrv": "string",
"reducedEncryptedPrv": "string"
},
"backupKeychain": {
"id": "6674a96064bda5f82a6f95efc7ad656e",
"source": "backup",
"type": "tss",
"commonKeychain": "032ba30f224e85a300fdc94eb28b37c83d0435e706389db33e0b977ad15b94edbc63b15dee6045330287bc9ccd33522a6e50c90a5f7e845e6dbc6299556e3619c6",
"encryptedPrv": "string",
"reducedEncryptedPrv": "string"
},
"bitgoKeychain": {
"id": "6674a95f38be1dec30ce8f2ae40489c4",
"source": "bitgo",
"type": "tss",
"commonKeychain": "032ba30f224e85a300fdc94eb28b37c83d0435e706389db33e0b977ad15b94edbc63b15dee6045330287bc9ccd33522a6e50c90a5f7e845e6dbc6299556e3619c6",
"isBitGo": true
}
}