Function Signature

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

Description

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

Parameters

Required Parameters

  • chainName (string) - The name of the blockchain chain (e.g., ‘base-sepolia’)
  • keyShares (any[]) - Array of key shares to reconstruct the key

Optional Parameters

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

Returns

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

Example

import { authenticatedEvmClient } from './client';

const evmClient = await authenticatedEvmClient();

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

console.log('Offline key:', offlineKey);

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 offlineKey = await evmClient.offlineExportKey({
    chainName: 'base-sepolia',
    keyShares,
    derivationPath: 'm/44\'/60\'/0\'/0/0',
  });
  console.log('Key exported offline successfully');
} catch (error) {
  console.error('Failed to export key offline:', error);
}

Security Considerations

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