This commit is contained in:
Franck Royer 2021-07-02 11:44:04 +10:00
parent e9a1d88512
commit e59e9f4162
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 3 additions and 3 deletions

View File

@ -55,9 +55,9 @@ export async function createPublicKeyMessage(
* Validate that the EthDm Public Key was signed by the holder of the given Ethereum address.
*/
export function validatePublicKeyMessage(msg: PublicKeyMessage): boolean {
const formatedMsg = formatPublicKeyForSignature(msg.ethDmPublicKey);
const formattedMsg = formatPublicKeyForSignature(msg.ethDmPublicKey);
try {
const sigAddress = ethers.utils.verifyMessage(formatedMsg, msg.signature);
const sigAddress = ethers.utils.verifyMessage(formattedMsg, msg.signature);
const sigAddressBytes = Buffer.from(sigAddress.replace(/0x/, ''), 'hex');
// Compare the actual byte arrays instead of strings that may differ in casing or prefixing.
const cmp = sigAddressBytes.compare(new Buffer(msg.ethAddress));
@ -70,7 +70,7 @@ export function validatePublicKeyMessage(msg: PublicKeyMessage): boolean {
} catch (e) {
console.log(
'Failed to verify signature for Public Key Message',
formatedMsg,
formattedMsg,
msg
);
return false;