Botan 3.4.0
Crypto and TLS for C&
sp_wots.h
Go to the documentation of this file.
1/*
2 * WOTS+ - Winternitz One Time Signature+
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;
20class Sphincs_Hash_Functions;
21class Sphincs_Parameters;
22
23/**
24 * Implements a domain specific wrapper for the one-time signature scheme WOTS+
25 * (Winternitz OTS). It is meant to be used inside SPHINCS+ and does not aim to
26 * be applicable for other use cases. If this function is not used in a signing
27 * operation (i.e. @p sign_leaf_idx is not set), @p wots_steps may be empty.
28 */
29BOTAN_TEST_API void wots_sign_and_pkgen(StrongSpan<WotsSignature> sig_out,
30 StrongSpan<SphincsTreeNode> leaf_out,
31 const SphincsSecretSeed& secret_seed,
32 TreeNodeIndex leaf_idx,
33 std::optional<TreeNodeIndex> sign_leaf_idx,
34 const std::vector<WotsHashIndex>& wots_steps,
35 Sphincs_Address& leaf_addr,
36 Sphincs_Address& pk_addr,
37 const Sphincs_Parameters& params,
38 Sphincs_Hash_Functions& hashes);
39/**
40 * Reconstructs the WOTS public key from a given WOTS @p signature and
41 * @p message. This is tailored for the use case in the SPHINCS+ implementation
42 * and is not meant for general usability.
43 */
45 StrongSpan<const WotsSignature> signature,
46 Sphincs_Address& address,
47 const Sphincs_Parameters& params,
48 Sphincs_Hash_Functions& hashes);
49
50/**
51 * Given a @p msg construct the lengths (amount of hashes for signature) for each WOTS+ chain, including the checksum.
52 */
53BOTAN_TEST_API std::vector<WotsHashIndex> chain_lengths(const SphincsTreeNode& msg, const Sphincs_Parameters& params);
54
55} // namespace Botan
56
57#endif
#define BOTAN_TEST_API
Definition compiler.h:51
Strong< std::vector< uint8_t >, struct SphincsTreeNode_ > SphincsTreeNode
Either an XMSS or FORS tree node or leaf.
Definition sp_types.h:56
WotsPublicKey wots_public_key_from_signature(const SphincsTreeNode &hashed_message, StrongSpan< const WotsSignature > signature, Sphincs_Address &address, const Sphincs_Parameters &params, Sphincs_Hash_Functions &hashes)
Definition sp_wots.cpp:97
void wots_sign_and_pkgen(StrongSpan< WotsSignature > sig_out, StrongSpan< SphincsTreeNode > leaf_out, const SphincsSecretSeed &secret_seed, TreeNodeIndex leaf_idx, 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)
Definition sp_wots.cpp:126
Strong< std::vector< uint8_t >, struct WotsPublicKey_ > WotsPublicKey
Definition sp_types.h:59
Strong< secure_vector< uint8_t >, struct SphincsSecretSeed_ > SphincsSecretSeed
Definition sp_types.h:47
Strong< uint32_t, struct TreeNodeIndex_, EnableArithmeticWithPlainNumber > TreeNodeIndex
Index of an individual node inside an XMSS or FORS tree.
Definition sp_types.h:78
std::vector< WotsHashIndex > chain_lengths(const SphincsTreeNode &msg, const Sphincs_Parameters &params)
Definition sp_wots.cpp:85