Botan 3.14.1
Crypto and TLS for C&
Botan::CRYSTALS::Polynomial< Trait, D > Class Template Reference

#include <pqcrystals.h>

Public Member Functions

void _const_time_poison () const
void _const_time_unpoison () const
decltype(auto) begin ()
decltype(auto) begin () const
ThisPolynomial clone () const
std::span< T, Trait::N > coefficients ()
std::span< const T, Trait::N > coefficients () const
ThisPolynomial & conditional_add_q ()
constexpr bool ct_validate_value_range (T min, T max) const noexcept
constexpr Domain domain () const noexcept
decltype(auto) end ()
decltype(auto) end () const
constexpr size_t hamming_weight () const noexcept
decltype(auto) operator+= (const ThisPolynomial &other)
decltype(auto) operator-= (const ThisPolynomial &other)
ThisPolynomial & operator= (const ThisPolynomial &other)=delete
ThisPolynomial & operator= (ThisPolynomial &&other) noexcept
T & operator[] (size_t i)
T operator[] (size_t i) const
constexpr bool owns_storage () const
 Polynomial ()
 Polynomial (const ThisPolynomial &other)=delete
 Polynomial (std::span< T, Trait::N > coeffs)
 Polynomial (ThisPolynomial &&other) noexcept
ThisPolynomial & reduce ()
constexpr size_t size () const
 ~Polynomial ()=default

Static Public Member Functions

template<Domain OtherD>
static Polynomial< Trait, D > from_domain_cast (Polynomial< Trait, OtherD > &&p)

Friends

template<Domain To, template< typename, Domain > class StructureT, crystals_trait C, Domain From>
StructureT< C, To > detail::domain_cast (StructureT< C, From > &&)
template<crystals_trait OtherTrait, Domain OtherD>
class Polynomial

Detailed Description

template<crystals_trait Trait, Domain D = Domain::Normal>
class Botan::CRYSTALS::Polynomial< Trait, D >

Represents a polynomial with Trait::N coefficients of type Trait::T. The domain of the polynomial can be either Domain::Normal or Domain::NTT and this information is represented in the C++ type system.

Polynomials may either own their storage of piggy-back on external storage when they are part of a PolynomialVector.

Definition at line 215 of file pqcrystals.h.

Constructor & Destructor Documentation

◆ Polynomial() [1/4]

template<crystals_trait Trait, Domain D = Domain::Normal>
Botan::CRYSTALS::Polynomial< Trait, D >::Polynomial ( )
inline

◆ Polynomial() [2/4]

template<crystals_trait Trait, Domain D = Domain::Normal>
Botan::CRYSTALS::Polynomial< Trait, D >::Polynomial ( std::span< T, Trait::N > coeffs)
inlineexplicit

Definition at line 258 of file pqcrystals.h.

◆ Polynomial() [3/4]

template<crystals_trait Trait, Domain D = Domain::Normal>
Botan::CRYSTALS::Polynomial< Trait, D >::Polynomial ( const ThisPolynomial< Trait, D > & other)
delete

◆ Polynomial() [4/4]

template<crystals_trait Trait, Domain D = Domain::Normal>
Botan::CRYSTALS::Polynomial< Trait, D >::Polynomial ( ThisPolynomial< Trait, D > && other)
inlinenoexcept

Definition at line 262 of file pqcrystals.h.

262 :
263 m_coeffs_storage(std::move(other.m_coeffs_storage)), m_coeffs(other.m_coeffs) {}

◆ ~Polynomial()

template<crystals_trait Trait, Domain D = Domain::Normal>
Botan::CRYSTALS::Polynomial< Trait, D >::~Polynomial ( )
default

Member Function Documentation

◆ _const_time_poison()

template<crystals_trait Trait, Domain D = Domain::Normal>
void Botan::CRYSTALS::Polynomial< Trait, D >::_const_time_poison ( ) const
inline

Definition at line 332 of file pqcrystals.h.

constexpr void poison(const T *p, size_t n)
Definition ct_utils.h:56

◆ _const_time_unpoison()

template<crystals_trait Trait, Domain D = Domain::Normal>
void Botan::CRYSTALS::Polynomial< Trait, D >::_const_time_unpoison ( ) const
inline

Definition at line 334 of file pqcrystals.h.

constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:67

◆ begin() [1/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
decltype(auto) Botan::CRYSTALS::Polynomial< Trait, D >::begin ( )
inline

Definition at line 312 of file pqcrystals.h.

312{ return m_coeffs.begin(); }

◆ begin() [2/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
decltype(auto) Botan::CRYSTALS::Polynomial< Trait, D >::begin ( ) const
inline

Definition at line 314 of file pqcrystals.h.

314{ return m_coeffs.begin(); }

◆ clone()

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomial Botan::CRYSTALS::Polynomial< Trait, D >::clone ( ) const
inline

Definition at line 282 of file pqcrystals.h.

282 {
284 copy_mem(res.m_coeffs_storage, m_coeffs);
285 res.m_coeffs = std::span<T, Trait::N>(res.m_coeffs_storage);
287 return res;
288 }
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:144

◆ coefficients() [1/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
std::span< T, Trait::N > Botan::CRYSTALS::Polynomial< Trait, D >::coefficients ( )
inline

◆ coefficients() [2/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
std::span< const T, Trait::N > Botan::CRYSTALS::Polynomial< Trait, D >::coefficients ( ) const
inline

Definition at line 306 of file pqcrystals.h.

306{ return m_coeffs; }

◆ conditional_add_q()

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomial & Botan::CRYSTALS::Polynomial< Trait, D >::conditional_add_q ( )
inline

Definition at line 327 of file pqcrystals.h.

327 {
329 return *this;
330 }

◆ ct_validate_value_range()

template<crystals_trait Trait, Domain D = Domain::Normal>
bool Botan::CRYSTALS::Polynomial< Trait, D >::ct_validate_value_range ( T min,
T max ) const
inlineconstexprnoexcept
Returns
true if all coefficients are within the range [min, max]

Definition at line 291 of file pqcrystals.h.

291 {
293 }
std::span< T, Trait::N > coefficients()
Definition pqcrystals.h:304

Referenced by Botan::Dilithium_Algos::sample_in_ball().

◆ domain()

template<crystals_trait Trait, Domain D = Domain::Normal>
Domain Botan::CRYSTALS::Polynomial< Trait, D >::domain ( ) const
inlineconstexprnoexcept

Definition at line 280 of file pqcrystals.h.

280{ return D; }

◆ end() [1/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
decltype(auto) Botan::CRYSTALS::Polynomial< Trait, D >::end ( )
inline

Definition at line 316 of file pqcrystals.h.

316{ return m_coeffs.end(); }

◆ end() [2/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
decltype(auto) Botan::CRYSTALS::Polynomial< Trait, D >::end ( ) const
inline

Definition at line 318 of file pqcrystals.h.

318{ return m_coeffs.end(); }

◆ from_domain_cast()

template<crystals_trait Trait, Domain D = Domain::Normal>
template<Domain OtherD>
Polynomial< Trait, D > Botan::CRYSTALS::Polynomial< Trait, D >::from_domain_cast ( Polynomial< Trait, OtherD > && p)
inlinestatic

Definition at line 251 of file pqcrystals.h.

251 {
253 }

◆ hamming_weight()

template<crystals_trait Trait, Domain D = Domain::Normal>
size_t Botan::CRYSTALS::Polynomial< Trait, D >::hamming_weight ( ) const
inlineconstexprnoexcept
Returns
the number of non-zero coefficients in the polynomial

Definition at line 296 of file pqcrystals.h.

296 {
297 size_t weight = 0;
298 for(const auto c : m_coeffs) {
299 weight += (c != 0);
300 }
301 return weight;
302 }

Referenced by Botan::Dilithium_Algos::sample_in_ball().

◆ operator+=()

template<crystals_trait Trait, Domain D = Domain::Normal>
decltype(auto) Botan::CRYSTALS::Polynomial< Trait, D >::operator+= ( const ThisPolynomial< Trait, D > & other)
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 340 of file pqcrystals.h.

340 {
342 return *this;
343 }

◆ operator-=()

template<crystals_trait Trait, Domain D = Domain::Normal>
decltype(auto) Botan::CRYSTALS::Polynomial< Trait, D >::operator-= ( const ThisPolynomial< Trait, D > & other)
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 349 of file pqcrystals.h.

349 {
351 return *this;
352 }

◆ operator=() [1/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomial & Botan::CRYSTALS::Polynomial< Trait, D >::operator= ( const ThisPolynomial< Trait, D > & other)
delete

◆ operator=() [2/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomial & Botan::CRYSTALS::Polynomial< Trait, D >::operator= ( ThisPolynomial< Trait, D > && other)
inlinenoexcept

Definition at line 267 of file pqcrystals.h.

267 {
268 if(this != &other) {
270 m_coeffs_storage = std::move(other.m_coeffs_storage);
272 }
273 return *this;
274 }
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82

◆ operator[]() [1/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
T & Botan::CRYSTALS::Polynomial< Trait, D >::operator[] ( size_t i)
inline

Definition at line 308 of file pqcrystals.h.

308{ return m_coeffs[i]; }

◆ operator[]() [2/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
T Botan::CRYSTALS::Polynomial< Trait, D >::operator[] ( size_t i) const
inline

Definition at line 310 of file pqcrystals.h.

310{ return m_coeffs[i]; }

◆ owns_storage()

◆ reduce()

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomial & Botan::CRYSTALS::Polynomial< Trait, D >::reduce ( )
inline

Definition at line 322 of file pqcrystals.h.

322 {
324 return *this;
325 }

Referenced by Botan::CRYSTALS::detail::dot_product().

◆ size()

template<crystals_trait Trait, Domain D = Domain::Normal>
size_t Botan::CRYSTALS::Polynomial< Trait, D >::size ( ) const
inlineconstexpr

◆ detail::domain_cast

template<crystals_trait Trait, Domain D = Domain::Normal>
template<Domain To, template< typename, Domain > class StructureT, crystals_trait C, Domain From>
StructureT< C, To > detail::domain_cast ( StructureT< C, From > && )
friend

◆ Polynomial

template<crystals_trait Trait, Domain D = Domain::Normal>
template<crystals_trait OtherTrait, Domain OtherD>
friend class Polynomial
friend

Definition at line 227 of file pqcrystals.h.


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