Botan 3.6.1
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)
inline

Definition at line 49 of file sp_address.h.

49 {
50 m_address.fill(0);
51 set_type(type);
52 }
Sphincs_Address & set_type(Sphincs_Address_Type type)
Definition sp_address.h:74

◆ Sphincs_Address() [2/2]

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

Definition at line 54 of file sp_address.h.

54{ std::copy(address.begin(), address.end(), m_address.begin()); }

Member Function Documentation

◆ as_keypair_from()

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

Definition at line 131 of file sp_address.h.

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

References copy_keypair_from().

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

◆ as_subtree_from()

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

Definition at line 115 of file sp_address.h.

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

References copy_subtree_from().

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

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

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

◆ copy_subtree_from()

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

Definition at line 106 of file sp_address.h.

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

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

◆ get_type()

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

Definition at line 137 of file sp_address.h.

137{ 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 84 of file sp_address.h.

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

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

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

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

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

Referenced by Botan::wots_sign_and_pkgen().

◆ set_keypair_address()

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

Definition at line 79 of file sp_address.h.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Referenced by Botan::fors_public_key_from_signature(), Botan::fors_sign_and_pkgen(), 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 139 of file sp_address.h.

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

References Botan::store_be().

◆ to_bytes_compressed()

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

Definition at line 147 of file sp_address.h.

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

References Botan::store_be().


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