是否可以从tronweb和Azure密钥库触发Tron智能合约

时间:2019-12-19 11:52:20

标签: javascript azure tron tronweb

我正在考虑在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;
}

0 个答案:

没有答案