Created
December 23, 2017 14:43
-
-
Save jstoxrocky/39f8abfa87079eb70bb2348adef89bac to your computer and use it in GitHub Desktop.
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
def ecrecover(h, v, r, s): | |
""" | |
Function recreating solidity's ecrecover | |
Args: | |
h: The Keccak hash of the msg | |
v: The "v" parameter derived from the signed message (ethereum.utils.ecsign) | |
r: The "r" parameter derived from the signed message (ethereum.utils.ecsign) | |
s: The "s" parameter derived from the signed message (ethereum.utils.ecsign) | |
Returns: | |
Address of the message signer as a hexidecimal string | |
""" | |
pub = ecrecover_to_pub(h, v, r, s) | |
addr = keccak(pub)[-20:] | |
addr = encode_hex(addr) | |
addr = to_checksum_address(addr) | |
return addr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment