Botan 3.14.1
Crypto and TLS for C&
Botan::Kyber_Algos::PolynomialSampler< SeedT > Class Template Reference

#include <kyber_algos.h>

Public Member Functions

 PolynomialSampler (StrongSpan< const SeedT > seed, const KyberConstants &mode)
std::pair< KyberPolyVec, KyberPoly > sample_polynomial_vector_and_poly_cbd_eta2 ()
 Samples a polynomial vector and a single polynomial in one PRF batch.
KyberPolyVec sample_polynomial_vector_cbd_eta1 ()
std::pair< KyberPolyVec, KyberPolyVec > sample_polynomial_vector_pair_cbd_eta1 ()
 Samples two polynomial vectors in a single PRF batch.

Detailed Description

template<typename SeedT>
requires std::same_as<KyberSeedSigma, SeedT> || std::same_as<KyberEncryptionRandomness, SeedT>
class Botan::Kyber_Algos::PolynomialSampler< SeedT >

Allows sampling multiple polynomials from a single seed via a XOF.

Used in Algorithms 13 (K-PKE.KeyGen) and 14 (K-PKE.Encrypt), and takes care of the continuous nonce value internally.

Definition at line 65 of file kyber_algos.h.

Constructor & Destructor Documentation

◆ PolynomialSampler()

template<typename SeedT>
Botan::Kyber_Algos::PolynomialSampler< SeedT >::PolynomialSampler ( StrongSpan< const SeedT > seed,
const KyberConstants & mode )
inline

Definition at line 67 of file kyber_algos.h.

67 :
68 m_seed(seed), m_mode(mode), m_nonce(0) {}

Member Function Documentation

◆ sample_polynomial_vector_and_poly_cbd_eta2()

template<typename SeedT>
std::pair< KyberPolyVec, KyberPoly > Botan::Kyber_Algos::PolynomialSampler< SeedT >::sample_polynomial_vector_and_poly_cbd_eta2 ( )
inline

Samples a polynomial vector and a single polynomial in one PRF batch.

Definition at line 86 of file kyber_algos.h.

88 {
90 sample_polys_cbd(concat(result.first.polynomials(), std::array{&result.second}), m_mode.eta2());
91 return result;
92 }
Botan::CRYSTALS::Polynomial< KyberPolyTraits, Botan::CRYSTALS::Domain::Normal > KyberPoly
Definition kyber_types.h:29
constexpr auto concat(Rs &&... ranges)
Definition concat_util.h:95
Botan::CRYSTALS::PolynomialVector< KyberPolyTraits, Botan::CRYSTALS::Domain::Normal > KyberPolyVec
Definition kyber_types.h:30

References Botan::concat().

Referenced by Botan::Kyber_PublicKeyInternal::indcpa_encrypt().

◆ sample_polynomial_vector_cbd_eta1()

template<typename SeedT>
KyberPolyVec Botan::Kyber_Algos::PolynomialSampler< SeedT >::sample_polynomial_vector_cbd_eta1 ( )
inline

Definition at line 70 of file kyber_algos.h.

70 {
71 KyberPolyVec vec(m_mode.k());
72 sample_polys_cbd(vec.polynomials(), m_mode.eta1());
73 return vec;
74 }

References Botan::CRYSTALS::PolynomialVector< Trait, D >::polynomials().

Referenced by Botan::Kyber_PublicKeyInternal::indcpa_encrypt().

◆ sample_polynomial_vector_pair_cbd_eta1()

template<typename SeedT>
std::pair< KyberPolyVec, KyberPolyVec > Botan::Kyber_Algos::PolynomialSampler< SeedT >::sample_polynomial_vector_pair_cbd_eta1 ( )
inline

Samples two polynomial vectors in a single PRF batch.

Definition at line 77 of file kyber_algos.h.

77 {
78 auto result = std::make_pair(KyberPolyVec(m_mode.k()), KyberPolyVec(m_mode.k()));
79 sample_polys_cbd(concat(result.first.polynomials(), //
80 result.second.polynomials()),
81 m_mode.eta1());
82 return result;
83 }

References Botan::concat().

Referenced by Botan::Kyber_Algos::expand_keypair().


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