def uncompress(payload):
    """
    Given a compressed ec key in bytes, uncompress it using math and return (x, y)
    """
    payload = hexlify(payload)
    even = payload[:2] == b"02"
    x = int(payload[2:], 16)
    beta = pow(int(x ** 3 + A * x + B), int((P + 1) // 4), int(P))
    y = (P-beta) if even else beta
    return x, y