9#ifndef BOTAN_CMCE_GF_H_
10#define BOTAN_CMCE_GF_H_
12#include <botan/assert.h>
13#include <botan/internal/bit_ops.h>
14#include <botan/internal/cmce_types.h>
15#include <botan/internal/ct_utils.h>
16#include <botan/internal/stl_util.h>
61 size_t log_q()
const {
return log_q_from_mod(m_modulus); }
81 m_elem = elem &
CmceGfElem((
size_t(1) << log_q()) - 1);
90 return *
this * other.
inv();
106 m_elem ^= other.m_elem;
115 *
this = *
this * other;
155 template <std::
unsigned_
integral T>
188 uint16_t
select(uint16_t x, uint16_t y)
const {
return m_mask.select(x, y); }
195 bool as_bool()
const {
return m_mask.as_bool(); }
#define BOTAN_DEBUG_ASSERT(expr)
Represents an element of the finite field GF(q) for q = 2^m.
Classic_McEliece_GF inv() const
Invert the element. Constant time.
Classic_McEliece_GF(CmceGfElem elem, CmceGfMod modulus)
Creates an element of GF(q) from a uint16_t.
CmceGfElem elem() const
Get the GF(q) element as a GF_Elem.
Classic_McEliece_GF & operator=(const CmceGfElem elem)
Change the element to elem.
static size_t log_q_from_mod(CmceGfMod modulus)
Get m.
CmceGfMod modulus() const
Get the modulus f(z) of GF(q) as a GF_Mod.
bool is_zero() const
Check if the element is zero.
size_t log_q() const
Get m, the degree of the element's modulus.
Classic_McEliece_GF operator/(Classic_McEliece_GF other) const
Divide the element by other in GF(q). Constant time.
Classic_McEliece_GF operator+(Classic_McEliece_GF other) const
Add other to the element. Constant time.
bool operator==(Classic_McEliece_GF other) const
Check if the element is equal to other. Modulus is ignored.
Classic_McEliece_GF & operator+=(Classic_McEliece_GF other)
Add other to the element. Constant time.
Classic_McEliece_GF square() const
Square the element. Constant time.
Classic_McEliece_GF & operator*=(Classic_McEliece_GF other)
Multiply the element by other in GF(q). Constant time.
Constant time mask wrapper for GF(q) elements.
static GF_Mask expand(T v)
uint16_t select(uint16_t x, uint16_t y) const
static GF_Mask is_lte(Classic_McEliece_GF a, Classic_McEliece_GF b)
static GF_Mask is_equal(Classic_McEliece_GF a, Classic_McEliece_GF b)
static GF_Mask is_zero(Classic_McEliece_GF v)
CT::Mask< uint16_t > & elem_mask()
Classic_McEliece_GF select(const Classic_McEliece_GF x, const Classic_McEliece_GF y) const
static GF_Mask expand(Classic_McEliece_GF v)
GF_Mask(CT::Mask< uint16_t > underlying_mask)
GF_Mask & operator&=(const GF_Mask &o)
Classic_McEliece_GF if_set_return(const Classic_McEliece_GF x) const
Classic_McEliece_GF select(const Classic_McEliece_GF x, CmceGfElem y) const
int(* final)(unsigned char *, CTX *)
BigInt operator*(const BigInt &x, const BigInt &y)
constexpr T floor_log2(T n)