Botan 3.9.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 34 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 51 of file sp_address.h.

51 : m_address{} {
52 std::copy(address.begin(), address.end(), m_address.begin());
53 }

Member Function Documentation

◆ as_keypair_from()

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

Definition at line 130 of file sp_address.h.

130 {
131 Sphincs_Address result({0, 0, 0, 0, 0, 0, 0, 0});
132 result.copy_keypair_from(other);
133 return result;
134 }
Sphincs_Address(Sphincs_Address_Type type)
Definition sp_address.h:49

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 114 of file sp_address.h.

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

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 120 of file sp_address.h.

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

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 105 of file sp_address.h.

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

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 136 of file sp_address.h.

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

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 83 of file sp_address.h.

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

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 93 of file sp_address.h.

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

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 78 of file sp_address.h.

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

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 57 of file sp_address.h.

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

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 62 of file sp_address.h.

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

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 88 of file sp_address.h.

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

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 98 of file sp_address.h.

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

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 73 of file sp_address.h.

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

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 138 of file sp_address.h.

138 {
139 std::array<uint8_t, sizeof(m_address)> result{};
140 for(unsigned int i = 0; i < m_address.size(); ++i) {
141 store_be(m_address[i], result.data() + (i * 4));
142 }
143 return result;
144 }
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 146 of file sp_address.h.

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

References Botan::store_be().


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