30 std::optional<TreeNodeIndex> leaf_idx,
32 uint32_t total_tree_height,
38 const TreeNodeIndex max_idx(uint32_t((1 << total_tree_height) - 1));
40 std::vector<uint8_t> stack(total_tree_height * params.
n());
55 gen_leaf(current_node, idx + idx_offset);
59 uint32_t internal_idx_offset = idx_offset;
61 auto internal_leaf = leaf_idx;
65 if(h.get() == total_tree_height) {
66 copy_into(out_root, current_node);
73 if(internal_leaf.has_value() && (internal_idx ^ internal_leaf.value()) == 0x01U) {
74 auto auth_path_location = out_auth_path.
get().subspan(h.get() * params.
n(), params.
n());
75 copy_into(auth_path_location, current_node);
80 auto stack_location = std::span(stack).subspan(h.get() * params.
n(), params.
n());
86 if((internal_idx & 1) == 0U && idx < max_idx) {
89 copy_into(stack_location, current_node);
97 internal_idx_offset /= 2;
99 tree_address.
set_tree_index(internal_idx / 2 + internal_idx_offset);
101 hashes.
T(current_node, tree_address, stack_location, current_node);
104 if(internal_leaf.has_value()) {
105 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)