def DecodePublic(curve, bb):
    """
    Decode a public key from bytes. Invalid points are rejected. The
    neutral element is NOT accepted as a public key.
    """
    pk = curve.Decode(bb)
    if pk.is_neutral():
        raise Exception('Invalid public key (neutral point)')
    return pk