Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Use EIP 191. fix #71
Browse files Browse the repository at this point in the history
  • Loading branch information
oed committed Nov 16, 2017
1 parent 880f8b8 commit baaf442
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions contracts/TxRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ contract TxRelay {
) public {

address claimedSender = getAddress(data);
// relay :: nonce :: destination :: data :: relayer
bytes32 h = sha3(this, nonce[claimedSender], destination, data);
// use EIP 191
// 0x19 :: version :: relay :: nonce :: destination :: data :: relayer
bytes32 h = keccak256(byte(0x19), byte(0), this, nonce[claimedSender], destination, data);
address addressFromSig = ecrecover(h, sigV, sigR, sigS);

require(claimedSender == addressFromSig);
Expand Down
2 changes: 1 addition & 1 deletion test/txRelay.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function signPayload(signingAddr, sendingAddr, txRelay, destinationAddress

nonce = await txRelay.getNonce.call(signingAddr)
//Tight packing, as Solidity sha3 does
hashInput = txRelay.address + pad(nonce.toString('16')).slice(2)
hashInput = '0x1900' + txRelay.address.slice(2) + pad(nonce.toString('16')).slice(2)
+ destinationAddress.slice(2) + data.slice(2)
hash = solsha3(hashInput)
sig = lightwallet.signing.signMsgHash(lw, keyFromPw, hash, signingAddr)
Expand Down

0 comments on commit baaf442

Please sign in to comment.