src/utils/crypto.js
function ECKeySign(hashBytes, priKeyBytes) {
  let ec = new EC('secp256k1');
  let key = ec.keyFromPrivate(priKeyBytes, 'bytes');
  let signature = key.sign(hashBytes);
  let r = signature.r;
  let s = signature.s;
  let id = signature.recoveryParam;
  let rHex = r.toString('hex');
  while (rHex.length < 64) {
    rHex = "0" + rHex;
  }
  let sHex = s.toString('hex');
  while (sHex.length < 64) {
    sHex = "0" + sHex;
  }
  let idHex = byte2hexStr(id);
  let signHex = rHex + sHex + idHex;
  return hexStr2byteArray(signHex);
}
function ECKeySign(hashBytes, priKeyBytes) {
  let ec = new EC('secp256k1');
  let key = ec.keyFromPrivate(priKeyBytes, 'bytes');
  let signature = key.sign(hashBytes);
  let r = signature.r;
  let s = signature.s;
  let id = signature.recoveryParam;
  let rHex = r.toString('hex');
  while (rHex.length < 64) {
    rHex = "0" + rHex;
  }
  let sHex = s.toString('hex');
  while (sHex.length < 64) {
    sHex = "0" + sHex;
  }
  let idHex = byte2hexStr(id);
  let signHex = rHex + sHex + idHex;
  return hexStr2byteArray(signHex);
}
function ECKeySign ( hashBytes , priKeyBytes ) { let ec = new EC ( 'secp256k1' ) ; let key = ec . keyFromPrivate ( priKeyBytes , 'bytes' ) ; let signature = key . sign ( hashBytes ) ; let r = signature . r ; let s = signature . s ; let id = signature . recoveryParam ; let rHex = r . toString ( 'hex' ) ; while ( rHex . length < 64 ) { rHex = "0" + rHex ; } let sHex = s . toString ( 'hex' ) ; while ( sHex . length < 64 ) { sHex = "0" + sHex ; } let idHex = byte2hexStr ( id ) ; let signHex = rHex + sHex + idHex ; return hexStr2byteArray ( signHex ) ; }
return sign by 65 bytes r s id. id < 27
return sign by 65 bytes r s id . id < 27