def generate_key_address_pair(): private_key = generate_private_key() public_key = point_to_public_key(private_key.public_key().public_numbers(), compressed=True) address = public_key_to_address(public_key) return int_to_hex(private_key.private_numbers().private_value), address
def generate_key_address_pair(): private_key = gen_privkey(SECP256K1, DEFAULT_BACKEND) public_key = point_to_public_key(private_key.public_key().public_numbers(), compressed=True) bitcoin_address = public_key_to_address(public_key) return int_to_hex( private_key.private_numbers().private_value), bitcoin_address
def stream_key_address_pairs(queue, event): # pragma: no cover while True: private_key = generate_private_key() public_key = point_to_public_key( private_key.public_key().public_numbers(), compressed=True) address = public_key_to_address(public_key) queue.put_nowait( (private_key.private_numbers().private_value, address)) if event.is_set(): return
def __init__(self, wif=None): if wif: if isinstance(wif, str): private_key_hex, compressed, version = wif_to_hex(wif) self._pk = derive_private_key(hex_to_int(private_key_hex)) elif isinstance(wif, EllipticCurvePrivateKey): self._pk = wif compressed = True else: raise TypeError('Wallet Import Format must be a string.') else: self._pk = generate_private_key() compressed = True self._public_point = None self._public_key = point_to_public_key( self._pk.public_key().public_numbers(), compressed=compressed)
def test_point_to_public_key(): class Point: x = PUBLIC_KEY_X y = PUBLIC_KEY_Y assert point_to_public_key(Point) == coords_to_public_key(Point.x, Point.y)