Function Signature

offlineExportPrivateKey(params: {
  keyShares: (EcdsaKeygenResult | Ed25519KeygenResult)[];
  derivationPath?: string;
}): Promise<{ derivedPrivateKey: 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 ((EcdsaKeygenResult | Ed25519KeygenResult)[]) - 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<{ derivedPrivateKey: string }> - Object containing the exported private key

Example

import { authenticatedEvmClient } from './client';

const evmClient = await authenticatedEvmClient();

const result = await evmClient.offlineExportPrivateKey({
  keyShares: [
    // EcdsaKeygenResult or Ed25519KeygenResult objects
  ],
  derivationPath: 'm/44\'/60\'/0\'/0/0', // optional
});

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

Key Share Format

// Key shares can be either EcdsaKeygenResult or Ed25519KeygenResult
const keyShares: (EcdsaKeygenResult | Ed25519KeygenResult)[] = [
  // Key share objects
];

Error Handling

try {
  const result = 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