import crypto from "crypto" ; import secp256k1 from "@node-lightning/secp256k1" ; param privKey export function validPrivateKey ( privKey ) { try { return secp256k1 . privateKeyVerify ( privKey ) ; } catch ( ex ) { return false ; } } param pubkey export function validPublicKey ( pubkey ) { try { return secp256k1 . publicKeyVerify ( pubkey ) ; } catch ( ex ) { return false ; } } remarks returns export function createPrivateKey ( ) { let result ; do { result = crypto . randomBytes ( 32 ) ; } while ( ! validPrivateKey ( result ) ) ; return result ; } param privKey returns export function getPublicKey ( privKey , compressed = true ) { return Buffer . from ( secp256k1 . publicKeyCreate ( privKey , compressed ) ) ; } param pubkey param compressed returns export function convertPublicKey ( pubkey , compressed = true ) { return Buffer . from ( secp256k1 . publicKeyConvert ( pubkey , compressed ) ) ; }