def __init__(self, wif=None): if wif: if isinstance(wif, str): private_key_int, compressed, version = wif_to_int(wif) self._pk = derive_private_key(private_key_int) 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 = coords_to_public_key(*get_ec_point(self._pk), compressed=compressed)
def test_coords_to_public_key_uncompressed(self): assert coords_to_public_key(PUBLIC_KEY_X, PUBLIC_KEY_Y, compressed=False) == PUBLIC_KEY_UNCOMPRESSED
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)
def test_coords_to_public_key_compressed(self): assert coords_to_public_key(PUBLIC_KEY_X, PUBLIC_KEY_Y) == PUBLIC_KEY_COMPRESSED