本文整理匯總了TypeScript中ethers.ethers.utils.recoverAddress方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ethers.utils.recoverAddress方法的具體用法?TypeScript ethers.utils.recoverAddress怎麽用?TypeScript ethers.utils.recoverAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ethers.ethers.utils
的用法示例。
在下文中一共展示了ethers.utils.recoverAddress方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: validateSignatures
private validateSignatures(
message: InternalMessage,
next: Function,
context: Context
) {
const operation = context.intermediateResults.operation!;
const digest = operation.hashToSign();
let sig;
const expectedSigningAddress =
message.clientMessage.toAddress === this.signingKey.address
? message.clientMessage.fromAddress
: message.clientMessage.toAddress;
if (message.clientMessage.signature === undefined) {
// initiator
const incomingMessage = context.intermediateResults.inbox!;
sig = incomingMessage.signature;
} else {
// receiver
sig = message.clientMessage.signature;
}
const recoveredAddress = ethers.utils.recoverAddress(digest, {
v: sig.v,
r: sig.r,
s: sig.s
});
if (recoveredAddress !== expectedSigningAddress) {
// FIXME: handle this more gracefully
// https://github.com/counterfactual/monorepo/issues/93
throw Error("Invalid signature");
}
}