def DecodePrivate(curve, bb):
    """
    Decode a private key from bytes. Note that the length must match the
    expected value (32 bytes for both do255e and do255s) and the value
    is verified to be in the proper range (1 to r-1, with r being the
    prime order of the do255* group).
    """
    sk = curve.SF.Decode(bb)
    if sk.is_zero():
        raise Exception('Invalid private key (zero)')
    return sk