Created
September 7, 2017 09:57
-
-
Save YoshihitoAso/5455845330b84b98564971de84b050d5 to your computer and use it in GitHub Desktop.
Solidity Sample ECVerify
This file contains hidden or 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
pragma solidity ^0.4.8; | |
contract ECVerify { | |
event VerifyResult(bool ret, address indexed addr, address indexed recoverAddress); | |
function verify(bytes32 hash, uint8 v, bytes32 r, bytes32 s, address signer) returns(bool) { | |
bytes memory prefix = "\x19Ethereum Signed Message:\n32"; | |
bytes32 prefixedHash = sha3(prefix, hash); | |
bool ret = false; | |
address recoverAddress = ecrecover(prefixedHash, v, r, s); | |
if (recoverAddress == signer) | |
ret = true; | |
VerifyResult(ret, signer, recoverAddress); | |
return ret; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment