-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add frontrun protection using witness and secret (#3)
* Add frontrun protection using witness and secret * Remove readWitness and use fromToken on depositEth
- Loading branch information
1 parent
b5d771f
commit 2bd1326
Showing
7 changed files
with
721 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
pragma solidity ^0.5.5; | ||
|
||
|
||
library SigUtils { | ||
/** | ||
@dev Recovers address who signed the message | ||
@param _hash operation ethereum signed message hash | ||
@param _signature message `hash` signature | ||
*/ | ||
function ecrecover2 ( | ||
bytes32 _hash, | ||
bytes memory _signature | ||
) internal pure returns (address) { | ||
bytes32 r; | ||
bytes32 s; | ||
uint8 v; | ||
|
||
assembly { | ||
r := mload(add(_signature, 32)) | ||
s := mload(add(_signature, 64)) | ||
v := and(mload(add(_signature, 65)), 255) | ||
} | ||
|
||
if (v < 27) { | ||
v += 27; | ||
} | ||
|
||
return ecrecover( | ||
_hash, | ||
v, | ||
r, | ||
s | ||
); | ||
} | ||
} |
Oops, something went wrong.