Botan 3.4.0
Crypto and TLS for C&
sp_types.h
Go to the documentation of this file.
1/*
2 * SPHINCS+ Strong Type Definitions
3 * (C) 2023 Jack Lloyd
4 * 2023 Fabian Albert, René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 **/
8
9#ifndef BOTAN_SP_TYPES_H_
10#define BOTAN_SP_TYPES_H_
11
12#include <botan/secmem.h>
13#include <botan/strong_type.h>
14
15namespace Botan {
16
17/*
18 * The following gives an overview about the different building blocks of
19 * Sphincs+ and how they are connected. In general, we always consider sequences of bytes
20 * that are interpreted in the following manner (flattening the || operation, i.e.,
21 * mapping the byte sequence of a strong type onto the underlying byte sequence of the containing strong type).
22 * Only FORS indices are not seen as byte sequences.
23 *
24 * Sphincs+ secret key is built up like the following:
25 * [SphincsSecretSeed || SphincsSecretPRF || SphincsPublicSeed || SphincsTreeNode] (the last chunk is the root node of Sphincs+' topmost XMSS tree)
26 *
27 * Sphincs+ public key is built up like the following:
28 * [SphincsPublicSeed || SphincsTreeNode] (the last chunk is the root node of Sphincs+' topmost XMSS tree)]
29 *
30 * Sphincs+ signature is built up like the following:
31 * [SphincsMessageRandomness (n bytes) || ForsSignature (k(a+1)*n = fors_signature_bytes bytes) || SphincsHypertreeSignature]. SphincsHypertreeSignature contains a total of
32 * d SphincsXMSSSignatures, with (h+d*len)*n = xmss_signature_bytes bytes each.
33 *
34 * ForsSignature is built up like the following:
35 * [<Leaf Secret of FORS Subtree 1>(n bytes) || SphincsAuthenticationPath (Subtree 1, a*n bytes) || ... || <Leaf Secret of FORS Subtree k>(n bytes) || SphincsAuthenticationPath (Subtree k, a*n bytes)]
36 * We define no special type for the leaf secret. The leaf secret is the secret PRF output that is hashed to create a FORS subtree's leaf.
37 *
38 * SphincsXmssSignature is built up like the following:
39 * [WotsSignature || SphincsAuthenticationPath]
40 *
41 * WotsSignature is built up like the following:
42 * [WotsNode || ... || WotsNode] contains len WotsNodes, each of length n bytes.
43 */
44
45using SphincsHashedMessage = Strong<std::vector<uint8_t>, struct SphincsHashedMessage_>;
46using SphincsPublicSeed = Strong<std::vector<uint8_t>, struct SphincsPublicSeed_>;
47using SphincsSecretSeed = Strong<secure_vector<uint8_t>, struct SphincsSecretSeed_>;
48using SphincsSecretPRF = Strong<secure_vector<uint8_t>, struct SphincsSecretPRF_>;
49using SphincsOptionalRandomness = Strong<secure_vector<uint8_t>, struct SphincsOptionalRandomness_>;
50using SphincsMessageRandomness = Strong<secure_vector<uint8_t>, struct SphincsMessageRandomness_>;
51using SphincsXmssSignature = Strong<std::vector<uint8_t>, struct SphincsXmssSignature_>;
52using SphincsHypertreeSignature = Strong<std::vector<uint8_t>, struct SphincsXmssSignature_>;
53using SphincsAuthenticationPath = Strong<std::vector<uint8_t>, struct SphincsAuthenticationPath_>;
54
55/// Either an XMSS or FORS tree node or leaf
56using SphincsTreeNode = Strong<std::vector<uint8_t>, struct SphincsTreeNode_>;
57using ForsLeafSecret = Strong<secure_vector<uint8_t>, struct ForsLeafSecret_>;
58using ForsSignature = Strong<std::vector<uint8_t>, struct ForsSignature_>;
59using WotsPublicKey = Strong<std::vector<uint8_t>, struct WotsPublicKey_>;
60
61/// End node of a WOTS+ chain (part of the WOTS+ public key)
62using WotsPublicKeyNode = Strong<std::vector<uint8_t>, struct WotsPublicKeyNode_>;
63
64/// Start (or intermediate) node of a WOTS+ chain
65using WotsNode = Strong<secure_vector<uint8_t>, struct WotsNode_>;
66using WotsSignature = Strong<secure_vector<uint8_t>, struct WotsSignature_>;
67
68/// Index of the layer within a FORS/XMSS tree
70
71/// Index of a layer in the XMSS hyper-tree
73
74/// Index of an XMSS tree (unique for just the local hyper-tree layer)
76
77/// Index of an individual node inside an XMSS or FORS tree
79
80/// Index of a WOTS chain within a single usage of WOTS
82
83/// Index of a hash application inside a single WOTS chain (integers in "base_w")
85
86} // namespace Botan
87
88#endif