Botan 3.14.1
Crypto and TLS for C&
Botan::LMOTS_Public_Key Class Referencefinal

Representation of an OTS public key. More...

#include <lm_ots.h>

Inheritance diagram for Botan::LMOTS_Public_Key:
Botan::OTS_Instance

Public Member Functions

const LMS_Identifier & identifier () const
 The LMS identifier of the LMS tree containing this OTS instance ('I' in RFC 8554).
const LMOTS_K & K () const
 The public key final hash value (K in RFC 8554 4.3 ).
 LMOTS_Public_Key (const LMOTS_Params &params, const LMS_Identifier &identifier, LMS_Tree_Node_Idx q, LMOTS_K K)
 Construct a new LMOTS public key object using the bytes.
 LMOTS_Public_Key (const LMOTS_Private_Key &lmots_sk)
 Derivivation of an LMOTS public key using an LMOTS_Private_Key as defined in RFC 8554 4.3.
 LMOTS_Public_Key (const LMOTS_Private_Key &lmots_sk, Hash_Engine &engine)
 As above, but using a caller-provided hash engine, allowing its reuse over many key derivations.
const LMOTS_Params & params () const
 The LMOTS parameters.
LMS_Tree_Node_Idx q () const
 The index of the LMS tree leaf associated with this OTS instance.

Detailed Description

Representation of an OTS public key.

Contains the public key bytes as defined in RFC 8554 4.3:

u32str(type) || I || u32str(q) || K

Definition at line 319 of file lm_ots.h.

Constructor & Destructor Documentation

◆ LMOTS_Public_Key() [1/3]

Botan::LMOTS_Public_Key::LMOTS_Public_Key ( const LMOTS_Private_Key & lmots_sk)
explicit

Derivivation of an LMOTS public key using an LMOTS_Private_Key as defined in RFC 8554 4.3.

Definition at line 390 of file lm_ots.cpp.

390 :
391 LMOTS_Public_Key(lmots_sk, *Hash_Engine::create_or_throw(lmots_sk.params().hash_name())) {}
static std::unique_ptr< Hash_Engine > create_or_throw(std::string_view hash_fn, std::span< const uint8_t > common_prefix={}, std::string_view provider="")
LMOTS_Public_Key(const LMOTS_Private_Key &lmots_sk)
Derivivation of an LMOTS public key using an LMOTS_Private_Key as defined in RFC 8554 4....
Definition lm_ots.cpp:390

References LMOTS_Public_Key(), and Botan::OTS_Instance::params().

Referenced by LMOTS_Public_Key().

◆ LMOTS_Public_Key() [2/3]

Botan::LMOTS_Public_Key::LMOTS_Public_Key ( const LMOTS_Private_Key & lmots_sk,
Hash_Engine & engine )

As above, but using a caller-provided hash engine, allowing its reuse over many key derivations.

Definition at line 393 of file lm_ots.cpp.

393 :
394 /* NOLINT(*-slicing) */ OTS_Instance(lmots_sk) {
395 const uint16_t p = lmots_sk.params().p();
396 const size_t n = lmots_sk.params().n();
397
398 // Walk all chains to the top in lock-step
399 secure_vector<uint8_t> nodes(p * n);
400 std::vector<uint16_t> chains(p);
401 std::vector<std::span<uint8_t>> outputs(p);
402 std::vector<std::span<const uint8_t>> inputs(p);
403 for(uint16_t i = 0; i < p; ++i) {
404 chains[i] = i;
405 const auto node = std::span(nodes).subspan(i * n, n);
406 copy_mem(node, lmots_sk.chain_input(i));
407 outputs[i] = node;
408 inputs[i] = node;
409 }
410
411 Batch_Chain_Generator chain_gen(engine, lmots_sk.identifier(), lmots_sk.q(), p);
412 for(uint8_t j = 0; j < lmots_sk.params().coef_max(); ++j) {
413 chain_gen.process(chains, j, outputs, inputs);
414 }
415
416 const auto pk_hash = lmots_sk.params().hash();
417 pk_hash->update(lmots_sk.identifier());
418 pk_hash->update(store_be(lmots_sk.q()));
419 pk_hash->update(store_be(D_PBLC));
420 pk_hash->update(nodes);
421 m_K = pk_hash->final<LMOTS_K>();
422}
OTS_Instance(const LMOTS_Params &params, const LMS_Identifier &identifier, LMS_Tree_Node_Idx q)
Constructor storing the specific OTS parameters.
Definition lm_ots.h:230
Strong< std::vector< uint8_t >, struct LMOTS_K_ > LMOTS_K
The K value from the LM-OTS public key.
Definition lm_ots.h:39
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:144
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745

References Botan::LMOTS_Private_Key::chain_input(), Botan::copy_mem(), Botan::LMOTS_Params::hash(), Botan::OTS_Instance::identifier(), Botan::OTS_Instance::OTS_Instance(), Botan::OTS_Instance::params(), Botan::OTS_Instance::q(), and Botan::store_be().

◆ LMOTS_Public_Key() [3/3]

Botan::LMOTS_Public_Key::LMOTS_Public_Key ( const LMOTS_Params & params,
const LMS_Identifier & identifier,
LMS_Tree_Node_Idx q,
LMOTS_K K )
inline

Construct a new LMOTS public key object using the bytes.

Note that the passed params, identifier and q value should match with the prefix in pub_key_bytes.

Definition at line 339 of file lm_ots.h.

339 :
340 OTS_Instance(params, identifier, q), m_K(std::move(K)) {}
const LMOTS_K & K() const
The public key final hash value (K in RFC 8554 4.3 ).
Definition lm_ots.h:347
const LMS_Identifier & identifier() const
The LMS identifier of the LMS tree containing this OTS instance ('I' in RFC 8554).
Definition lm_ots.h:241
LMS_Tree_Node_Idx q() const
The index of the LMS tree leaf associated with this OTS instance.
Definition lm_ots.h:246
const LMOTS_Params & params() const
The LMOTS parameters.
Definition lm_ots.h:236

References Botan::OTS_Instance::identifier(), K(), Botan::OTS_Instance::OTS_Instance(), Botan::OTS_Instance::params(), and Botan::OTS_Instance::q().

Member Function Documentation

◆ identifier()

const LMS_Identifier & Botan::OTS_Instance::identifier ( ) const
inlineinherited

The LMS identifier of the LMS tree containing this OTS instance ('I' in RFC 8554).

Definition at line 241 of file lm_ots.h.

241{ return m_identifier; }

Referenced by Botan::LMOTS_Private_Key::LMOTS_Private_Key(), Botan::LMOTS_Private_Key::LMOTS_Private_Key(), Botan::LMOTS_Public_Key::LMOTS_Public_Key(), Botan::LMOTS_Public_Key::LMOTS_Public_Key(), OTS_Instance(), and Botan::LMOTS_Private_Key::sign().

◆ K()

const LMOTS_K & Botan::LMOTS_Public_Key::K ( ) const
inline

The public key final hash value (K in RFC 8554 4.3 ).

Returns
const LMOTS_K&

Definition at line 347 of file lm_ots.h.

347{ return m_K; }

Referenced by LMOTS_Public_Key().

◆ params()

◆ q()

LMS_Tree_Node_Idx Botan::OTS_Instance::q ( ) const
inlineinherited

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