import * as crypto from 'crypto' ; import * as rsasign from 'jsrsasign' ; const curve = 'secp128r1' ; const ec = new rsasign . ECDSA ( { curve } ) ; export function hash ( string ) { return crypto . createHash ( 'sha256' ) . update ( string ) . digest ( 'hex' ) ; } export function generateKeyPair ( ) { const keypair = ec . generateKeyPairHex ( ) ; return [ keypair . ecpubhex , keypair . ecprvhex ] ; } export function signWithPrivateKey ( privateKey , dataHash ) { return ec . signHex ( dataHash , privateKey ) ; } export function verifyWithPublicKey ( publicKey , dataHash , signature ) { return ec . verifyHex ( dataHash , signature , publicKey ) ; }