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
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 |
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
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 = {} | |
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) |