def pubkey_from_point_to_bytes(x: int, y: int, compressed: bool = True) -> bytes:
    """ Constructs pubkey from its x y coordinates """
    x_bytes = x.to_bytes(32, byteorder='big')
    y_bytes = y.to_bytes(32, byteorder='big')
    if compressed:
        parity = y & 1
        return (2 + parity).to_bytes(1, byteorder='big') + x_bytes
    else:
        return b'\04' + x_bytes + y_bytes