diff --git a/contracts/TestERC1271.sol b/contracts/TestERC1271.sol index 2684bf0..61f7af1 100644 --- a/contracts/TestERC1271.sol +++ b/contracts/TestERC1271.sol @@ -28,21 +28,20 @@ contract TestERC1271 is ERC1271 { /** * Check if a signature is valid * - * @param _data Data signed over - * @param _signature Encoded signature + * @param _hash Hash of the data to be signed + * @param _signature Signature encoded as (bytes32 r, bytes32 s, uint8 v) * @return magicValue Magic value if valid, zero-value otherwise */ function isValidSignature( - bytes memory _data, + bytes32 _hash, bytes memory _signature) override public view returns (bytes4 magicValue) { - bytes32 hash = abi.decode(_data, (bytes32)); (uint8 v, bytes32 r, bytes32 s) = abi.decode(_signature, (uint8, bytes32, bytes32)); - if (owner == ecrecover(hash, v, r, s)) { + if (owner == ecrecover(_hash, v, r, s)) { return MAGICVALUE; } else { return SIGINVALID; diff --git a/contracts/exchange/ExchangeCore.sol b/contracts/exchange/ExchangeCore.sol index ebe675b..f627444 100644 --- a/contracts/exchange/ExchangeCore.sol +++ b/contracts/exchange/ExchangeCore.sol @@ -21,7 +21,7 @@ import "../registry/AuthenticatedProxy.sol"; */ contract ExchangeCore is ReentrancyGuarded, StaticCaller, EIP712 { - bytes4 constant internal EIP_1271_MAGICVALUE = 0x20c13b0b; + bytes4 constant internal EIP_1271_MAGICVALUE = 0x1626ba7e; bytes internal personalSignPrefix = "\x19Ethereum Signed Message:\n"; /* Struct definitions. */ @@ -184,7 +184,7 @@ contract ExchangeCore is ReentrancyGuarded, StaticCaller, EIP712 { /* (c): Contract-only authentication: EIP/ERC 1271. */ if (isContract) { - if (ERC1271(maker).isValidSignature(abi.encodePacked(calculatedHashToSign), signature) == EIP_1271_MAGICVALUE) { + if (ERC1271(maker).isValidSignature(calculatedHashToSign, signature) == EIP_1271_MAGICVALUE) { return true; } return false; diff --git a/contracts/lib/EIP1271.sol b/contracts/lib/EIP1271.sol index 6ebfb96..e968caa 100644 --- a/contracts/lib/EIP1271.sol +++ b/contracts/lib/EIP1271.sol @@ -8,23 +8,23 @@ pragma solidity 0.7.5; abstract contract ERC1271 { - // bytes4(keccak256("isValidSignature(bytes,bytes)") - bytes4 constant internal MAGICVALUE = 0x20c13b0b; + // bytes4(keccak256("isValidSignature(bytes32,bytes)") + bytes4 constant internal MAGICVALUE = 0x1626ba7e; /** - * @dev Should return whether the signature provided is valid for the provided data - * @param _data Arbitrary length data signed on the behalf of address(this) - * @param _signature Signature byte array associated with _data + * @dev Should return whether the signature provided is valid for the provided hash + * @param _hash Hash of the data to be signed + * @param _signature Signature byte array associated with _hash * - * MUST return the bytes4 magic value 0x20c13b0b when function passes. + * MUST return the bytes4 magic value 0x1626ba7e when function passes. * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) * MUST allow external calls - */ + */ function isValidSignature( - bytes memory _data, - bytes memory _signature) - virtual - public - view - returns (bytes4 magicValue); -} + bytes32 _hash, + bytes memory _signature) + virtual + public + view + returns (bytes4 magicValue); +} \ No newline at end of file diff --git a/test/4-wyvern-exchange-basics.js b/test/4-wyvern-exchange-basics.js index ace25f1..e241ce5 100755 --- a/test/4-wyvern-exchange-basics.js +++ b/test/4-wyvern-exchange-basics.js @@ -59,7 +59,7 @@ contract('WyvernExchange',accounts => { it('does not validate order parameters with expirationTime before now',async () => { let {exchange,registry} = await withExchangeAndRegistry() - let example = {registry: registry.address,maker: accounts[0],staticTarget: exchange.inst.address,staticSelector: '0x00000000',staticExtradata: '0x',maximumFill: '1',listingTime: '0',expirationTime: '0',salt: '0'} + let example = {registry: registry.address,maker: accounts[0],staticTarget: exchange.inst.address,staticSelector: '0x00000000',staticExtradata: '0x',maximumFill: '1',listingTime: '0',expirationTime: '1',salt: '0'} assert.isFalse(await exchange.validateOrderParameters(example),'Should not have validated') })