Botan 3.14.1
Crypto and TLS for C&
sp_wots.h
Go to the documentation of this file.
1/*
2 * SLH-DSA's WOTS+ - Winternitz One Time Signature Plus Scheme (FIPS 205, Section 5)
3 * (C) 2023 Jack Lloyd
4 * 2023 Fabian Albert, René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity
5 *
6 * Parts of this file have been adapted from https://github.com/sphincs/sphincsplus
7 *
8 * Botan is released under the Simplified BSD License (see license.txt)
9 **/
10
11#ifndef BOTAN_SP_WOTS_H_
12#define BOTAN_SP_WOTS_H_
13
14#include <botan/internal/sp_types.h>
15#include <optional>
16
17namespace Botan {
18
19class Sphincs_Address;
22
23/**
24 * @brief FIPS 205, Algorithm 6 and 7: wots_pkGen and wots_sign
25 *
26 * Implements a domain specific wrapper for the one-time signature scheme WOTS+
27 * (Winternitz OTS). It is meant to be used inside SLH-DSA and does not aim to
28 * be applicable for other use cases. If this function is not used in a signing
29 * operation (i.e. @p sign_leaf_idx is not set), @p wots_steps may be empty.
30 *
31 * Computes the WOTS public key leaves for @p leaf_count consecutive leaves
32 * starting at @p first_leaf_idx into @p leaves_out, batching the hash
33 * invocations across all leaves' chains. If @p sign_leaf_idx falls into
34 * this range, its WOTS signature is written to @p sig_out in passing.
35 */
37 std::span<uint8_t> leaves_out,
38 const SphincsSecretSeed& secret_seed,
39 TreeNodeIndex first_leaf_idx,
40 size_t leaf_count,
41 std::optional<TreeNodeIndex> sign_leaf_idx,
42 const std::vector<WotsHashIndex>& wots_steps,
43 Sphincs_Address& leaf_addr,
44 Sphincs_Address& pk_addr,
45 const Sphincs_Parameters& params,
47
48/**
49 * @brief FIPS 205, Algorithm 8: wots_pkFromSig
50 *
51 * Reconstructs the WOTS public key from a given WOTS @p signature and
52 * @p message. This is tailored for the use case in the SLH-DSA implementation
53 * and is not meant for general usability in non SLH-DSA algorithms.
54 */
57 const Sphincs_Address& address,
58 const Sphincs_Parameters& params,
60
61/**
62 * Given a @p msg construct the lengths (amount of hashes for signature) for each WOTS+ chain, including the checksum.
63 *
64 * Corresponds to FIPS 205, Algorithm 7 or 8, Step 1-7
65 */
66BOTAN_TEST_API std::vector<WotsHashIndex> chain_lengths(const SphincsTreeNode& msg, const Sphincs_Parameters& params);
67
68} // namespace Botan
69
70#endif
#define BOTAN_TEST_API
Definition api.h:41
Strong< std::vector< uint8_t >, struct SphincsTreeNode_ > SphincsTreeNode
Either an XMSS or FORS tree node or leaf.
Definition sp_types.h:70
WotsPublicKey wots_public_key_from_signature(const SphincsTreeNode &hashed_message, StrongSpan< const WotsSignature > signature, const Sphincs_Address &address, const Sphincs_Parameters &params, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 8: wots_pkFromSig.
Definition sp_wots.cpp:81
Strong< std::vector< uint8_t >, struct WotsPublicKey_ > WotsPublicKey
Definition sp_types.h:73
Strong< secure_vector< uint8_t >, struct SphincsSecretSeed_ > SphincsSecretSeed
Definition sp_types.h:61
Strong< uint32_t, struct TreeNodeIndex_, EnableArithmeticWithPlainNumber > TreeNodeIndex
Index of an individual node inside an XMSS or FORS tree.
Definition sp_types.h:92
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 &params, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 6 and 7: wots_pkGen and wots_sign.
Definition sp_wots.cpp:130
std::vector< WotsHashIndex > chain_lengths(const SphincsTreeNode &msg, const Sphincs_Parameters &params)
Definition sp_wots.cpp:69