def auth_set(hashed_sks, auth_set_indices, height, hashfun):
    """Return the authentication set defined by the given indices.

    Keyword arguments:
    hashed_sks       -- the hased secret key components which form the
                        leaves of the tree
    auth_set_indices -- A list of tuples (h, i) defining the height and index of
                        the nodes that should end up in the authentication set
    height           -- the height of the binary tree
    hashfun          -- a hash function of 2n -> n that is used to produce the
                        parent node from its two child nodes

    Returns:
    A list containing tuples ((h, i), hash), the height, index, and hash of the
    node in the authentication set. The order of the nodes in the returned list
    is equal to the order of the nodes in auth_set_indices.
    """
    tree = [None] * height
    tree[0] = hashed_sks # the leaves
    for current_height in range(1, height): # We don't need to compute the root,
                                            # otherwise this would be off by one
        num_nodes = 2**(height - current_height)
        tree[current_height] = [None] * num_nodes
        for index in range(0, num_nodes):
            left  = tree[current_height - 1][2*index]
            right = tree[current_height - 1][2*index + 1]
            tree[current_height][index] = hashfun(left, right)

    return [((h, i), tree[h][i]) for h, i in auth_set_indices]