Skip to main content
Platform

Export Key

Reconstruct and export the full private key of the MPC wallet by combining both shares. Use this to move a wallet out of MPC, for example into another wallet ecosystem.

Once the private key is exported, the MPC security guarantees are lost.

Export is not exposed directly in the client SDK. Instead, you make a POST request to the cloud node's export endpoint to retrieve the server's encrypted share, then use the SDK's export method to combine both shares and recover the full private key.

It's your responsibility to expose this endpoint securely. For example:

  • When a user requests export, your backend authenticates them (2FA, etc.).
  • Your backend calls the cloud node's export endpoint and returns the encrypted share to the client.
  • The client uses the SDK's export method to decrypt and combine the shares.

Never expose the export endpoint directly to users.

App.tsx
import { ecdsaKeyExport, type EcdsaSession } from '@silencelaboratories/silent-shard-sdk/ecdsa';
import * as duo from '@silencelaboratories/dkls-sdk';
import { Platform } from 'react-native';

const CLOUD_NODE_URI = Platform.select({ android: '10.0.2.2', ios: 'localhost' }) + ':8080';

export const exportKey = async (session: EcdsaSession) => {
// Creating a new keyshare for demo purpose. In real application, you can use an existing keyshare.
const keyshare = await session.keygen();
console.log('Keyshare: ', keyshare.keyIdHex);

// Export
const encryptionKey = await duo.EncryptionKey.create();
const exportRes = await fetch(`http://${CLOUD_NODE_URI}/v3/ecdsa/export`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
key_id: keyshare.keyIdHex, // Use Hex version of keyId for server request
client_enc_pubkey: encryptionKey.publicKeyHex,
}),
});

const exportJson = await exportRes.json();

const exportConfig = {
keyshare: keyshare,
client_secret_key: encryptionKey.privateKeyB64,
server_public_key: exportJson.server_public_key,
encrypted_server_share: exportJson.enc_server_share,
};

const privateKeyHex = await ecdsaKeyExport(exportConfig);
console.log('Exported private key: ', privateKeyHex);
};

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

Step 1: Fetch the server's encrypted share. Make a POST request to the export endpoint (/v3/ecdsa/export or /v3/eddsa/export) with:

  • key_id: the keyshare's key ID (hex string, from the Keyshare's keyIdHex)
  • client_enc_pubkey: an encryption public key generated via EncryptionKey.create()

Step 2: Combine shares. Pass the response and your keyshare to ecdsaKeyExport(), which takes an EcdsaExportConfig with:

  • keyshare: your client share (a Keyshare)
  • client_secret_key: the private key from your encryption key pair
  • server_public_key: from the export endpoint response
  • encrypted_server_share: from the export endpoint response

Returns privateKeyHex: the full private key in hex format.