Botan 3.7.1
Crypto and TLS for C&
Botan::Classic_McEliece_Polynomial Class Reference

Representation of a Classic McEliece polynomial. More...

#include <cmce_poly.h>

Inheritance diagram for Botan::Classic_McEliece_Polynomial:
Botan::Classic_McEliece_Minimal_Polynomial

Public Member Functions

void _const_time_poison () const
 
void _const_time_unpoison () const
 
 Classic_McEliece_Polynomial (std::vector< Classic_McEliece_GF > coef)
 Construct a polynomial given its coefficients.
 
const std::vector< Classic_McEliece_GF > & coef () const
 Get the entire coefficients vector of the polynomial.
 
Classic_McEliece_GFcoef_at (size_t i)
 Get the coefficient of the i-th monomial as a reference (from low to high degree).
 
const Classic_McEliece_GFcoef_at (size_t i) const
 Get the coefficient of the i-th monomial (from low to high degree).
 
size_t degree () const
 Get the degree of the polynomial.
 
Classic_McEliece_GF operator() (Classic_McEliece_GF a) const
 Evaluate the polynomial P(x) at a given point a, i.e., compute P(a).
 

Detailed Description

Representation of a Classic McEliece polynomial.

This class represents a polynomial in the ring GF(q)[y]. E.g an example element of degree 2 could be: a = (z^3+1)y^2 + (z)y + (z^4+z^3) The degree of the polynomial is given by the size of the coefficient vector given to the constructor, even if the leading coefficient is zero. Coefficients are stored from lowest to highest monomial degree (coef_at(0) = (z^4+z^3) in the example above).

This class is merely a container. The modulus and the operations with Polynomials (e.g. multiplication) is handled by the Classic_McEliece_Polynomial_Ring class.

Definition at line 32 of file cmce_poly.h.

Constructor & Destructor Documentation

◆ Classic_McEliece_Polynomial()

Botan::Classic_McEliece_Polynomial::Classic_McEliece_Polynomial ( std::vector< Classic_McEliece_GF > coef)
inline

Construct a polynomial given its coefficients.

Parameters
coefThe coefficients of the polynomial. The first element is the coefficient of the lowest monomial.

Definition at line 39 of file cmce_poly.h.

39: m_coef(std::move(coef)) {}
const std::vector< Classic_McEliece_GF > & coef() const
Get the entire coefficients vector of the polynomial.
Definition cmce_poly.h:59

Member Function Documentation

◆ _const_time_poison()

void Botan::Classic_McEliece_Polynomial::_const_time_poison ( ) const
inline

Definition at line 68 of file cmce_poly.h.

68{ CT::poison(m_coef); }
constexpr void poison(const T *p, size_t n)
Definition ct_utils.h:53

◆ _const_time_unpoison()

void Botan::Classic_McEliece_Polynomial::_const_time_unpoison ( ) const
inline

Definition at line 70 of file cmce_poly.h.

70{ CT::unpoison(m_coef); }
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:64

◆ coef()

const std::vector< Classic_McEliece_GF > & Botan::Classic_McEliece_Polynomial::coef ( ) const
inline

Get the entire coefficients vector of the polynomial.

Definition at line 59 of file cmce_poly.h.

59{ return m_coef; }

Referenced by Botan::Classic_McEliece_Minimal_Polynomial::serialize().

◆ coef_at() [1/2]

Classic_McEliece_GF & Botan::Classic_McEliece_Polynomial::coef_at ( size_t i)
inline

Get the coefficient of the i-th monomial as a reference (from low to high degree).

Definition at line 49 of file cmce_poly.h.

49{ return m_coef.at(i); }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key(), Botan::Classic_McEliece_Polynomial_Ring::multiply(), and operator()().

◆ coef_at() [2/2]

const Classic_McEliece_GF & Botan::Classic_McEliece_Polynomial::coef_at ( size_t i) const
inline

Get the coefficient of the i-th monomial (from low to high degree).

Definition at line 54 of file cmce_poly.h.

54{ return m_coef.at(i); }

◆ degree()

size_t Botan::Classic_McEliece_Polynomial::degree ( ) const
inline

Get the degree of the polynomial.

Note that the degree is given by the size of the coefficient vector, even if the leading coefficient is zero.

Definition at line 66 of file cmce_poly.h.

66{ return m_coef.size() + 1; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key().

◆ operator()()

Classic_McEliece_GF Botan::Classic_McEliece_Polynomial::operator() ( Classic_McEliece_GF a) const

Evaluate the polynomial P(x) at a given point a, i.e., compute P(a).

Definition at line 18 of file cmce_poly.cpp.

18 {
19 BOTAN_DEBUG_ASSERT(a.modulus() == coef_at(0).modulus());
20
21 Classic_McEliece_GF r(CmceGfElem(0), a.modulus());
22 for(auto it = m_coef.rbegin(); it != m_coef.rend(); ++it) {
23 r *= a;
24 r += *it;
25 }
26
27 return r;
28}
#define BOTAN_DEBUG_ASSERT(expr)
Definition assert.h:98
Classic_McEliece_GF & coef_at(size_t i)
Get the coefficient of the i-th monomial as a reference (from low to high degree).
Definition cmce_poly.h:49
Strong< uint16_t, struct CmceGfElem_ > CmceGfElem
Represents a GF(q) element.
Definition cmce_types.h:19

References BOTAN_DEBUG_ASSERT, coef_at(), and Botan::Classic_McEliece_GF::modulus().


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