Convert SIWE message to utf8array before hashing

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2022-05-18 15:45:47 +02:00
committed by Alexis Sellier
parent 08a7cf6e14
commit c56a949778
+4 -1
View File
@@ -51,13 +51,16 @@ export class WalletConnectSigner extends ethers.Signer {
const prefix = ethers.utils.toUtf8Bytes(
`\x19Ethereum Signed Message:\n${message.length}`
);
const msg = ethers.utils.concat([prefix, message]);
const data = ((typeof(message) === "string") ? ethers.utils.toUtf8Bytes(message): message);
const msg = ethers.utils.concat([prefix, data]);
const address = await this.getAddress();
const keccakMessage = ethers.utils.keccak256(msg);
const signature = await this.walletConnect.signMessage([
address.toLowerCase(),
keccakMessage,
]);
return signature;
}