import { ec as EC } from 'elliptic' ; import { Bip39 , generateKeys } from './account' ; import { ensureLeading0x } from './address' ; const ec = new EC ( 'secp256k1' ) ; param { Buffer } privateKey returns { string } export function compressedPubKey ( privateKey ) { const key = ec . keyFromPrivate ( privateKey ) ; return ensureLeading0x ( key . getPublic ( true , 'hex' ) ) ; } param publicKey returns export function decompressPublicKey ( publicKey ) { return Buffer . from ( ec . keyFromPublic ( publicKey ) . getPublic ( false , 'hex' ) , 'hex' ) . slice ( 1 ) ; } param { string } privateKey returns { Buffer } export function deriveDek ( mnemonic , bip39ToUse ? ) { if ( ! mnemonic ) { throw new Error ( 'Invalid mnemonic' ) ; } return generateKeys ( mnemonic , undefined , 1 , 0 , bip39ToUse ) ; } export const DataEncryptionKeyUtils = { compressedPubKey , decompressPublicKey , deriveDek } ;