21 std::optional<TreeNodeIndex> leaf_idx,
23 uint32_t total_tree_height,
29 const TreeNodeIndex max_idx(uint32_t((1 << total_tree_height) - 1));
31 std::vector<uint8_t> stack(total_tree_height * params.
n());
46 gen_leaf(current_node, idx + idx_offset);
50 uint32_t internal_idx_offset = idx_offset;
52 auto internal_leaf = leaf_idx;
56 if(h.get() == total_tree_height) {
64 if(internal_leaf.has_value() && (internal_idx ^ internal_leaf.value()) == 0x01U) {
65 auto auth_path_location = out_auth_path.
get().subspan(h.get() * params.
n(), params.
n());
66 copy_mem(auth_path_location, current_node);
71 auto stack_location = std::span(stack).subspan(h.get() * params.
n(), params.
n());
77 if((internal_idx & 1) == 0U && idx < max_idx) {
80 copy_mem(stack_location, current_node);
88 internal_idx_offset /= 2;
90 tree_address.
set_tree_index(internal_idx / 2 + internal_idx_offset);
92 hashes.
T(current_node, tree_address, stack_location, current_node);
95 if(internal_leaf.has_value()) {
96 internal_leaf.value() /= 2;
void treehash(StrongSpan< SphincsTreeNode > out_root, StrongSpan< SphincsAuthenticationPath > out_auth_path, const Sphincs_Parameters ¶ms, Sphincs_Hash_Functions &hashes, std::optional< TreeNodeIndex > leaf_idx, uint32_t idx_offset, uint32_t total_tree_height, const GenerateLeafFunction &gen_leaf, Sphincs_Address &tree_address)
void compute_root(StrongSpan< SphincsTreeNode > out, const Sphincs_Parameters ¶ms, Sphincs_Hash_Functions &hashes, const SphincsTreeNode &leaf, TreeNodeIndex leaf_idx, uint32_t idx_offset, StrongSpan< const SphincsAuthenticationPath > authentication_path, uint32_t total_tree_height, Sphincs_Address &tree_address)