Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
signMessage(key: KeyPair, message: string | Buffer): Buffer {
const toSign = this.toHexString(message);
let prv = key.prv;
if (this.isValidXprv(prv)) {
prv = HDNode.fromBase58(prv)
.getKey()
.getPrivateKeyBuffer();
}
let sig = bitgoAccountLib.Trx.Utils.signString(toSign, prv, true);
// remove the preceding 0x
sig = sig.replace(/^0x/, '');
return Buffer.from(sig, 'hex');
}
compressedPubToHexAddress(pub: string): string {
const byteArrayAddr = bitgoAccountLib.Trx.Utils.getByteArrayFromHexAddress(pub);
const rawAddress = bitgoAccountLib.Trx.Utils.getRawAddressFromPubKey(byteArrayAddr);
return bitgoAccountLib.Trx.Utils.getHexAddressFromByteArray(rawAddress);
}