#ifndef SPX_UTILSX4_H
#define SPX_UTILSX4_H

#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Uefi.h>
#include "params.h"
#include "context.h"

/**
 * For a given leaf index, computes the authentication path and the resulting
 * root node using Merkle's TreeHash algorithm.
 * Expects the layer and tree parts of the tree_addr to be set, as well as the
 * tree type (i.e. SPX_ADDR_TYPE_HASHTREE or SPX_ADDR_TYPE_FORSTREE).
 * Applies the offset idx_offset to indices before building addresses, so that
 * it is possible to continue counting indices across trees.
 */
#define treehashx1 SPX_NAMESPACE(treehashx1)
VOID treehashx1(UINT8 *root, UINT8 *auth_path,
                const spx_ctx* ctx,
                UINT32 leaf_idx, UINT32 idx_offset, UINT32 tree_height,
                VOID (*gen_leaf)(
                   UINT8* /* Where to write the leaf */,
                   const spx_ctx* /* ctx */,
                   UINT32 addr_idx, VOID *info),
                UINT32 tree_addrx4[8], VOID *info);

#endif
