Botan 3.6.1
Crypto and TLS for C&
Botan::ML_KEM_Expanding_Keypair_Codec Class Referencefinal

#include <ml_kem_impl.h>

Inheritance diagram for Botan::ML_KEM_Expanding_Keypair_Codec:
Botan::Kyber_Keypair_Codec

Public Member Functions

KyberInternalKeypair decode_keypair (std::span< const uint8_t > buffer, KyberConstants mode) const override
 
secure_vector< uint8_t > encode_keypair (KyberInternalKeypair keypair) const override
 

Detailed Description

Definition at line 108 of file ml_kem_impl.h.

Member Function Documentation

◆ decode_keypair()

KyberInternalKeypair Botan::ML_KEM_Expanding_Keypair_Codec::decode_keypair ( std::span< const uint8_t > buffer,
KyberConstants mode ) const
overridevirtual

Implements Botan::Kyber_Keypair_Codec.

Definition at line 71 of file ml_kem_impl.cpp.

72 {
73 BufferSlicer s(private_key);
74 auto seed = KyberPrivateKeySeed{
77 };
78 BOTAN_ASSERT_NOMSG(s.empty());
79 return Kyber_Algos::expand_keypair(std::move(seed), std::move(mode));
80}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59
static constexpr size_t SEED_BYTES
KyberInternalKeypair expand_keypair(KyberPrivateKeySeed seed, KyberConstants mode)
Strong< secure_vector< uint8_t >, struct KyberImplicitRejectionValue_ > KyberImplicitRejectionValue
Secret random value (called Z in the spec), used for implicit rejection in the decapsulation.
Definition kyber_types.h:42
Strong< secure_vector< uint8_t >, struct KyberSeedRandomness_ > KyberSeedRandomness
Principal seed used to generate Kyber key pairs.
Definition kyber_types.h:33

References BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::copy(), Botan::BufferSlicer::empty(), Botan::Kyber_Algos::expand_keypair(), and Botan::KyberConstants::SEED_BYTES.

◆ encode_keypair()

secure_vector< uint8_t > Botan::ML_KEM_Expanding_Keypair_Codec::encode_keypair ( KyberInternalKeypair keypair) const
overridevirtual

Implements Botan::Kyber_Keypair_Codec.

Definition at line 82 of file ml_kem_impl.cpp.

82 {
83 BOTAN_ASSERT_NONNULL(keypair.second);
84 const auto& seed = keypair.second->seed();
85 BOTAN_ARG_CHECK(seed.d.has_value(), "Cannot encode keypair without the full private seed");
86 return concat<secure_vector<uint8_t>>(seed.d.value(), seed.z);
87};
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:86
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29
constexpr auto concat(Rs &&... ranges)
Definition stl_util.h:263

References BOTAN_ARG_CHECK, BOTAN_ASSERT_NONNULL, and Botan::concat().


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