UNPKG

necjs

Version:
64 lines (63 loc) 2.12 kB
declare global { var Go: any; var mlkemKeyGen: () => any; var mlkemEncrypt: (pubKey: string, message: string) => any; var mlkemDecrypt: (privKey: string, encryptedData: string, version: string) => any; var symEncrypt: (ssKey: string, message: string) => any; var symDecrypt: (ssKey: string, encryptedData: string, version: string) => any; var privateKeyToWalletAddress: (pk: string) => any; var signTransactionMLDSA87: (TxObject: any, privateKeyHex: string) => any; var decodeRLPTransaction: (txHex: string) => any; var fs: typeof import('fs'); interface Crypto { getRandomValues(array: Uint8Array): void; } } /** * Public interface for MLKEM operations in Node.js */ export interface MlKemNode { /** * Generate a new keypair. * Resolves to an object: { pubKey: base64-string; privKey: base64-string }. */ keyGen(): Promise<{ pubKey: string; privKey: string; }>; /** * Asymmetric encrypt with the given public key. */ encrypt(pubKey: string, message: string): Promise<{ encryptedData: string; version: string; }>; /** * Asymmetric decrypt with the given private key. */ decrypt(privKey: string, encryptedData: string, version: string): Promise<string>; /** * Symmetric encrypt with the shared-secret key. */ symEncrypt(ssKey: string, message: string): Promise<{ encryptedData: string; version: string; }>; /** * Symmetric decrypt with the shared-secret key. */ symDecrypt(ssKey: string, encryptedData: string, version: string): Promise<string>; /** * Derive an EVM-style address (hex) from a raw private-key string. */ privateKeyToAddress(privateKey: string): string; /** * Sign a transaction object with the given private key. */ signTransactionMLDSA87: (TxObject: any, privateKeyHex: string) => any; decodeRLPTransaction: (txHex: string) => any; } /** * Load and initialize the MLKEM Go WebAssembly module. */ export declare function loadWasm(): Promise<MlKemNode>;