10#define BOTAN_LM_OTS_H_
12#include <botan/hash.h>
13#include <botan/internal/stl_util.h>
115 static LMOTS_Params create_or_throw(std::string_view hash_name, uint8_t w);
125 size_t n()
const {
return m_n; }
130 uint8_t
w()
const {
return m_w; }
135 uint8_t
coef_max()
const {
return (1 << m_w) - 1; }
140 uint16_t
p()
const {
return m_p; }
145 uint8_t
ls()
const {
return m_ls; }
150 const std::string&
hash_name()
const {
return m_hash_name; }
155 std::unique_ptr<HashFunction>
hash()
const {
return HashFunction::create_or_throw(hash_name()); }
172 std::string m_hash_name;
197 std::span<const uint8_t>
C()
const {
return m_C; }
213 std::vector<uint8_t> m_C;
214 std::vector<uint8_t> m_y_buffer;
215 std::vector<StrongSpan<const LMOTS_Node>> m_y;
228 m_params(params), m_identifier(identifier), m_q(q) {}
292 void derive_random_C(std::span<uint8_t> out,
HashFunction& hash)
const;
295 std::vector<LMOTS_Node> m_ots_sk;
321 OTS_Instance(params, identifier, q), m_K(std::move(K)) {}
uint8_t coef_max() const
The maximum the winternitz coefficients can have.
std::unique_ptr< HashFunction > hash() const
Construct a new hash instance for the OTS instance.
LMOTS_Algorithm_Type algorithm_type() const
Returns the LM-OTS algorithm type.
size_t n() const
The number of bytes of the output of the hash function.
uint8_t w() const
The width (in bits) of the Winternitz coefficients.
const std::string & hash_name() const
Name of the hash function to use.
uint8_t ls() const
The number of left-shift bits used in the checksum function Cksm.
uint16_t p() const
The number of n-byte string elements that make up the LM-OTS signature.
Representation of an LMOTS private key.
const LMOTS_Node & chain_input(uint16_t chain_idx) const
The secret chain input at a given chain index. (x[] in RFC 8554 4.2).
Representation of an OTS public key.
const LMOTS_K & K() const
The public key final hash value (K in RFC 8554 4.3 )
LMOTS_Public_Key(const LMOTS_Params ¶ms, const LMS_Identifier &identifier, LMS_Tree_Node_Idx q, LMOTS_K K)
Construct a new LMOTS public key object using the bytes.
Representation of a LM-OTS signature.
static size_t size(const LMOTS_Params ¶ms)
The expected size of the signature.
StrongSpan< const LMOTS_Node > y(uint16_t chain_idx) const
Returns the part of the signature for chain_idx.
LMOTS_Algorithm_Type algorithm_type() const
Returns the LM-OTS algorithm type.
std::span< const uint8_t > C() const
The n-byte randomizer of the signature.
Base class for LMOTS private and public key. Contains the parameters for the specific OTS instance.
const LMS_Identifier & identifier() const
The LMS identifier of the LMS tree containing this OTS instance ('I' in RFC 8554)
OTS_Instance(const LMOTS_Params ¶ms, const LMS_Identifier &identifier, LMS_Tree_Node_Idx q)
Constructor storing the specific OTS parameters.
LMS_Tree_Node_Idx q() const
The index of the LMS tree leaf associated with this OTS instance.
const LMOTS_Params & params() const
The LMOTS parameters.
LMOTS_K lmots_compute_pubkey_from_sig(const LMOTS_Signature &sig, const LMS_Message &msg, const LMS_Identifier &identifier, LMS_Tree_Node_Idx q)
Compute a public key candidate for an OTS-signature-message pair and the OTS instance parameters.
Strong< std::vector< uint8_t >, struct LMOTS_K_ > LMOTS_K
The K value from the LM-OTS public key.
Strong< std::vector< uint8_t >, struct LMS_Identifier_ > LMS_Identifier
The identifier of an LMS tree (I in RFC 8554)
LMOTS_Algorithm_Type
Enum of available LM-OTS algorithm types.
Strong< std::vector< uint8_t >, struct LMS_Message_ > LMS_Message
A message that is signed with an LMS tree.
Strong< uint32_t, struct LMS_Tree_Node_Idx_, EnableArithmeticWithPlainNumber > LMS_Tree_Node_Idx
The index of a node within a specific LMS tree layer.