Botan 3.8.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 37 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 86 of file kyber_keys.cpp.

87 {
88 BufferSlicer s(private_key);
89 auto seed = KyberPrivateKeySeed{
92 };
93 BOTAN_ASSERT_NOMSG(s.empty());
94 return Kyber_Algos::expand_keypair(std::move(seed), std::move(mode));
95}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:61
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.

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

◆ 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 97 of file kyber_keys.cpp.

97 {
98 BOTAN_ASSERT_NONNULL(keypair.second);
99 const auto& seed = keypair.second->seed();
100 BOTAN_ARG_CHECK(seed.d.has_value(), "Cannot encode keypair without the full private seed");
101 return concat<secure_vector<uint8_t>>(seed.d.value(), seed.z);
102}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:88
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:31
constexpr auto concat(Rs &&... ranges)
Definition stl_util.h:264

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


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