Fix verify eip1271 signature in js sdk
@@ -326,9 +326,12 @@ export async function verifyERC1271Signature(
signerOrProvider: ethers.Signer | ethers.providers.Provider
): Promise<boolean> {
const EIP1271_SUCCESS_VALUE = '0x1626ba7e';
- const hash = utils.keccak256(message);
+
+ const prefixed_message = `\x19Ethereum Signed Message:\n32${utils.keccak256(message)}`;
+ const sign_message = utils.keccak256(prefixed_message);
+
const eip1271 = new ethers.Contract(address, IEIP1271_INTERFACE, signerOrProvider);
- const eipRetVal = await eip1271.isValidSignature(utils.hexlify(hash), signature);
+ const eipRetVal = await eip1271.isValidSignature(utils.hexlify(sign_message), signature);
return eipRetVal === EIP1271_SUCCESS_VALUE;
}
