From 78e216d1570a2f4b41715b0602e4606659a2f512 Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Tue, 13 Feb 2018 15:27:43 -0800 Subject: Implement EIP712 at verify-signature call site --- .../current/protocol/Exchange/LibOrder.sol | 17 +++++++++++++++- .../protocol/Exchange/MixinExchangeCore.sol | 4 ++-- .../protocol/Exchange/MixinSignatureValidator.sol | 23 +--------------------- 3 files changed, 19 insertions(+), 25 deletions(-) (limited to 'packages') diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol index f4d031510..7f01fc1b7 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol @@ -19,7 +19,22 @@ pragma solidity ^0.4.19; contract LibOrder { - + + bytes32 constant orderSchemaHash = keccak256( + "address exchangeContractAddress", + "address makerAddress", + "address takerAddress", + "address makerTokenAddress", + "address takerTokenAddress", + "address feeRecipientAddress", + "uint256 makerTokenAmount", + "uint256 takerTokenAmount", + "uint256 makerFeeAmount", + "uint256 takerFeeAmount", + "uint256 expirationTimestamp", + "uint256 salt" + ); + struct Order { address maker; address taker; diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol index 4f7c3d4a1..7000f6389 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol @@ -102,7 +102,7 @@ contract MixinExchangeCore is require(order.makerTokenAmount > 0); require(order.takerTokenAmount > 0); require(isValidSignature( - order.orderHash, + keccak256(orderSchemaHash, order.orderHash), order.maker, signature )); @@ -188,7 +188,7 @@ contract MixinExchangeCore is require(order.takerTokenAmount > 0); require(takerTokenCancelAmount > 0); require(isValidSignature( - order.orderHash, + keccak256(orderSchemaHash, order.orderHash), order.maker, signature )); diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol index 179b1b02c..e243eade1 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol @@ -32,22 +32,6 @@ contract MixinSignatureValidator is EIP712, Contract } - - bytes32 public constant orderSchemaHash = keccak256( - "address exchangeContractAddress", - "address makerAddress", - "address takerAddress", - "address makerTokenAddress", - "address takerTokenAddress", - "address feeRecipientAddress", - "uint256 makerTokenAmount", - "uint256 takerTokenAmount", - "uint256 makerFeeAmount", - "uint256 takerFeeAmount", - "uint256 expirationTimestamp", - "uint256 salt" - ); - function isValidSignature( bytes32 hash, @@ -98,12 +82,7 @@ contract MixinSignatureValidator is v = uint8(signature[1]); r = get32(signature, 2); s = get32(signature, 35); - address recovered = ecrecover( - keccak256(orderSchemaHash, orderHash), - v, - r, - s - ); + address recovered = ecrecover(hash, v, r, s); isValid = signer == recovered; return; -- cgit