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

Codec for private keys as 64-byte seeds: d || z. More...

#include <kyber_keys.h>

Inheritance diagram for Botan::Seed_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

Codec for private keys as 64-byte seeds: d || z.

Definition at line 38 of file kyber_keys.h.

Member Function Documentation

◆ decode_keypair()

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

Implements Botan::Kyber_Keypair_Codec.

Definition at line 118 of file kyber_keys.cpp.

119 {
120 BufferSlicer s(private_key);
121 auto seed = KyberPrivateKeySeed{
124 };
125 BOTAN_ASSERT_NOMSG(s.empty());
126 return Kyber_Algos::expand_keypair(std::move(seed), std::move(mode));
127}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
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::Seed_Expanding_Keypair_Codec::encode_keypair ( KyberInternalKeypair keypair) const
overridevirtual

Implements Botan::Kyber_Keypair_Codec.

Definition at line 129 of file kyber_keys.cpp.

129 {
130 BOTAN_ASSERT_NONNULL(keypair.second);
131 const auto& seed = keypair.second->seed();
132 BOTAN_ARG_CHECK(seed.d.has_value(), "Cannot encode keypair without the full private seed");
133 return concat<secure_vector<uint8_t>>(seed.d.value(), seed.z);
134}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:121
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
constexpr auto concat(Rs &&... ranges)
Definition concat_util.h:95

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

Referenced by Botan::Kyber_PrivateKey::formatted_raw_private_key_bits().


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