Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import bitcoin as b
from pyethereum import tester, utils
class TestECRecover(object):
def test_ecrecover(h, v, r, s):
return(ecrecover(h, v, r, s))
def setup_class(cls):
cls.s = tester.state()
cls.c = cls.s.abi_contract(cls.CONTRACT)
cls.snapshot = cls.s.snapshot()
def setup_method(self, method):
def test_ecrecover(self):
priv = b.sha256('some big long brainwallet password')
pub = b.privtopub(priv)
msghash = b.sha256('the quick brown fox jumps over the lazy dog')
V, R, S = b.ecdsa_raw_sign(msghash, priv)
assert b.ecdsa_raw_verify(msghash, (V, R, S), pub)
addr = utils.big_endian_to_int(utils.sha3(b.encode_pubkey(pub, 'bin')[1:])[12:])
assert int(utils.privtoaddr(priv), 16) == addr
result = self.c.test_ecrecover(utils.big_endian_to_int(msghash.decode('hex')), V, R, S)
assert result == addr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.