Function Signature

offlineExportPrivateKey(params: {
  keyShares: any[];
  derivationPath?: string;
}): Promise<string>

Description

Exports a private key offline using key shares without requiring server communication. This function reconstructs the private key from the provided key shares locally.

Parameters

Required Parameters

  • keyShares (any[]) - Array of key shares to reconstruct the private key

Optional Parameters

  • derivationPath (string) - BIP-44 derivation path (defaults to “m/44’/60’/0’/0/0”)

Returns

  • Promise<string> - The exported private key as a hex string

Example

import { authenticatedEvmClient } from './client';

const evmClient = await authenticatedEvmClient();

const offlinePrivateKey = await evmClient.offlineExportPrivateKey({
  keyShares: [
    {
      chainName: 'base-sepolia',
      keyShare: '0x1234567890',
    },
  ],
  derivationPath: 'm/44\'/60\'/0\'/0/0', // optional
});

console.log('Offline private key:', offlinePrivateKey);

Key Share Format

interface KeyShare {
  chainName: string;
  keyShare: string;
}

const keyShares: KeyShare[] = [
  {
    chainName: 'base-sepolia', // or your specific chain
    keyShare: '0x1234567890', // the actual key share
  },
];

Error Handling

try {
  const offlinePrivateKey = await evmClient.offlineExportPrivateKey({
    keyShares,
    derivationPath: 'm/44\'/60\'/0\'/0/0',
  });
  console.log('Offline private key exported successfully');
} catch (error) {
  console.error('Failed to export offline private key:', error);
}

Security Considerations

  • Offline Operation: This function works without server communication
  • Key Share Security: Ensure key shares are kept secure
  • Local Processing: Private key reconstruction happens locally
  • Derivation Path: Use appropriate derivation path for your use case