Botan 3.0.0-alpha0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::GF2m_Field Class Reference

#include <gf2m_small_m.h>

Public Member Functions

gf2m get_cardinality () const
 
size_t get_extension_degree () const
 
 GF2m_Field (size_t extdeg)
 
gf2m gf_div (gf2m x, gf2m y) const
 
gf2m gf_div_nrr (gf2m a, gf2m b) const
 
gf2m gf_div_rnn (gf2m x, gf2m y) const
 
gf2m gf_div_rnr (gf2m x, gf2m b) const
 
gf2m gf_div_zzr (gf2m x, gf2m b) const
 
gf2m gf_exp (gf2m i) const
 
gf2m gf_inv (gf2m x) const
 
gf2m gf_inv_rn (gf2m x) const
 
gf2m gf_l_from_n (gf2m x) const
 
gf2m gf_log (gf2m i) const
 
gf2m gf_mul (gf2m x, gf2m y) const
 
gf2m gf_mul_fast (gf2m x, gf2m y) const
 
gf2m gf_mul_lll (gf2m a, gf2m b) const
 
gf2m gf_mul_lnn (gf2m x, gf2m y) const
 
gf2m gf_mul_nnr (gf2m y, gf2m a) const
 
gf2m gf_mul_nrn (gf2m a, gf2m y) const
 
gf2m gf_mul_nrr (gf2m a, gf2m b) const
 
gf2m gf_mul_rnn (gf2m x, gf2m y) const
 
gf2m gf_mul_rnr (gf2m y, gf2m a) const
 
gf2m gf_mul_rrn (gf2m a, gf2m y) const
 
gf2m gf_mul_rrr (gf2m a, gf2m b) const
 
gf2m gf_mul_zrz (gf2m a, gf2m y) const
 
gf2m gf_mul_zzr (gf2m a, gf2m y) const
 
gf2m gf_ord () const
 
gf2m gf_sqrt (gf2m x) const
 
gf2m gf_square (gf2m x) const
 
gf2m gf_square_ln (gf2m x) const
 
gf2m gf_square_rr (gf2m a) const
 
gf2m square_rr (gf2m x) const
 

Detailed Description

GF(2^m) field for m = [2...16]

Definition at line 25 of file gf2m_small_m.h.

Constructor & Destructor Documentation

◆ GF2m_Field()

Botan::GF2m_Field::GF2m_Field ( size_t  extdeg)
explicit

Definition at line 111 of file gf2m_small_m.cpp.

111 : m_gf_extension_degree(extdeg),
112 m_gf_multiplicative_order((1 << extdeg) - 1),
113 m_gf_log_table(log_table(m_gf_extension_degree)),
114 m_gf_exp_table(exp_table(m_gf_extension_degree))
115 {
116 }

Member Function Documentation

◆ get_cardinality()

gf2m Botan::GF2m_Field::get_cardinality ( ) const
inline

Definition at line 191 of file gf2m_small_m.h.

192 {
193 return static_cast<gf2m>(1 << get_extension_degree());
194 }
size_t get_extension_degree() const
Definition: gf2m_small_m.h:186
uint16_t gf2m
Definition: gf2m_small_m.h:20

◆ get_extension_degree()

size_t Botan::GF2m_Field::get_extension_degree ( ) const
inline

Definition at line 186 of file gf2m_small_m.h.

187 {
188 return m_gf_extension_degree;
189 }

◆ gf_div()

gf2m Botan::GF2m_Field::gf_div ( gf2m  x,
gf2m  y 
) const

Definition at line 118 of file gf2m_small_m.cpp.

119 {
120 const int32_t sub_res = static_cast<int32_t>(gf_log(x) - static_cast<int32_t>(gf_log(y)));
121 const gf2m modq_res = _gf_modq_1(sub_res);
122 const int32_t div_res = static_cast<int32_t>(x) ? static_cast<int32_t>(gf_exp(modq_res)) : 0;
123 return static_cast<gf2m>(div_res);
124 }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:171
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:176

References gf_exp(), and gf_log().

◆ gf_div_nrr()

gf2m Botan::GF2m_Field::gf_div_nrr ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 134 of file gf2m_small_m.h.

135 {
136 return gf_exp(_gf_modq_1(a - b));
137 }
PolynomialVector b
Definition: kyber.cpp:821

References b.

◆ gf_div_rnn()

gf2m Botan::GF2m_Field::gf_div_rnn ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 124 of file gf2m_small_m.h.

125 {
126 return _gf_modq_1(gf_log(x) - gf_log(y));
127 }

◆ gf_div_rnr()

gf2m Botan::GF2m_Field::gf_div_rnr ( gf2m  x,
gf2m  b 
) const
inline

Definition at line 129 of file gf2m_small_m.h.

130 {
131 return _gf_modq_1(gf_log(x) - b);
132 }

References b.

◆ gf_div_zzr()

gf2m Botan::GF2m_Field::gf_div_zzr ( gf2m  x,
gf2m  b 
) const
inline

Definition at line 139 of file gf2m_small_m.h.

140 {
141 return ((x) ? gf_exp(_gf_modq_1(gf_log(x) - b)) : 0);
142 }

References b.

◆ gf_exp()

gf2m Botan::GF2m_Field::gf_exp ( gf2m  i) const
inline

Definition at line 171 of file gf2m_small_m.h.

172 {
173 return m_gf_exp_table.at(i); /* alpha^i */
174 }

Referenced by gf_div().

◆ gf_inv()

gf2m Botan::GF2m_Field::gf_inv ( gf2m  x) const
inline

Definition at line 144 of file gf2m_small_m.h.

145 {
146 return gf_exp(gf_ord() - gf_log(x));
147 }
gf2m gf_ord() const
Definition: gf2m_small_m.h:181

◆ gf_inv_rn()

gf2m Botan::GF2m_Field::gf_inv_rn ( gf2m  x) const
inline

Definition at line 149 of file gf2m_small_m.h.

150 {
151 return (gf_ord() - gf_log(x));
152 }

◆ gf_l_from_n()

gf2m Botan::GF2m_Field::gf_l_from_n ( gf2m  x) const
inline

Definition at line 164 of file gf2m_small_m.h.

165 {
166 return gf_log(x);
167 }

◆ gf_log()

gf2m Botan::GF2m_Field::gf_log ( gf2m  i) const
inline

Definition at line 176 of file gf2m_small_m.h.

177 {
178 return m_gf_log_table.at(i); /* return i when x=alpha^i */
179 }

Referenced by gf_div().

◆ gf_mul()

gf2m Botan::GF2m_Field::gf_mul ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 30 of file gf2m_small_m.h.

31 {
32 return ((x) ? gf_mul_fast(x, y) : 0);
33 }
gf2m gf_mul_fast(gf2m x, gf2m y) const
Definition: gf2m_small_m.h:45

◆ gf_mul_fast()

gf2m Botan::GF2m_Field::gf_mul_fast ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 45 of file gf2m_small_m.h.

46 {
47 return ((y) ? gf_exp(_gf_modq_1(gf_log(x) + gf_log(y))) : 0);
48 }

◆ gf_mul_lll()

gf2m Botan::GF2m_Field::gf_mul_lll ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 58 of file gf2m_small_m.h.

59 {
60 return (a + b);
61 }

References b.

◆ gf_mul_lnn()

gf2m Botan::GF2m_Field::gf_mul_lnn ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 83 of file gf2m_small_m.h.

84 {
85 return (gf_log(x) + gf_log(y));
86 }

◆ gf_mul_nnr()

gf2m Botan::GF2m_Field::gf_mul_nnr ( gf2m  y,
gf2m  a 
) const
inline

non-zero operand

Definition at line 114 of file gf2m_small_m.h.

115 {
116 return gf_mul_nrn(a, y);
117 }
gf2m gf_mul_nrn(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:93

◆ gf_mul_nrn()

gf2m Botan::GF2m_Field::gf_mul_nrn ( gf2m  a,
gf2m  y 
) const
inline

Definition at line 93 of file gf2m_small_m.h.

94 {
95 return gf_exp(_gf_modq_1((a) + gf_log(y)));
96 }

◆ gf_mul_nrr()

gf2m Botan::GF2m_Field::gf_mul_nrr ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 68 of file gf2m_small_m.h.

69 {
70 return (gf_exp(gf_mul_rrr(a, b)));
71 }
gf2m gf_mul_rrr(gf2m a, gf2m b) const
Definition: gf2m_small_m.h:63

References b.

◆ gf_mul_rnn()

gf2m Botan::GF2m_Field::gf_mul_rnn ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 88 of file gf2m_small_m.h.

89 {
90 return _gf_modq_1(gf_mul_lnn(x, y));
91 }
gf2m gf_mul_lnn(gf2m x, gf2m y) const
Definition: gf2m_small_m.h:83

◆ gf_mul_rnr()

gf2m Botan::GF2m_Field::gf_mul_rnr ( gf2m  y,
gf2m  a 
) const
inline

Definition at line 78 of file gf2m_small_m.h.

79 {
80 return gf_mul_rrn(a, y);
81 }
gf2m gf_mul_rrn(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:73

◆ gf_mul_rrn()

gf2m Botan::GF2m_Field::gf_mul_rrn ( gf2m  a,
gf2m  y 
) const
inline

Definition at line 73 of file gf2m_small_m.h.

74 {
75 return _gf_modq_1(gf_mul_lll(a, gf_log(y)));
76 }
gf2m gf_mul_lll(gf2m a, gf2m b) const
Definition: gf2m_small_m.h:58

◆ gf_mul_rrr()

gf2m Botan::GF2m_Field::gf_mul_rrr ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 63 of file gf2m_small_m.h.

64 {
65 return (_gf_modq_1(gf_mul_lll(a, b)));
66 }

References b.

◆ gf_mul_zrz()

gf2m Botan::GF2m_Field::gf_mul_zrz ( gf2m  a,
gf2m  y 
) const
inline

zero operand allowed

Definition at line 101 of file gf2m_small_m.h.

102 {
103 return ( (y == 0) ? 0 : gf_mul_nrn(a, y) );
104 }

◆ gf_mul_zzr()

gf2m Botan::GF2m_Field::gf_mul_zzr ( gf2m  a,
gf2m  y 
) const
inline

Definition at line 106 of file gf2m_small_m.h.

107 {
108 return gf_mul_zrz(y, a);
109 }
gf2m gf_mul_zrz(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:101

◆ gf_ord()

gf2m Botan::GF2m_Field::gf_ord ( ) const
inline

Definition at line 181 of file gf2m_small_m.h.

182 {
183 return m_gf_multiplicative_order;
184 }

◆ gf_sqrt()

gf2m Botan::GF2m_Field::gf_sqrt ( gf2m  x) const
inline

Definition at line 119 of file gf2m_small_m.h.

120 {
121 return ((x) ? gf_exp(_gf_modq_1(gf_log(x) << (get_extension_degree()-1))) : 0);
122 }

◆ gf_square()

gf2m Botan::GF2m_Field::gf_square ( gf2m  x) const
inline

Definition at line 35 of file gf2m_small_m.h.

36 {
37 return ((x) ? gf_exp(_gf_modq_1(gf_log(x) << 1)) : 0);
38 }

◆ gf_square_ln()

gf2m Botan::GF2m_Field::gf_square_ln ( gf2m  x) const
inline

Definition at line 154 of file gf2m_small_m.h.

155 {
156 return gf_log(x) << 1;
157 }

◆ gf_square_rr()

gf2m Botan::GF2m_Field::gf_square_rr ( gf2m  a) const
inline

Definition at line 159 of file gf2m_small_m.h.

160 {
161 return a << 1;
162 }

◆ square_rr()

gf2m Botan::GF2m_Field::square_rr ( gf2m  x) const
inline

Definition at line 40 of file gf2m_small_m.h.

41 {
42 return _gf_modq_1(x << 1);
43 }

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