9#include <botan/internal/sp_xmss.h>
11#include <botan/internal/buffer_stuffer.h>
12#include <botan/internal/sp_address.h>
13#include <botan/internal/sp_treehash.h>
14#include <botan/internal/sp_wots.h>
24 std::optional<TreeNodeIndex> idx_leaf,
31 const auto steps = [&]() -> std::vector<WotsHashIndex> {
34 if(idx_leaf.has_value()) {
50 [&](std::span<uint8_t> out_leaves,
TreeNodeIndex first_idx, uint32_t count) {
51 constexpr uint32_t leaf_group = 128;
52 for(uint32_t j = 0; j < count; j += leaf_group) {
53 const uint32_t leaves = std::min(leaf_group, count - j);
55 out_leaves.subspan(j * params.
n(), leaves * params.
n()),
70 treehash(next_root, auth_path_s, params, hashes, idx_leaf, 0, params.
xmss_tree_height(), xmss_gen_leaves, tree_addr);
91 xmss_sign_and_pkgen(dummy_sig, dummy_root, secret_seed, wots_addr, top_tree_addr, std::nullopt, params, hashes);
#define BOTAN_ASSERT_NOMSG(expr)
Helper class to ease in-place marshalling of concatenated fixed-length values.
constexpr size_t remaining_capacity() const
constexpr std::span< uint8_t > next(size_t bytes)
Sphincs_Address_Type get_type() const
Sphincs_Address & set_layer_address(HypertreeLayerIndex layer)
static Sphincs_Address as_subtree_from(const Sphincs_Address &other)
Sphincs_Address & set_type(Sphincs_Address_Type type)
uint32_t wots_bytes() const
uint32_t xmss_tree_height() const
Strong< std::vector< uint8_t >, struct SphincsXmssSignature_ > SphincsXmssSignature
Gf448Elem root(const Gf448Elem &elem)
Compute the root of elem in the field.
Strong< std::vector< uint8_t >, struct SphincsTreeNode_ > SphincsTreeNode
Either an XMSS or FORS tree node or leaf.
@ WotsPublicKeyCompression
SphincsTreeNode xmss_gen_root(const Sphincs_Parameters ¶ms, const SphincsSecretSeed &secret_seed, Sphincs_Hash_Functions &hashes)
std::function< void(std::span< uint8_t >, TreeNodeIndex, uint32_t)> GenerateLeavesFunction
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 GenerateLeavesFunction &gen_leaves, Sphincs_Address &tree_address)
Strong< secure_vector< uint8_t >, struct WotsSignature_ > WotsSignature
Strong< secure_vector< uint8_t >, struct SphincsSecretSeed_ > SphincsSecretSeed
SphincsTreeNode xmss_sign_and_pkgen(StrongSpan< SphincsXmssSignature > out_sig, const SphincsTreeNode &message, const SphincsSecretSeed &secret_seed, const Sphincs_Address &wots_addr, Sphincs_Address &tree_addr, std::optional< TreeNodeIndex > idx_leaf, const Sphincs_Parameters ¶ms, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 10: xmss_sign.
Strong< uint32_t, struct TreeNodeIndex_, EnableArithmeticWithPlainNumber > TreeNodeIndex
Index of an individual node inside an XMSS or FORS tree.
Strong< std::vector< uint8_t >, struct SphincsAuthenticationPath_ > SphincsAuthenticationPath
void wots_sign_and_pkgen(StrongSpan< WotsSignature > sig_out, std::span< uint8_t > leaves_out, const SphincsSecretSeed &secret_seed, TreeNodeIndex first_leaf_idx, size_t leaf_count, std::optional< TreeNodeIndex > sign_leaf_idx, const std::vector< WotsHashIndex > &wots_steps, Sphincs_Address &leaf_addr, Sphincs_Address &pk_addr, const Sphincs_Parameters ¶ms, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 6 and 7: wots_pkGen and wots_sign.
Strong< uint32_t, struct HypertreeLayerIndex_ > HypertreeLayerIndex
Index of a layer in the XMSS hyper-tree.
std::vector< WotsHashIndex > chain_lengths(const SphincsTreeNode &msg, const Sphincs_Parameters ¶ms)