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