Botan 3.6.1
Crypto and TLS for C&
Botan::CRYSTALS::PolynomialVector< 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
 
ThisPolynomialVector clone () const
 
std::span< T > coefficients ()
 
std::span< const T > coefficients () const
 
ThisPolynomialVectorconditional_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
 
size_t hamming_weight () const noexcept
 
ThisPolynomialVectoroperator+= (const ThisPolynomialVector &other)
 
ThisPolynomialVectoroperator-= (const ThisPolynomialVector &other)
 
ThisPolynomialVectoroperator= (const ThisPolynomialVector &other)=delete
 
ThisPolynomialVectoroperator= (ThisPolynomialVector &&other) noexcept=default
 
Polynomial< Trait, D > & operator[] (size_t i)
 
const Polynomial< Trait, D > & operator[] (size_t i) const
 
 PolynomialVector (const ThisPolynomialVector &other)=delete
 
 PolynomialVector (size_t vecsize)
 
 PolynomialVector (ThisPolynomialVector &&other) noexcept=default
 
ThisPolynomialVectorreduce ()
 
size_t size () const
 
 ~PolynomialVector ()=default
 

Static Public Member Functions

template<Domain OtherD>
requires (D != OtherD)
static PolynomialVector< Trait, D > from_domain_cast (PolynomialVector< Trait, OtherD > &&other)
 

Friends

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

Detailed Description

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

Definition at line 352 of file pqcrystals.h.

Constructor & Destructor Documentation

◆ PolynomialVector() [1/3]

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

Definition at line 398 of file pqcrystals.h.

398 : m_polys_storage(vecsize * Trait::N) {
399 for(size_t i = 0; i < vecsize; ++i) {
400 m_vec.emplace_back(
401 Polynomial<Trait, D>(std::span{m_polys_storage}.subspan(i * Trait::N).template first<Trait::N>()));
402 }
403 }

◆ PolynomialVector() [2/3]

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

◆ PolynomialVector() [3/3]

template<crystals_trait Trait, Domain D = Domain::Normal>
Botan::CRYSTALS::PolynomialVector< Trait, D >::PolynomialVector ( ThisPolynomialVector< Trait, D > && other)
defaultnoexcept

◆ ~PolynomialVector()

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

Member Function Documentation

◆ _const_time_poison()

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

Definition at line 486 of file pqcrystals.h.

486{ CT::poison_range(m_vec); }
constexpr void poison_range(R &&r)
Definition ct_utils.h:175

References Botan::CT::poison_range().

◆ _const_time_unpoison()

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

Definition at line 488 of file pqcrystals.h.

488{ CT::unpoison_range(m_vec); }
constexpr void unpoison_range(R &&r)
Definition ct_utils.h:183

References Botan::CT::unpoison_range().

◆ begin() [1/2]

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

Definition at line 478 of file pqcrystals.h.

478{ return m_vec.begin(); }

◆ begin() [2/2]

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

Definition at line 480 of file pqcrystals.h.

480{ return m_vec.begin(); }

◆ clone()

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

Definition at line 415 of file pqcrystals.h.

415 {
416 ThisPolynomialVector res(size());
417
418 // The default-constructed PolynomialVector has set up res.m_vec to
419 // point to res.m_polys_storage. Therefore we can just copy the data
420 // into res.m_polys_storage to fill the non-owning polynomials.
421 copy_mem(res.m_polys_storage, m_polys_storage);
422
423 return res;
424 }
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:146

References Botan::copy_mem(), and Botan::CRYSTALS::PolynomialVector< Trait, D >::size().

◆ coefficients() [1/2]

◆ coefficients() [2/2]

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

Definition at line 442 of file pqcrystals.h.

442{ return m_polys_storage; }

◆ conditional_add_q()

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

Definition at line 467 of file pqcrystals.h.

467 {
468 for(auto& v : m_vec) {
469 Trait::poly_cadd_q(v.coefficients());
470 }
471 return *this;
472 }

◆ ct_validate_value_range()

template<crystals_trait Trait, Domain D = Domain::Normal>
bool Botan::CRYSTALS::PolynomialVector< 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 436 of file pqcrystals.h.

436 {
437 return detail::ct_all_within_range(coefficients(), min, max);
438 }

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

Referenced by Botan::Dilithium_Algos::make_hint(), and Botan::Dilithium_Algos::use_hint().

◆ domain()

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

Definition at line 413 of file pqcrystals.h.

413{ return D; }

◆ end() [1/2]

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

Definition at line 482 of file pqcrystals.h.

482{ return m_vec.end(); }

◆ end() [2/2]

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

Definition at line 484 of file pqcrystals.h.

484{ return m_vec.end(); }

◆ from_domain_cast()

template<crystals_trait Trait, Domain D = Domain::Normal>
template<Domain OtherD>
requires (D != OtherD)
static PolynomialVector< Trait, D > Botan::CRYSTALS::PolynomialVector< Trait, D >::from_domain_cast ( PolynomialVector< Trait, OtherD > && other)
inlinestatic

Definition at line 393 of file pqcrystals.h.

393 {
394 return PolynomialVector<Trait, D>(std::move(other));
395 }

References Botan::CRYSTALS::PolynomialVector< Trait, D >::PolynomialVector.

◆ hamming_weight()

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

Definition at line 427 of file pqcrystals.h.

427 {
428 size_t weight = 0;
429 for(const auto c : m_polys_storage) {
430 weight += (c != 0);
431 }
432 return weight;
433 }

◆ operator+=()

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomialVector & Botan::CRYSTALS::PolynomialVector< Trait, D >::operator+= ( const ThisPolynomialVector< Trait, D > & other)
inline

Definition at line 444 of file pqcrystals.h.

444 {
445 BOTAN_ASSERT(m_vec.size() == other.m_vec.size(), "cannot add polynomial vectors of differing lengths");
446 for(size_t i = 0; i < m_vec.size(); ++i) {
447 Trait::poly_add(m_vec[i].coefficients(), m_vec[i].coefficients(), other.m_vec[i].coefficients());
448 }
449 return *this;
450 }
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:50

References BOTAN_ASSERT, and Botan::CRYSTALS::PolynomialVector< Trait, D >::coefficients().

◆ operator-=()

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomialVector & Botan::CRYSTALS::PolynomialVector< Trait, D >::operator-= ( const ThisPolynomialVector< Trait, D > & other)
inline

Definition at line 452 of file pqcrystals.h.

452 {
453 BOTAN_ASSERT(m_vec.size() == other.m_vec.size(), "cannot subtract polynomial vectors of differing lengths");
454 for(size_t i = 0; i < m_vec.size(); ++i) {
455 Trait::poly_sub(m_vec[i].coefficients(), m_vec[i].coefficients(), other.m_vec[i].coefficients());
456 }
457 return *this;
458 }

References BOTAN_ASSERT, and Botan::CRYSTALS::PolynomialVector< Trait, D >::coefficients().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

template<crystals_trait Trait, Domain D = Domain::Normal>
ThisPolynomialVector & Botan::CRYSTALS::PolynomialVector< Trait, D >::operator= ( ThisPolynomialVector< Trait, D > && other)
defaultnoexcept

◆ operator[]() [1/2]

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

Definition at line 474 of file pqcrystals.h.

474{ return m_vec[i]; }

◆ operator[]() [2/2]

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

Definition at line 476 of file pqcrystals.h.

476{ return m_vec[i]; }

◆ reduce()

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

Definition at line 460 of file pqcrystals.h.

460 {
461 for(auto& p : m_vec) {
462 Trait::barrett_reduce(p.coefficients());
463 }
464 return *this;
465 }

◆ size()

Friends And Related Symbol Documentation

◆ detail::domain_cast

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

◆ PolynomialVector

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

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