Botan 3.5.0
Crypto and TLS for C&
|
#include <kyber_structures.h>
Public Member Functions | |
void | csubq () |
void | invntt_tomont () |
void | ntt () |
Polynomial & | operator+= (const Polynomial &other) |
Polynomial & | operator-= (const Polynomial &other) |
int16_t & | operator[] (size_t idx) |
int16_t | operator[] (size_t idx) const |
Polynomial () | |
void | reduce () |
size_t | size () const |
void | to_bytes (std::span< uint8_t > out) |
KyberMessage | to_message () |
void | tomont () |
Static Public Member Functions | |
static Polynomial | basemul_montgomery (const Polynomial &a, const Polynomial &b) |
static Polynomial | cbd2 (StrongSpan< const KyberSamplingRandomness > buf) |
static Polynomial | cbd3 (StrongSpan< const KyberSamplingRandomness > buf) |
static Polynomial | from_bytes (std::span< const uint8_t > a) |
static Polynomial | from_message (StrongSpan< const KyberMessage > msg) |
static Polynomial | getnoise_eta1 (KyberSigmaOrEncryptionRandomness seed, uint8_t nonce, const KyberConstants &mode) |
static Polynomial | getnoise_eta2 (StrongSpan< const KyberEncryptionRandomness > seed, uint8_t nonce, const KyberConstants &mode) |
static Polynomial | sample_rej_uniform (std::unique_ptr< XOF > xof) |
Definition at line 59 of file kyber_structures.h.
|
inline |
Definition at line 61 of file kyber_structures.h.
|
inlinestatic |
Multiplication of two polynomials in NTT domain
Multiplication of polynomials in Zq[X]/(X^2-zeta) used for multiplication of elements in Rq in NTT domain.
Definition at line 252 of file kyber_structures.h.
References Botan::KyberConstants::zetas.
Referenced by Botan::PolynomialVector::pointwise_acc_montgomery().
|
inlinestatic |
Given an array of uniformly random bytes, compute polynomial with coefficients distributed according to a centered binomial distribution with parameter eta=2
Definition at line 101 of file kyber_structures.h.
References BOTAN_ASSERT, BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::empty(), Botan::load_le(), size(), Botan::StrongSpan< T >::size(), and Botan::BufferSlicer::take().
Referenced by getnoise_eta1(), and getnoise_eta2().
|
inlinestatic |
Given an array of uniformly random bytes, compute polynomial with coefficients distributed according to a centered binomial distribution with parameter eta=3
This function is only needed for Kyber-512
Definition at line 129 of file kyber_structures.h.
References BOTAN_ASSERT, BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::empty(), Botan::load_le(), Botan::make_uint32(), size(), Botan::StrongSpan< T >::size(), and Botan::BufferSlicer::take().
Referenced by getnoise_eta1().
|
inline |
Applies conditional subtraction of q to each coefficient of the polynomial.
Definition at line 66 of file kyber_structures.h.
References Botan::KyberConstants::Q.
Referenced by to_bytes(), and to_message().
|
inlinestatic |
Definition at line 184 of file kyber_structures.h.
References size().
Referenced by Botan::PolynomialVector::from_bytes().
|
inlinestatic |
Definition at line 193 of file kyber_structures.h.
References BOTAN_ASSERT, Botan::CT::Mask< T >::is_zero(), Botan::KyberConstants::N, Botan::KyberConstants::Q, size(), and Botan::StrongSpan< T >::size().
Referenced by Botan::Kyber_PublicKeyInternal::indcpa_encrypt().
|
inlinestatic |
Sample a polynomial deterministically from a seed and a nonce, with output polynomial close to centered binomial distribution with parameter mode.eta1()
Definition at line 173 of file kyber_structures.h.
References BOTAN_ASSERT, cbd2(), cbd3(), Botan::KyberConstants::eta1(), Botan::KyberConstants::N, Botan::Kyber_Symmetric_Primitives::PRF(), and Botan::KyberConstants::symmetric_primitives().
Referenced by Botan::PolynomialVector::getnoise_eta1().
|
inlinestatic |
Sample a polynomial deterministically from a seed and a nonce, with output polynomial close to centered binomial distribution with parameter eta=2.
Definition at line 159 of file kyber_structures.h.
References BOTAN_ASSERT, cbd2(), Botan::KyberConstants::eta2(), Botan::KyberConstants::N, Botan::Kyber_Symmetric_Primitives::PRF(), and Botan::KyberConstants::symmetric_primitives().
Referenced by Botan::PolynomialVector::getnoise_eta2(), and Botan::Kyber_PublicKeyInternal::indcpa_encrypt().
|
inline |
Computes inverse of negacyclic number-theoretic transform (NTT) of a polynomial in place; inputs assumed to be in bitreversed order, output in normal order.
Definition at line 337 of file kyber_structures.h.
References size(), and Botan::KyberConstants::zetas_inv.
|
inline |
Computes negacyclic number-theoretic transform (NTT) of a polynomial in place; inputs assumed to be in normal order, output in bitreversed order.
Definition at line 318 of file kyber_structures.h.
References reduce(), size(), and Botan::KyberConstants::zetas.
Referenced by Botan::Kyber_PrivateKeyInternal::indcpa_decrypt().
|
inline |
Adds two polynomials element-wise. Does not perform a reduction after the addition. Therefore this operation might cause an integer overflow.
Definition at line 227 of file kyber_structures.h.
References BOTAN_DEBUG_ASSERT, and size().
|
inline |
Subtracts two polynomials element-wise. Does not perform a reduction after the subtraction. Therefore this operation might cause an integer underflow.
Definition at line 240 of file kyber_structures.h.
References BOTAN_DEBUG_ASSERT, and size().
|
inline |
Definition at line 358 of file kyber_structures.h.
|
inline |
Definition at line 356 of file kyber_structures.h.
|
inline |
Applies Barrett reduction to all coefficients of the polynomial
Definition at line 76 of file kyber_structures.h.
Referenced by ntt(), and Botan::PolynomialVector::pointwise_acc_montgomery().
|
inlinestatic |
Run rejection sampling on uniform random bytes to generate uniform random integers mod q.
Definition at line 281 of file kyber_structures.h.
References Botan::KyberConstants::Q, and size().
Referenced by Botan::PolynomialMatrix::generate().
|
inline |
Definition at line 354 of file kyber_structures.h.
Referenced by cbd2(), cbd3(), from_bytes(), from_message(), invntt_tomont(), ntt(), operator+=(), operator-=(), sample_rej_uniform(), to_bytes(), and to_message().
|
inline |
Definition at line 82 of file kyber_structures.h.
References BOTAN_ASSERT_NOMSG, csubq(), Botan::BufferStuffer::full(), Botan::BufferStuffer::next(), and size().
|
inline |
Definition at line 206 of file kyber_structures.h.
References csubq(), Botan::detail::ct_int_div_kyber_q(), Botan::KyberConstants::Q, and size().
|
inline |
Inplace conversion of all coefficients of a polynomial from normal domain to Montgomery domain.
Definition at line 307 of file kyber_structures.h.
References Botan::KyberConstants::Q.