Skip to content

Instantly share code, notes, and snippets.

from ethereum.utils import privtoaddr, ecrecover_to_pub, ecsign
from eth_utils import keccak, encode_hex, decode_hex, to_checksum_address
# Create Bob's account
priv = keccak('Bob')
addr = privtoaddr(priv)
pub = to_checksum_address(addr)
bob = {'pub':pub, 'priv':priv}
# Create Alice's account
class Channel:
def __init__(self, sender, recipient, deposit):
self.sender = to_checksum_address(sender)
self.recipient = to_checksum_address(recipient)
self.deposit = deposit
self.signatures = {}
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)