Botan 3.5.0
Crypto and TLS for C&
Botan::Kyber_PublicKeyInternal Class Reference

#include <kyber_keys.h>

Public Member Functions

const KyberHashedPublicKeyH_public_key_bits_raw () const
 
Ciphertext indcpa_encrypt (StrongSpan< const KyberMessage > m, StrongSpan< const KyberEncryptionRandomness > r) const
 
 Kyber_PublicKeyInternal ()=delete
 
 Kyber_PublicKeyInternal (const KyberConstants &mode, std::span< const uint8_t > polynomials, KyberSeedRho seed)
 
 Kyber_PublicKeyInternal (KyberConstants mode, PolynomialVector polynomials, KyberSeedRho seed)
 
const KyberConstantsmode () const
 
const KyberSerializedPublicKeypublic_key_bits_raw () const
 
const KyberSeedRhorho () const
 
const PolynomialVectort () const
 

Detailed Description

Definition at line 21 of file kyber_keys.h.

Constructor & Destructor Documentation

◆ Kyber_PublicKeyInternal() [1/3]

Botan::Kyber_PublicKeyInternal::Kyber_PublicKeyInternal ( KyberConstants mode,
PolynomialVector polynomials,
KyberSeedRho seed )

Definition at line 19 of file kyber_keys.cpp.

19 :
20 m_mode(std::move(mode)),
21 m_t(std::move(t)),
22 m_rho(std::move(rho)),
23 m_public_key_bits_raw(concat(m_t.to_bytes(), m_rho)),
24 m_H_public_key_bits_raw(m_mode.symmetric_primitives().H(m_public_key_bits_raw)) {}
Kyber_Symmetric_Primitives & symmetric_primitives() const
const KyberSeedRho & rho() const
Definition kyber_keys.h:32
const PolynomialVector & t() const
Definition kyber_keys.h:30
const KyberConstants & mode() const
Definition kyber_keys.h:34
KyberMessage H(StrongSpan< const KyberMessage > m) const
constexpr auto concat(Rs &&... ranges)
Definition stl_util.h:262

◆ Kyber_PublicKeyInternal() [2/3]

Botan::Kyber_PublicKeyInternal::Kyber_PublicKeyInternal ( const KyberConstants & mode,
std::span< const uint8_t > polynomials,
KyberSeedRho seed )
inline

Definition at line 25 of file kyber_keys.h.

25 :
26 Kyber_PublicKeyInternal(mode, PolynomialVector::from_bytes(polynomials, mode), std::move(seed)) {}
static PolynomialVector from_bytes(std::span< const uint8_t > a, const KyberConstants &mode)

◆ Kyber_PublicKeyInternal() [3/3]

Botan::Kyber_PublicKeyInternal::Kyber_PublicKeyInternal ( )
delete

Member Function Documentation

◆ H_public_key_bits_raw()

const KyberHashedPublicKey & Botan::Kyber_PublicKeyInternal::H_public_key_bits_raw ( ) const
inline

Definition at line 38 of file kyber_keys.h.

38{ return m_H_public_key_bits_raw; }

◆ indcpa_encrypt()

Ciphertext Botan::Kyber_PublicKeyInternal::indcpa_encrypt ( StrongSpan< const KyberMessage > m,
StrongSpan< const KyberEncryptionRandomness > r ) const

NIST FIPS 203 IPD, Algorithm 13 (K-PKE.Encrypt)

Definition at line 29 of file kyber_keys.cpp.

30 {
31 auto at = PolynomialMatrix::generate(m_rho, true /* transposed */, m_mode);
32
33 auto rv = PolynomialVector::getnoise_eta1(r, 0, m_mode);
34 auto e1 = PolynomialVector::getnoise_eta2(r, m_mode.k(), m_mode);
35 auto e2 = Polynomial::getnoise_eta2(r, 2 * m_mode.k(), m_mode);
36
37 rv.ntt();
38
39 auto u = at.pointwise_acc_montgomery(rv);
40 u.invntt_tomont();
41 u += e1;
42 u.reduce();
43
44 auto mu = Polynomial::from_message(m);
46 v.invntt_tomont();
47 v += e2;
48 v += mu;
49 v.reduce();
50
51 return Ciphertext(std::move(u), v, m_mode);
52}
static PolynomialMatrix generate(StrongSpan< const KyberSeedRho > seed, const bool transposed, const KyberConstants &mode)
static PolynomialVector getnoise_eta1(KyberSigmaOrEncryptionRandomness seed, uint8_t nonce, const KyberConstants &mode)
static Polynomial pointwise_acc_montgomery(const PolynomialVector &a, const PolynomialVector &b)
static PolynomialVector getnoise_eta2(StrongSpan< const KyberEncryptionRandomness > seed, uint8_t nonce, const KyberConstants &mode)
static Polynomial getnoise_eta2(StrongSpan< const KyberEncryptionRandomness > seed, uint8_t nonce, const KyberConstants &mode)
static Polynomial from_message(StrongSpan< const KyberMessage > msg)

References Botan::Polynomial::from_message(), Botan::PolynomialMatrix::generate(), Botan::PolynomialVector::getnoise_eta1(), Botan::Polynomial::getnoise_eta2(), Botan::PolynomialVector::getnoise_eta2(), Botan::KyberConstants::k(), and Botan::PolynomialVector::pointwise_acc_montgomery().

◆ mode()

const KyberConstants & Botan::Kyber_PublicKeyInternal::mode ( ) const
inline

Definition at line 34 of file kyber_keys.h.

34{ return m_mode; }

◆ public_key_bits_raw()

const KyberSerializedPublicKey & Botan::Kyber_PublicKeyInternal::public_key_bits_raw ( ) const
inline

Definition at line 36 of file kyber_keys.h.

36{ return m_public_key_bits_raw; }

◆ rho()

const KyberSeedRho & Botan::Kyber_PublicKeyInternal::rho ( ) const
inline

Definition at line 32 of file kyber_keys.h.

32{ return m_rho; }

◆ t()

const PolynomialVector & Botan::Kyber_PublicKeyInternal::t ( ) const
inline

Definition at line 30 of file kyber_keys.h.

30{ return m_t; }

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