我正在考虑为我在 Azure 上的 erc-20 令牌开发 Tron 和以太坊链之间的桥梁,并将我的私钥存储在 Azure 密钥库中。对于以太坊,我为此找到了一个不错的库:https://github.com/tmarkovski/ethereumjs-tx-keyvault,但是相同的方法在 tronweb 中是否有效?tronweb 使用 elliptic.js 进行签名:
export function ECKeySign(hashBytes, priKeyBytes) {
const ec = new EC("secp256k1");
const key = ec.keyFromPrivate(priKeyBytes, "bytes");
const signature = key.sign(hashBytes);
const r = signature.r;
const s = signature.s;
const 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}`;
}
const idHex = byte2hexStr(id);
const signHex = rHex + sHex + idHex;
return signHex;
}