Botan 3.14.1
Crypto and TLS for C&
lms.cpp
Go to the documentation of this file.
1/**
2 * LMS - Leighton-Micali Hash-Based Signatures (RFC 8554)
3 * (C) 2023 Jack Lloyd
4 * 2023 Fabian Albert, Philippe Lieser - Rohde & Schwarz Cybersecurity GmbH
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9#include <botan/internal/lms.h>
10
11#include <botan/exceptn.h>
12#include <botan/hash.h>
13#include <botan/internal/buffer_slicer.h>
14#include <botan/internal/buffer_stuffer.h>
15#include <botan/internal/concat_util.h>
16#include <botan/internal/hash_engine.h>
17#include <botan/internal/loadstor.h>
18#include <botan/internal/tree_hash.h>
19
20namespace Botan {
21namespace {
22
23/**
24 * @brief Domain-separation parameter when computing the hash of the leaf of an LMS tree.
25 */
26constexpr uint16_t D_LEAF = 0x8282;
27
28/**
29 * @brief Domain-separation parameter when computing the hash of an interior node of an LMS tree.
30 */
31constexpr uint16_t D_INTR = 0x8383;
32
33/// Index of the layer in a tree starting with 0 for the bottom level to the root layer
35
36class TreeAddress final {
37 public:
38 explicit TreeAddress(uint32_t total_tree_height) : m_h(total_tree_height), m_r(0) {
39 BOTAN_ARG_CHECK(total_tree_height > 0 && total_tree_height < 32, "Invalid tree height");
40 }
41
42 TreeAddress& set_address(LMS_TreeLayerIndex tree_layer, LMS_Tree_Node_Idx tree_index) {
43 BOTAN_ARG_CHECK(tree_index.get() < (1 << m_h), "Invalid tree index");
44 BOTAN_ARG_CHECK(tree_layer.get() <= m_h, "Invalid tree index");
45 m_r = (1 << (m_h - tree_layer)).get() + tree_index.get();
46 return *this;
47 }
48
49 uint32_t r() const { return m_r; }
50
51 bool is_leaf() const { return m_r >= (1 << m_h); }
52
53 LMS_Tree_Node_Idx q() const {
54 BOTAN_STATE_CHECK(is_leaf());
55 return LMS_Tree_Node_Idx(m_r - (1 << m_h.get()));
56 }
57
58 private:
59 LMS_TreeLayerIndex m_h;
60 uint32_t m_r;
61};
62
63auto get_hash_pair_func_for_identifier(const LMS_Params& lms_params, LMS_Identifier identifier) {
64 return [hash = lms_params.hash(), I = std::move(identifier)](StrongSpan<LMS_Tree_Node> out,
65 const TreeAddress& address,
68 hash->update(I);
69 hash->update(store_be(address.r()));
70 hash->update(store_be(D_INTR));
71 hash->update(left);
72 hash->update(right);
73 hash->final(out);
74 };
75}
76
77void lms_gen_leaf(StrongSpan<LMS_Tree_Node> out,
78 const LMOTS_Public_Key& lmots_pk,
79 const TreeAddress& tree_address,
80 HashFunction& hash) {
81 hash.update(lmots_pk.identifier());
82 hash.update(store_be(tree_address.r()));
83 hash.update(store_be(D_LEAF));
84 hash.update(lmots_pk.K());
85 hash.final(out);
86}
87
88auto lms_gen_leaves_func(const LMS_PrivateKey& lms_sk) {
89 // The hash engine is created once here and reused for all leaves
90 return [engine = Hash_Engine::create_or_throw(lms_sk.lmots_params().hash_name()), lms_sk](
91 std::span<uint8_t> out, LMS_Tree_Node_Idx first_idx, size_t count) {
92 const size_t m = lms_sk.lms_params().m();
93 const auto& identifier = lms_sk.identifier();
94
95 // The OTS public key hashes of all requested leaves
96 std::vector<uint8_t> ks(count * m);
97 lmots_compute_pubkeys(ks, lms_sk.lmots_params(), identifier, first_idx, count, lms_sk.seed(), *engine);
98
99 // Leaf node hash: H(I || u32str(r) || u16str(D_LEAF) || K)
100 const size_t prefix_len = identifier.size() + sizeof(uint32_t) + sizeof(uint16_t);
101 std::vector<uint8_t> prefixes(count * prefix_len);
102 std::vector<std::span<uint8_t>> outs(count);
103 std::vector<std::span<const uint8_t>> prefix_spans(count);
104 std::vector<std::span<const uint8_t>> k_spans(count);
105 for(size_t i = 0; i != count; ++i) {
106 const uint32_t r = (uint32_t(1) << lms_sk.lms_params().h()) + first_idx.get() + static_cast<uint32_t>(i);
107 const auto prefix_span = std::span(prefixes).subspan(i * prefix_len, prefix_len);
108 BufferStuffer prefix(prefix_span);
109 prefix.append(identifier);
110 prefix.append(store_be(r));
111 prefix.append(store_be(D_LEAF));
112 prefix_spans[i] = prefix_span;
113 outs[i] = out.subspan(i * m, m);
114 k_spans[i] = std::span(ks).subspan(i * m, m);
115 }
116 engine->batch_hash(outs, prefix_spans, k_spans);
117 };
118}
119
120void lms_treehash(StrongSpan<LMS_Tree_Node> out_root,
121 std::optional<StrongSpan<LMS_AuthenticationPath>> out_auth_path,
122 std::optional<LMS_Tree_Node_Idx> leaf_idx,
123 const LMS_PrivateKey& lms_sk) {
124 auto hash_pair_func = get_hash_pair_func_for_identifier(lms_sk.lms_params(), lms_sk.identifier());
125 auto gen_leaves = lms_gen_leaves_func(lms_sk);
126 TreeAddress lms_tree_address(lms_sk.lms_params().h());
127
128 treehash(out_root,
129 out_auth_path,
130 leaf_idx,
131 lms_sk.lms_params().m(),
132 LMS_TreeLayerIndex(lms_sk.lms_params().h()),
133 0,
134 std::move(hash_pair_func),
135 std::move(gen_leaves),
136 lms_tree_address);
137}
138
139} // namespace
140
141std::unique_ptr<HashFunction> LMS_Params::hash() const {
143}
144
146 auto [hash_name, height] = [](const LMS_Algorithm_Type& lms_type) -> std::pair<std::string_view, uint8_t> {
147 switch(lms_type) {
149 return {"SHA-256", static_cast<uint8_t>(5)};
151 return {"SHA-256", static_cast<uint8_t>(10)};
153 return {"SHA-256", static_cast<uint8_t>(15)};
155 return {"SHA-256", static_cast<uint8_t>(20)};
157 return {"SHA-256", static_cast<uint8_t>(25)};
159 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(5)};
161 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(10)};
163 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(15)};
165 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(20)};
167 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(25)};
169 return {"SHAKE-256(256)", static_cast<uint8_t>(5)};
171 return {"SHAKE-256(256)", static_cast<uint8_t>(10)};
173 return {"SHAKE-256(256)", static_cast<uint8_t>(15)};
175 return {"SHAKE-256(256)", static_cast<uint8_t>(20)};
177 return {"SHAKE-256(256)", static_cast<uint8_t>(25)};
179 return {"SHAKE-256(192)", static_cast<uint8_t>(5)};
181 return {"SHAKE-256(192)", static_cast<uint8_t>(10)};
183 return {"SHAKE-256(192)", static_cast<uint8_t>(15)};
185 return {"SHAKE-256(192)", static_cast<uint8_t>(20)};
187 return {"SHAKE-256(192)", static_cast<uint8_t>(25)};
188 default:
189 throw Decoding_Error("Unsupported LMS algorithm type");
190 }
191 }(type);
192
193 return LMS_Params(type, hash_name, height);
194}
195
196LMS_Params LMS_Params::create_or_throw(std::string_view hash_name, uint8_t height) {
197 const LMS_Algorithm_Type type = [](std::string_view hash, uint8_t h) -> LMS_Algorithm_Type {
198 if(hash == "SHA-256") {
199 switch(h) {
200 case 5:
202 case 10:
204 case 15:
206 case 20:
208 case 25:
210 default:
211 throw Decoding_Error("Unsupported height for hash function");
212 }
213 }
214 if(hash == "Truncated(SHA-256,192)") {
215 switch(h) {
216 case 5:
218 case 10:
220 case 15:
222 case 20:
224 case 25:
226 default:
227 throw Decoding_Error("Unsupported height for hash function");
228 }
229 }
230 if(hash == "SHAKE-256(256)") {
231 switch(h) {
232 case 5:
234 case 10:
236 case 15:
238 case 20:
240 case 25:
242 default:
243 throw Decoding_Error("Unsupported height for hash function");
244 }
245 }
246 if(hash == "SHAKE-256(192)") {
247 switch(h) {
248 case 5:
250 case 10:
252 case 15:
254 case 20:
256 case 25:
258 default:
259 throw Decoding_Error("Unsupported height for hash function");
260 }
261 }
262 throw Decoding_Error("Unsupported hash function");
263 }(hash_name, height);
264
265 return LMS_Params(type, hash_name, height);
266}
267
268LMS_Params::LMS_Params(LMS_Algorithm_Type algorithm_type, std::string_view hash_name, uint8_t h) :
269 m_algorithm_type(algorithm_type), m_h(h), m_hash_name(hash_name) {
270 const auto hash = HashFunction::create_or_throw(m_hash_name);
271 m_m = hash->output_length();
272}
273
276 const LMS_Message& msg) const {
277 // Pre-alloc space for the signature
278 BOTAN_ARG_CHECK(out_sig.size() == LMS_Signature::size(lms_params(), lmots_params()), "Invalid output buffer size");
279
280 BufferStuffer sig_stuffer(out_sig);
281 sig_stuffer.append(store_be(q));
282 const LMOTS_Private_Key lmots_sk(lmots_params(), identifier(), q, seed());
283 lmots_sk.sign(sig_stuffer.next<LMOTS_Signature_Bytes>(LMOTS_Signature::size(lmots_params())), msg);
284 sig_stuffer.append(store_be(lms_params().algorithm_type()));
285 const auto auth_path_buffer = sig_stuffer.next<LMS_AuthenticationPath>(lms_params().m() * lms_params().h());
286
287 BOTAN_ASSERT_NOMSG(sig_stuffer.full());
288
289 const TreeAddress lms_tree_address(lms_params().h());
290 LMS_Tree_Node pk_buffer(lms_params().m());
291 lms_treehash(StrongSpan<LMS_Tree_Node>(pk_buffer.get()), auth_path_buffer, q, *this);
292
293 CT::unpoison(pk_buffer);
294 return LMS_PublicKey(lms_params(), lmots_params(), identifier(), std::move(pk_buffer));
295}
296
298 const size_t total_remaining_bytes = slicer.remaining();
299 // Alg. 6. 1. (4 bytes are sufficient until the next check)
300 if(total_remaining_bytes < sizeof(LMS_Algorithm_Type)) {
301 throw Decoding_Error("Too few bytes while parsing LMS public key.");
302 }
303 // Alg. 6. 2.a.
304 const auto lms_type = load_be<LMS_Algorithm_Type>(slicer.take<sizeof(LMS_Algorithm_Type)>());
305 // Alg. 6. 2.c.
307 // Alg. 6. 2.d.
308 if(total_remaining_bytes < LMS_PublicKey::size(lms_params)) {
309 throw Decoding_Error("Too few bytes while parsing LMS public key.");
310 }
311 // Alg. 6. 2.b.
312 const auto lmots_type = load_be<LMOTS_Algorithm_Type>(slicer.take<sizeof(LMOTS_Algorithm_Type)>());
314
315 if(lms_params.hash_name() != lmots_params.hash_name()) {
316 throw Decoding_Error("No support for HSS-LMS instances with multiple hash functions.");
317 }
318
319 // Alg. 6. 2.e.
320 auto I = slicer.copy<LMS_Identifier>(LMS_IDENTIFIER_LEN);
321 // Alg. 6. 2.f.
322 auto lms_root = slicer.copy<LMS_Tree_Node>(lms_params.m());
323
324 return LMS_PublicKey(std::move(lms_params), std::move(lmots_params), std::move(I), std::move(lms_root));
325}
326
327std::vector<uint8_t> LMS_PublicKey::to_bytes() const {
328 // clang-format off
330 store_be(lms_params().algorithm_type()),
331 store_be(lmots_params().algorithm_type()),
332 identifier(),
333 m_lms_root);
334 // clang-format on
335}
336
340 LMS_Tree_Node lms_root) :
341 LMS_Instance(std::move(lms_params), std::move(lmots_params), std::move(I)), m_lms_root(std::move(lms_root)) {
342 BOTAN_ARG_CHECK(identifier().size() == LMS_IDENTIFIER_LEN, "Invalid LMS identifier");
343 BOTAN_ARG_CHECK(m_lms_root.size() == this->lms_params().m(), "Invalid LMS root");
344}
345
349
351 const size_t total_remaining_bytes = slicer.remaining();
352 // Alg. 6a 1. (next 4 bytes are checked in LMOTS_Signature::from_bytes_or_throw)
353 if(total_remaining_bytes < sizeof(LMS_Tree_Node_Idx)) {
354 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
355 }
356 // Alg. 6a 2.a.
357 const auto q = load_be<LMS_Tree_Node_Idx>(slicer.take<sizeof(LMS_Tree_Node_Idx)>());
358
359 // Alg. 6a 2.b.-e.
361 const LMOTS_Params lmots_params = LMOTS_Params::create_or_throw(lmots_sig.algorithm_type());
362
363 if(slicer.remaining() < sizeof(LMS_Algorithm_Type)) {
364 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
365 }
366 // Alg. 6a 2.f.
367 const auto lms_type = load_be<LMS_Algorithm_Type>(slicer.take<sizeof(LMS_Algorithm_Type)>());
368 // Alg. 6a 2.h.
370 // Alg. 6a 2.i. (signature is not exactly [...] bytes long)
371 if(total_remaining_bytes < size(lms_params, lmots_params)) {
372 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
373 }
374
375 // Alg. 6a 2.j.
376 auto auth_path = slicer.copy<LMS_AuthenticationPath>(lms_params.m() * lms_params.h());
377
378 return LMS_Signature(q, std::move(lmots_sig), lms_type, std::move(auth_path));
379}
380
382 /* NOLINT(*-slicing) */ LMS_Instance(sk), m_lms_root(sk.lms_params().m()) {
383 lms_treehash(StrongSpan<LMS_Tree_Node>(m_lms_root), std::nullopt, std::nullopt, sk);
384}
385
387 if(lms_root().size() != lms_params().m()) {
388 // LMS public key (T[1] part) has unexpected length
389 return false;
390 }
391 if(lms_params().algorithm_type() != sig.lms_type()) {
392 // LMS algorithm type does not match with the signature's
393 return false;
394 }
395 // Alg. 6a 2.g.
396 if(lmots_params().algorithm_type() != sig.lmots_sig().algorithm_type()) {
397 // LMOTS algorithm type does not match with the signature's
398 return false;
399 }
400 // Alg. 6a 2.i.
401 if(sig.q() >= (1ULL << uint64_t(lms_params().h()))) {
402 return false;
403 }
404 // Alg 6. 3.
405 std::optional<LMS_Tree_Node> Tc = lms_compute_root_from_sig(msg, sig);
406 if(!Tc.has_value()) {
407 return false;
408 }
409 // Alg 6. 4.
410 return Tc.value() == lms_root();
411}
412
413std::optional<LMS_Tree_Node> LMS_PublicKey::lms_compute_root_from_sig(const LMS_Message& msg,
414 const LMS_Signature& sig) const {
415 // Alg. 6a 2.c, 2.g
416 if(lms_params().algorithm_type() != sig.lms_type() ||
417 lmots_params().algorithm_type() != sig.lmots_sig().algorithm_type()) {
418 return std::nullopt;
419 }
420 try {
421 const LMS_Params lms_params = LMS_Params::create_or_throw(sig.lms_type());
422 const LMOTS_Signature& lmots_sig = sig.lmots_sig();
423 const LMOTS_Params lmots_params = LMOTS_Params::create_or_throw(lmots_sig.algorithm_type());
424 const LMOTS_K Kc = lmots_compute_pubkey_from_sig(lmots_sig, msg, identifier(), sig.q());
425 const auto hash = lms_params.hash();
426
427 auto hash_pair_func = get_hash_pair_func_for_identifier(lms_params, identifier());
428
429 auto lms_address = TreeAddress(lms_params.h());
430 lms_address.set_address(LMS_TreeLayerIndex(0), LMS_Tree_Node_Idx(sig.q().get()));
431
432 const LMOTS_Public_Key pk_candidate(lmots_params, identifier(), sig.q(), Kc);
434 lms_gen_leaf(tmp, pk_candidate, lms_address, *hash);
435
437
438 compute_root(StrongSpan<LMS_Tree_Node>(root),
439 sig.auth_path(),
440 sig.q(),
441 StrongSpan<const LMS_Tree_Node>(tmp),
442 lms_params.m(),
443 LMS_TreeLayerIndex(lms_params.h()),
444 0,
445 std::move(hash_pair_func),
446 lms_address);
447 return LMS_Tree_Node(root);
448 } catch(const Decoding_Error&) {
449 return std::nullopt;
450 }
451}
452
453size_t LMS_Signature::size(const LMS_Params& lms_params, const LMOTS_Params& lmots_params) {
454 return sizeof(uint32_t) + LMOTS_Signature::size(lmots_params) + sizeof(uint32_t) + lms_params.h() * lms_params.m();
455}
456
457} // namespace Botan
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
size_t remaining() const
auto copy(const size_t count)
std::span< const uint8_t > take(const size_t count)
Helper class to ease in-place marshalling of concatenated fixed-length values.
constexpr void append(std::span< const uint8_t > buffer)
constexpr std::span< uint8_t > next(size_t bytes)
constexpr bool full() const
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:311
static std::unique_ptr< Hash_Engine > create_or_throw(std::string_view hash_fn, std::span< const uint8_t > common_prefix={}, std::string_view provider="")
The LM-OTS parameters.
Definition lm_ots.h:104
static LMOTS_Params create_or_throw(LMOTS_Algorithm_Type type)
Create the LM-OTS parameters from a known algorithm type.
Definition lm_ots.cpp:131
Representation of an LMOTS private key.
Definition lm_ots.h:260
void sign(StrongSpan< LMOTS_Signature_Bytes > out_sig, const LMS_Message &msg) const
Generate a new LMOTS signature.
Definition lm_ots.cpp:324
Representation of an OTS public key.
Definition lm_ots.h:319
static size_t size(const LMOTS_Params &params)
The expected size of the signature.
Definition lm_ots.h:211
LMOTS_Algorithm_Type algorithm_type() const
Returns the LM-OTS algorithm type.
Definition lm_ots.h:196
static LMOTS_Signature from_bytes_or_throw(BufferSlicer &slicer)
Parse a LM-OTS signature.
Definition lm_ots.cpp:271
const LMS_Params & lms_params() const
The LMS parameters for this LMS instance.
Definition lms.h:166
const LMOTS_Params & lmots_params() const
The LMOTS parameters used for OTS instances of this LMS instance.
Definition lms.h:171
const LMS_Identifier & identifier() const
The identifier of this LMS tree ('I' in RFC 8554).
Definition lms.h:176
LMS_Instance(LMS_Params lms_params, LMOTS_Params lmots_params, LMS_Identifier identifier)
Constructor storing the provided LMS data.
Definition lms.h:158
The LMS parameters.
Definition lms.h:91
const std::string & hash_name() const
Returns the name of the hash function to use.
Definition lms.h:126
size_t m() const
Returns the number of bytes associated with each node.
Definition lms.h:121
std::unique_ptr< HashFunction > hash() const
Construct a new hash instance for the LMS instance.
Definition lms.cpp:141
uint8_t h() const
Returns the height of the LMS tree.
Definition lms.h:116
static LMS_Params create_or_throw(LMS_Algorithm_Type type)
Create the LMS parameters from a known algorithm type.
Definition lms.cpp:145
Representation of an LMS Private key.
Definition lms.h:192
LMS_PublicKey sign_and_get_pk(StrongSpan< LMS_Signature_Bytes > out_sig, LMS_Tree_Node_Idx q, const LMS_Message &msg) const
Sign a message using an LMS_PrivateKey and the used leaf index (RFC 8554 5.4.1).
Definition lms.cpp:274
const LMS_Seed & seed() const
The secret seed used for LMOTS' WOTS chain input creation (RFC 8554 Appendix A).
Definition lms.h:203
The LMS public key.
Definition lms.h:227
static size_t size(const LMS_Params &lms_params)
The expected size of an LMS public key for given lms_params.
Definition lms.cpp:346
std::vector< uint8_t > to_bytes() const
Bytes of the full lms public key according to 8554 5.3.
Definition lms.cpp:327
static LMS_PublicKey from_bytes_or_throw(BufferSlicer &slicer)
Parse a public LMS key.
Definition lms.cpp:297
LMS_PublicKey(LMS_Params lms_params, LMOTS_Params lmots_params, LMS_Identifier I, LMS_Tree_Node lms_root)
Construct a public key for given public key data.
Definition lms.cpp:337
bool verify_signature(const LMS_Message &msg, const LMS_Signature &sig) const
Verify a LMS signature.
Definition lms.cpp:386
Container for LMS Signature data.
Definition lms.h:295
const LMOTS_Signature & lmots_sig() const
The LMOTS signature object containing the parsed LMOTS signature bytes contained in the LMS signature...
Definition lms.h:315
LMS_Tree_Node_Idx q() const
The index of the signing leaf given by the signature.
Definition lms.h:309
static LMS_Signature from_bytes_or_throw(BufferSlicer &slicer)
Parse the bytes of a lms signature into a LMS Signature object.
Definition lms.cpp:350
LMS_Algorithm_Type lms_type() const
The LMS algorithm type given by the signature.
Definition lms.h:320
StrongSpan< const LMS_AuthenticationPath > auth_path() const
The authentication path bytes given by the signature.
Definition lms.h:327
static size_t size(const LMS_Params &lms_params, const LMOTS_Params &lmots_params)
Definition lms.cpp:453
decltype(auto) size() const noexcept(noexcept(this->m_span.size()))
constexpr T & get() &
Definition strong_type.h:81
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:67
LMOTS_K lmots_compute_pubkey_from_sig(const LMOTS_Signature &sig, const LMS_Message &msg, const LMS_Identifier &identifier, LMS_Tree_Node_Idx q)
Compute a public key candidate for an OTS-signature-message pair and the OTS instance parameters.
Definition lm_ots.cpp:481
Strong< std::vector< uint8_t >, struct LMOTS_K_ > LMOTS_K
The K value from the LM-OTS public key.
Definition lm_ots.h:39
Gf448Elem root(const Gf448Elem &elem)
Compute the root of elem in the field.
LMS_Algorithm_Type
Enum of available LMS algorithm types.
Definition lms.h:32
constexpr size_t LMS_IDENTIFIER_LEN
The length in bytes of the LMS identifier (I).
Definition lms.h:69
Strong< std::vector< uint8_t >, struct LMS_Tree_Node_ > LMS_Tree_Node
A node with the LMS tree.
Definition lms.h:79
void treehash(StrongSpan< SphincsTreeNode > out_root, StrongSpan< SphincsAuthenticationPath > out_auth_path, const Sphincs_Parameters &params, 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< std::vector< uint8_t >, struct LMS_AuthenticationPath_ > LMS_AuthenticationPath
The authentication path of an LMS signature.
Definition lms.h:74
Strong< std::vector< uint8_t >, struct LMS_Identifier_ > LMS_Identifier
The identifier of an LMS tree (I in RFC 8554).
Definition lm_ots.h:54
LMOTS_Algorithm_Type
Enum of available LM-OTS algorithm types.
Definition lm_ots.h:69
Strong< std::vector< uint8_t >, struct LMS_Message_ > LMS_Message
A message that is signed with an LMS tree.
Definition lm_ots.h:59
constexpr auto concat(Rs &&... ranges)
Definition concat_util.h:95
void lmots_compute_pubkeys(std::span< uint8_t > out_ks, const LMOTS_Params &params, const LMS_Identifier &identifier, LMS_Tree_Node_Idx first_q, size_t count, const LMS_Seed &seed, Hash_Engine &engine)
Compute the public key hash values K (RFC 8554 4.3) of count consecutive LM-OTS instances beginning a...
Definition lm_ots.cpp:424
Strong< uint32_t, struct LMS_Tree_Node_Idx_, EnableArithmeticWithPlainNumber > LMS_Tree_Node_Idx
The index of a node within a specific LMS tree layer.
Definition lm_ots.h:49
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745
constexpr auto load_be(ParamTs &&... params)
Definition loadstor.h:504
void compute_root(StrongSpan< SphincsTreeNode > out, const Sphincs_Parameters &params, 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)
Strong< std::vector< uint8_t >, struct LMOTS_Signature_Bytes_ > LMOTS_Signature_Bytes
Byte vector of an LM-OTS signature.
Definition lm_ots.h:44