def test_affine(point_affine, nid, curve):
    point = Point.from_affine(point_affine, curve=nid)  # from nid
    the_same_point = Point.from_affine(point_affine,
                                       curve=curve)  # from curve instance
    assert point == the_same_point
    assert isinstance(point, Point)
    point_affine2 = point.to_affine()
    assert point_affine == point_affine2
def test_coords_with_special_characteristics():

    # Testing that a point with x coordinate greater than the curve order is still valid.
    # In particular, we will test the last valid point from the default curve (secp256k1)
    # whose x coordinate is `field_order - 3` and is greater than the order of the curve

    field_order = 2**256 - 0x1000003D1
    compressed = b'\x02' + (field_order - 3).to_bytes(32, 'big')

    last_point = Point.from_bytes(compressed)

    # The same point, but obtained through the from_affine method
    coords = (
        115792089237316195423570985008687907853269984665640564039457584007908834671660,
        109188863561374057667848968960504138135859662956057034999983532397866404169138
    )

    assert last_point == Point.from_affine(coords)
def test_affine(point_affine, nid, curve):
    point = Point.from_affine(point_affine, curve=curve)  # from curve
    assert isinstance(point, Point)
    point_affine2 = point.to_affine()
    assert point_affine == point_affine2