Function Signature

encryptKeyShare(params: {
  keyShare: any;
  password: string;
}): Promise<string>

Description

Encrypts a key share using the provided password. This function is used for secure storage and transmission of key shares.

Parameters

Required Parameters

  • keyShare (any) - The key share to encrypt
  • password (string) - Password for encrypting the key share

Returns

  • Promise<string> - The encrypted key share as a string

Example

import { authenticatedEvmClient } from './client';

const evmClient = await authenticatedEvmClient();

const encryptedShare = await evmClient.encryptKeyShare({
  keyShare: {
    chainName: 'base-sepolia',
    keyShare: '0x1234567890',
  },
  password: 'your-encryption-password',
});

console.log('Encrypted share:', encryptedShare);

Key Share Format

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

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

Error Handling

try {
  const encryptedShare = await evmClient.encryptKeyShare({
    keyShare,
    password: 'your-encryption-password',
  });
  console.log('Key share encrypted successfully');
} catch (error) {
  console.error('Failed to encrypt key share:', error);
}