Create nshares of the secret. threshold specifies the number of shares
    needed for reconstructing the secret value. A 0-16 bytes identifier must
    be provided. Optionally the secret is hashed with the algorithm specified
    by hash_id, a class attribute of Hash.
    This function must return a list of formatted shares or raises a TSSError
    exception if anything went wrong.

def share_secret(threshold, nshares, secret, identifier, hash_id=Hash.SHA256):
    """
    Create nshares of the secret. threshold specifies the number of shares
    needed for reconstructing the secret value. A 0-16 bytes identifier must
    be provided. Optionally the secret is hashed with the algorithm specified
    by hash_id, a class attribute of Hash.
    This function must return a list of formatted shares or raises a TSSError
    exception if anything went wrong.
    """
    if identifier is None:
        raise TSSError('an identifier must be provided')
    if not Hash.is_valid(hash_id):
        raise TSSError('invalid hash algorithm %s' % hash_id)
    secret = encode(secret)
    identifier = encode(identifier)
    if hash_id != Hash.NONE:
        secret += Hash.to_func(hash_id)(secret).digest()
    shares = generate_shares(threshold, nshares, secret)
    header = format_header(identifier, hash_id, threshold, len(secret) + 1)
    return [format_share(header, share) for share in shares]