Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | List of all members
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 (WotsChainIndex chain)
 
Sphincs_Addressset_hash (WotsHashIndex hash)
 
Sphincs_Addressset_keypair (TreeNodeIndex keypair)
 
Sphincs_Addressset_layer (HypertreeLayerIndex layer)
 
Sphincs_Addressset_tree (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 SPHINCS+ hash function address as specified in SPHINCS+ Specification Round 3.1, Section 2.7.3

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

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

◆ Sphincs_Address() [2/2]

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

Definition at line 53 of file sp_address.h.

53{ 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 126 of file sp_address.h.

126 {
127 Sphincs_Address result({0, 0, 0, 0, 0, 0, 0, 0});
128 result.copy_keypair_from(other);
129 return result;
130 }
Sphincs_Address(Sphincs_Address_Type type)
Definition sp_address.h:48

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

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

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

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

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

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

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

132{ 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()

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

Definition at line 79 of file sp_address.h.

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

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

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

◆ set_hash()

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

Definition at line 84 of file sp_address.h.

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

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

Referenced by Botan::wots_sign_and_pkgen().

◆ set_keypair()

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

Definition at line 74 of file sp_address.h.

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

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

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

◆ set_layer()

Sphincs_Address & Botan::Sphincs_Address::set_layer ( 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().

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

◆ set_tree()

Sphincs_Address & Botan::Sphincs_Address::set_tree ( 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().

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

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

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 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().

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

67 {
68 m_address[type_offset] = static_cast<uint32_t>(type);
69 return *this;
70 }

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

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

References Botan::store_be().

◆ to_bytes_compressed()

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

Definition at line 142 of file sp_address.h.

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

References Botan::store_be().


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