Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Implement EIP712 at verify-signature call site
Browse files Browse the repository at this point in the history
  • Loading branch information
recmo committed Feb 14, 2018
1 parent a575cf5 commit 509c76b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
Expand Down Expand Up @@ -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
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 509c76b

Please sign in to comment.