Botan 3.7.1
Crypto and TLS for C&
|
Represents an element of the finite field GF(q) for q = 2^m. More...
#include <cmce_gf.h>
Public Member Functions | |
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 | inv () const |
Invert the element. Constant time. | |
bool | is_zero () const |
Check if the element is zero. | |
size_t | log_q () const |
Get m, the degree of the element's modulus. | |
CmceGfMod | modulus () const |
Get the modulus f(z) of GF(q) as a GF_Mod. | |
Classic_McEliece_GF | operator* (Classic_McEliece_GF other) const |
Multiply the element by other in GF(q). Constant time. | |
Classic_McEliece_GF & | operator*= (Classic_McEliece_GF other) |
Multiply 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. | |
Classic_McEliece_GF & | operator+= (Classic_McEliece_GF other) |
Add other to the element. Constant time. | |
Classic_McEliece_GF | operator/ (Classic_McEliece_GF other) const |
Divide the element by other in GF(q). Constant time. | |
Classic_McEliece_GF & | operator= (const CmceGfElem elem) |
Change the element to elem . | |
bool | operator== (Classic_McEliece_GF other) const |
Check if the element is equal to other . Modulus is ignored. | |
Classic_McEliece_GF | square () const |
Square the element. Constant time. | |
Static Public Member Functions | |
static size_t | log_q_from_mod (CmceGfMod modulus) |
Get m. | |
Represents an element of the finite field GF(q) for q = 2^m.
This class implements the finite field GF(q) for q = 2^m via the irreducible polynomial f(z) of degree m. The elements of GF(q) are represented as polynomials of degree m-1 with coefficients in GF(2). Each element and the modulus is represented by a uint16_t, where the i-th least significant bit corresponds to the coefficient of z^i. For example, the element (z^3 + z^2 + 1) is represented by the uint16_t 0b1101.
|
inline |
Creates an element of GF(q) from a uint16_t.
Each element and the modulus is represented by a uint16_t, where the i-th least significant bit corresponds to the coefficient of z^i.
elem | The element as a uint16_t. Must be less than 2^m. |
modulus | The modulus of GF(q). |
Definition at line 41 of file cmce_gf.h.
References BOTAN_DEBUG_ASSERT.
Referenced by operator*().
|
inline |
Get the GF(q) element as a GF_Elem.
Definition at line 68 of file cmce_gf.h.
Referenced by Botan::GF_Mask::expand(), Botan::GF_Mask::if_set_return(), Botan::GF_Mask::is_equal(), Botan::GF_Mask::is_lte(), Botan::GF_Mask::is_zero(), operator==(), Botan::GF_Mask::select(), and Botan::GF_Mask::select().
Classic_McEliece_GF Botan::Classic_McEliece_GF::inv | ( | ) | const |
Invert the element. Constant time.
Definition at line 62 of file cmce_gf.cpp.
References log_q(), and square().
Referenced by operator/().
|
inline |
|
inline |
Get m, the degree of the element's modulus.
Definition at line 61 of file cmce_gf.h.
Referenced by inv(), and operator*().
|
inlinestatic |
Get m.
For a given irreducible polynomial modulus
f(z) representing the modulus of a finite field GF(q) = GF(2^m), get the degree log_q of f(z) which corresponds to m.
modulus | The modulus of GF(q). |
Definition at line 54 of file cmce_gf.h.
References Botan::floor_log2(), and Botan::detail::Strong_Base< T >::get().
|
inline |
Get the modulus f(z) of GF(q) as a GF_Mod.
Definition at line 75 of file cmce_gf.h.
Referenced by Botan::GF_Mask::if_set_return(), Botan::Classic_McEliece_Polynomial::operator()(), Botan::GF_Mask::select(), and Botan::GF_Mask::select().
Classic_McEliece_GF Botan::Classic_McEliece_GF::operator* | ( | Classic_McEliece_GF | other | ) | const |
Multiply the element by other
in GF(q). Constant time.
Definition at line 47 of file cmce_gf.cpp.
References Botan::b, BOTAN_ASSERT_NOMSG, Classic_McEliece_GF(), Botan::detail::Strong_Base< T >::get(), log_q(), and Botan::CT::value_barrier().
|
inline |
Multiply the element by other
in GF(q). Constant time.
Definition at line 113 of file cmce_gf.h.
References BOTAN_DEBUG_ASSERT.
|
inline |
Add other
to the element. Constant time.
Definition at line 96 of file cmce_gf.h.
References BOTAN_DEBUG_ASSERT.
|
inline |
Add other
to the element. Constant time.
Definition at line 104 of file cmce_gf.h.
References BOTAN_DEBUG_ASSERT.
|
inline |
Divide the element by other
in GF(q). Constant time.
Definition at line 88 of file cmce_gf.h.
References BOTAN_DEBUG_ASSERT, and inv().
|
inline |
Change the element to elem
.
|
inline |
|
inline |