def signOrder(orderHash, private_key): key = normalize_key(private_key.to_hex()) v, r, s = ecsign( sha3("\x19Ethereum Signed Message:\n32".encode('utf-8') + orderHash), key) return "0x" + v.to_bytes(1, "big").hex() + ( zpad(bytearray_to_bytestr(int_to_32bytearray(r)), 32) + zpad(bytearray_to_bytestr(int_to_32bytearray(s)), 32)).hex() + "03"
def _sub_hash(value, label): return sha3(value + sha3(label))
def is_bytes(value): return isinstance(value, (bytes, bytearray)) def combine(f, g): return lambda x: f(g(x)) def compose(*functions): return functools.reduce(combine, functions, lambda x: x) # ensure we have the *correct* sha3 installed (keccak) assert codecs.encode( sha3(b''), 'hex' ) == b'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470' # noqa def _sub_hash(value, label): return sha3(value + sha3(label)) def namehash(name): node = b'\x00' * 32 if name: if is_bytes(name): encoded_name = name else: encoded_name = codecs.encode(name, 'utf8')
def signHash(hash, private_key): key = normalize_key(private_key.to_hex()) v, r, s = ecsign(sha3("\x19Ethereum Signed Message:\n32".encode('utf-8') + hash), key) return zpad(bytearray_to_bytestr(int_to_32bytearray(r)), 32), zpad(bytearray_to_bytestr(int_to_32bytearray(s)), 32), v
def createOrder(orderHash): key = normalize_key('0x0000000000000000000000000000000000000000000000000000000000000001') v, r, s = ecsign(sha3("\x19Ethereum Signed Message:\n32".encode('utf-8') + orderHash), key) return v, zpad(bytearray_to_bytestr(int_to_32bytearray(r)), 32), zpad(bytearray_to_bytestr(int_to_32bytearray(s)), 32)
contractsFixture.eth_tester.time_travel(int(timestamp + timePassed)) def roughlyEqual(amount1, amount2, tolerance=5 * 10**16): return abs(amount1 - amount2) < tolerance def is_bytes(value): return isinstance(value, (bytes, bytearray)) def combine(f, g): return lambda x: f(g(x)) def compose(*functions): return functools.reduce(combine, functions, lambda x: x) # ensure we have the *correct* sha3 installed (keccak) assert codecs.encode(sha3(b''), 'hex') == b'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470' # noqa def _sub_hash(value, label): return sha3(value + sha3(label)) def namehash(name): node = b'\x00' * 32 if name: if is_bytes(name): encoded_name = name else: encoded_name = codecs.encode(name, 'utf8') labels = encoded_name.split(b'.') return compose(*(