Botan 3.11.0
Crypto and TLS for C&
Botan::Sphincs_Address Class Referencefinal

#include <sp_address.h>

Public Member Functions

Sphincs_Addresscopy_keypair_from (const Sphincs_Address other)
Sphincs_Addresscopy_subtree_from (const Sphincs_Address &other)
Sphincs_Address_Type get_type () const
Sphincs_Addressset_chain_address (WotsChainIndex chain)
Sphincs_Addressset_hash_address (WotsHashIndex hash)
Sphincs_Addressset_keypair_address (TreeNodeIndex keypair)
Sphincs_Addressset_layer_address (HypertreeLayerIndex layer)
Sphincs_Addressset_tree_address (XmssTreeIndexInLayer tree)
Sphincs_Addressset_tree_height (TreeLayerIndex tree_height)
Sphincs_Addressset_tree_index (TreeNodeIndex tree_index)
Sphincs_Addressset_type (Sphincs_Address_Type type)
 Sphincs_Address (Sphincs_Address_Type type)
 Sphincs_Address (std::array< uint32_t, 8 > address)
std::array< uint8_t, 32 > to_bytes () const
std::array< uint8_t, 22 > to_bytes_compressed () const

Static Public Member Functions

static Sphincs_Address as_keypair_from (const Sphincs_Address &other)
static Sphincs_Address as_subtree_from (const Sphincs_Address &other)

Detailed Description

Representation of a SLH-DSA hash function address as specified in FIPS 205, Section 4.2

Definition at line 32 of file sp_address.h.

Constructor & Destructor Documentation

◆ Sphincs_Address() [1/2]

Botan::Sphincs_Address::Sphincs_Address ( Sphincs_Address_Type type)
inlineexplicit

◆ Sphincs_Address() [2/2]

Botan::Sphincs_Address::Sphincs_Address ( std::array< uint32_t, 8 > address)
inlineexplicit

Definition at line 49 of file sp_address.h.

49 : m_address{} {
50 std::copy(address.begin(), address.end(), m_address.begin());
51 }

Member Function Documentation

◆ as_keypair_from()

Sphincs_Address Botan::Sphincs_Address::as_keypair_from ( const Sphincs_Address & other)
inlinestatic

Definition at line 128 of file sp_address.h.

128 {
129 Sphincs_Address result({0, 0, 0, 0, 0, 0, 0, 0});
130 result.copy_keypair_from(other);
131 return result;
132 }
Sphincs_Address(Sphincs_Address_Type type)
Definition sp_address.h:47

References Sphincs_Address().

Referenced by Botan::fors_public_key_from_signature(), and Botan::fors_sign_and_pkgen().

◆ as_subtree_from()

Sphincs_Address Botan::Sphincs_Address::as_subtree_from ( const Sphincs_Address & other)
inlinestatic

Definition at line 112 of file sp_address.h.

112 {
113 auto result = Sphincs_Address({0, 0, 0, 0, 0, 0, 0, 0});
114 result.copy_subtree_from(other);
115 return result;
116 }

References Sphincs_Address().

Referenced by Botan::xmss_sign_and_pkgen().

◆ copy_keypair_from()

Sphincs_Address & Botan::Sphincs_Address::copy_keypair_from ( const Sphincs_Address other)
inline

Definition at line 118 of file sp_address.h.

118 {
119 m_address[layer_offset] = other.m_address[layer_offset];
120 m_address[tree_offset + 0] = other.m_address[tree_offset + 0];
121 m_address[tree_offset + 1] = other.m_address[tree_offset + 1];
122 m_address[tree_offset + 2] = other.m_address[tree_offset + 2];
123 m_address[keypair_offset] = other.m_address[keypair_offset];
124
125 return *this;
126 }

References Sphincs_Address().

Referenced by Botan::ht_verify().

◆ copy_subtree_from()

Sphincs_Address & Botan::Sphincs_Address::copy_subtree_from ( const Sphincs_Address & other)
inline

Definition at line 103 of file sp_address.h.

103 {
104 m_address[layer_offset] = other.m_address[layer_offset];
105 m_address[tree_offset + 0] = other.m_address[tree_offset + 0];
106 m_address[tree_offset + 1] = other.m_address[tree_offset + 1];
107 m_address[tree_offset + 2] = other.m_address[tree_offset + 2];
108
109 return *this;
110 }

References Sphincs_Address().

Referenced by Botan::ht_sign(), and Botan::ht_verify().

◆ get_type()

Sphincs_Address_Type Botan::Sphincs_Address::get_type ( ) const
inline

Definition at line 134 of file sp_address.h.

134{ return Sphincs_Address_Type(m_address[type_offset]); }
Sphincs_Address_Type
Definition sp_address.h:18

Referenced by Botan::wots_sign_and_pkgen(), and Botan::xmss_sign_and_pkgen().

◆ set_chain_address()

Sphincs_Address & Botan::Sphincs_Address::set_chain_address ( WotsChainIndex chain)
inline

Definition at line 81 of file sp_address.h.

81 {
82 m_address[chain_offset] = chain.get();
83 return *this;
84 }

References Botan::detail::Strong_Base< T >::get(), and Sphincs_Address().

Referenced by Botan::wots_public_key_from_signature(), and Botan::wots_sign_and_pkgen().

◆ set_hash_address()

Sphincs_Address & Botan::Sphincs_Address::set_hash_address ( WotsHashIndex hash)
inline

Definition at line 91 of file sp_address.h.

91 {
92 m_address[hash_offset] = hash.get();
93 return *this;
94 }

References Botan::detail::Strong_Base< T >::get(), and Sphincs_Address().

Referenced by Botan::wots_sign_and_pkgen().

◆ set_keypair_address()

Sphincs_Address & Botan::Sphincs_Address::set_keypair_address ( TreeNodeIndex keypair)
inline

Definition at line 76 of file sp_address.h.

76 {
77 m_address[keypair_offset] = keypair.get();
78 return *this;
79 }

References Botan::detail::Strong_Base< T >::get(), and Sphincs_Address().

Referenced by Botan::ht_sign(), Botan::ht_verify(), and Botan::wots_sign_and_pkgen().

◆ set_layer_address()

Sphincs_Address & Botan::Sphincs_Address::set_layer_address ( HypertreeLayerIndex layer)
inline

Definition at line 55 of file sp_address.h.

55 {
56 m_address[layer_offset] = layer.get();
57 return *this;
58 }

References Botan::detail::Strong_Base< T >::get(), and Sphincs_Address().

Referenced by Botan::ht_sign(), Botan::ht_verify(), and Botan::xmss_gen_root().

◆ set_tree_address()

Sphincs_Address & Botan::Sphincs_Address::set_tree_address ( XmssTreeIndexInLayer tree)
inline

Definition at line 60 of file sp_address.h.

60 {
61 m_address[tree_offset + 0] = 0; // not required by all current instances
62 m_address[tree_offset + 1] = static_cast<uint32_t>(tree.get() >> 32);
63 m_address[tree_offset + 2] = static_cast<uint32_t>(tree.get());
64 return *this;
65 }

References Botan::detail::Strong_Base< T >::get(), and Sphincs_Address().

Referenced by Botan::ht_sign(), and Botan::ht_verify().

◆ set_tree_height()

Sphincs_Address & Botan::Sphincs_Address::set_tree_height ( TreeLayerIndex tree_height)
inline

Definition at line 86 of file sp_address.h.

86 {
87 m_address[tree_height_offset] = tree_height.get();
88 return *this;
89 }

References Botan::detail::Strong_Base< T >::get(), and Sphincs_Address().

Referenced by Botan::compute_root(), and Botan::treehash().

◆ set_tree_index()

Sphincs_Address & Botan::Sphincs_Address::set_tree_index ( TreeNodeIndex tree_index)
inline

Definition at line 96 of file sp_address.h.

96 {
97 m_address[tree_index_offset] = tree_index.get();
98 return *this;
99 }

References Botan::detail::Strong_Base< T >::get(), and Sphincs_Address().

Referenced by Botan::compute_root(), and Botan::treehash().

◆ set_type()

Sphincs_Address & Botan::Sphincs_Address::set_type ( Sphincs_Address_Type type)
inline

Definition at line 71 of file sp_address.h.

71 {
72 m_address[type_offset] = static_cast<uint32_t>(type);
73 return *this;
74 }

References Sphincs_Address().

Referenced by Botan::fors_public_key_from_signature(), Botan::fors_sign_and_pkgen(), Sphincs_Address(), Botan::wots_sign_and_pkgen(), and Botan::xmss_sign_and_pkgen().

◆ to_bytes()

std::array< uint8_t, 32 > Botan::Sphincs_Address::to_bytes ( ) const
inline

Definition at line 136 of file sp_address.h.

136 {
137 std::array<uint8_t, sizeof(m_address)> result{};
138 for(unsigned int i = 0; i < m_address.size(); ++i) {
139 store_be(m_address[i], result.data() + (i * 4));
140 }
141 return result;
142 }
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745

References Botan::store_be().

◆ to_bytes_compressed()

std::array< uint8_t, 22 > Botan::Sphincs_Address::to_bytes_compressed ( ) const
inline

Definition at line 144 of file sp_address.h.

144 {
145 std::array<uint8_t, 22> result{};
146
147 result[0] = static_cast<uint8_t>(m_address[layer_offset]);
148 store_be(m_address[tree_offset + 1], &result[1]);
149 store_be(m_address[tree_offset + 2], &result[5]);
150 result[9] = static_cast<uint8_t>(m_address[type_offset]);
151 store_be(m_address[keypair_offset], &result[10]);
152 store_be(m_address[chain_offset], &result[14]);
153 store_be(m_address[hash_offset], &result[18]);
154
155 return result;
156 }

References Botan::store_be().


The documentation for this class was generated from the following file: