def test_public_key_uncompressed(self): base_key = BaseKey(WALLET_FORMAT_MAIN) assert base_key.public_key == PUBLIC_KEY_UNCOMPRESSED
def test_init_from_key(self): pk = ECPrivateKey() base_key = BaseKey(pk) assert base_key._pk == pk
def test_init_wif_error(self): with pytest.raises(TypeError): BaseKey(b"\x00")
def test_equal(self): assert BaseKey(WALLET_FORMAT_COMPRESSED_MAIN) == BaseKey( WALLET_FORMAT_COMPRESSED_MAIN)
def test_init_default(self): base_key = BaseKey() assert isinstance(base_key._pk, ECPrivateKey) assert len(base_key.public_key) == 33
def test_to_int(self): base_key = BaseKey(WALLET_FORMAT_MAIN) assert base_key.to_int() == PRIVATE_KEY_NUM
def test_is_compressed(self): assert BaseKey(WALLET_FORMAT_COMPRESSED_MAIN).is_compressed() is True assert BaseKey(WALLET_FORMAT_MAIN).is_compressed() is False
def test_to_bytes(self): base_key = BaseKey(WALLET_FORMAT_MAIN) assert base_key.to_bytes() == PRIVATE_KEY_BYTES
def test_verify_failure(self): base_key = BaseKey() data = os.urandom(200) signature = base_key.sign(data) assert not base_key.verify(signature, data[::-1])
def test_verify_success(self): base_key = BaseKey() data = os.urandom(200) signature = base_key.sign(data) assert base_key.verify(signature, data)
def test_sign(self): base_key = BaseKey() data = os.urandom(200) signature = base_key.sign(data) assert verify_sig(signature, data, base_key.public_key)
def test_public_point(self): base_key = BaseKey(WALLET_FORMAT_MAIN) assert base_key.public_point == Point(PUBLIC_KEY_X, PUBLIC_KEY_Y) assert base_key.public_point == Point(PUBLIC_KEY_X, PUBLIC_KEY_Y)