diff options
author | Remco Bloemen <remco@wicked.ventures> | 2018-02-14 07:27:43 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:16 +0800 |
commit | 78e216d1570a2f4b41715b0602e4606659a2f512 (patch) | |
tree | 9bc1bde22a8317bd84e04e92088cec4d4cc176f8 /packages/contracts/src | |
parent | 61726d84ac418464de556956e9fa7227b971d30c (diff) | |
download | dexon-sol-tools-78e216d1570a2f4b41715b0602e4606659a2f512.tar dexon-sol-tools-78e216d1570a2f4b41715b0602e4606659a2f512.tar.gz dexon-sol-tools-78e216d1570a2f4b41715b0602e4606659a2f512.tar.bz2 dexon-sol-tools-78e216d1570a2f4b41715b0602e4606659a2f512.tar.lz dexon-sol-tools-78e216d1570a2f4b41715b0602e4606659a2f512.tar.xz dexon-sol-tools-78e216d1570a2f4b41715b0602e4606659a2f512.tar.zst dexon-sol-tools-78e216d1570a2f4b41715b0602e4606659a2f512.zip |
Implement EIP712 at verify-signature call site
Diffstat (limited to 'packages/contracts/src')
3 files changed, 19 insertions, 25 deletions
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; |