本文整理匯總了TypeScript中elliptic.ec.recoverPubKey方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ec.recoverPubKey方法的具體用法?TypeScript ec.recoverPubKey怎麽用?TypeScript ec.recoverPubKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類elliptic.ec
的用法示例。
在下文中一共展示了ec.recoverPubKey方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
export const recover = function(hash: Buffer, sig: Buffer): string {
const recovery = sig[64];
const signature = {
r: sig.slice(0, 32),
s: sig.slice(32, 64),
};
const ecPublicKey = secp256k1.recoverPubKey(hash, signature, recovery);
const publicKey = "0x" + ecPublicKey.encode("hex", false).slice(2);
const publicHash = EthLib.hash.keccak256(publicKey);
const address = EthLib.account.toChecksum("0x" + publicHash.slice(-40));
return address;
};