BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
goppa.c
Go to the documentation of this file.
1 /*
2 This file is part of BitPunch
3 Copyright (C) 2013-2015 Frantisek Uhrecky <frantisek.uhrecky[what here]gmail.com>
4 Copyright (C) 2013-2014 Andrej Gulyas <andrej.guly[what here]gmail.com>
5 Copyright (C) 2013-2014 Marek Klein <kleinmrk[what here]gmail.com>
6 Copyright (C) 2013-2014 Filip Machovec <filipmachovec[what here]yahoo.com>
7 Copyright (C) 2013-2014 Jozef Kudlac <jozef[what here]kudlac.sk>
8 
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #include "goppa.h"
23 
24 #include <stdlib.h>
25 
26 #include <bitpunch/math/gf2.h>
27 #include <bitpunch/math/perm.h>
28 #include <bitpunch/debugio.h>
29 
30 /***********************************************************************************************************/
31 #ifdef BPU_CONF_ENCRYPTION
32 int BPU_goppaEncode(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx) {
33  int rc = 0;
34  int i, j;
35  uint8_t out_bit = 0;
36  BPU_T_GF2 out_dword;
37  BPU_T_GF2_Vector *tmp;
38 
39  BPU_gf2VecNull(out);
40 
41  // test the size of message and g_m
42  if (in->len != ctx->code_spec->goppa->g_mat->n) {
43  BPU_printError("message length have to be of length %d", ctx->code_spec->goppa->g_mat->n);
44 
45  return -1;
46  }
47  BPU_gf2VecMalloc(&tmp, ctx->code_spec->goppa->g_mat->k);
48  for (j = 0; j < ctx->code_spec->goppa->g_mat->k; j++) {
49  out_dword = 0;
50  for (i = 0; i < ctx->code_spec->goppa->g_mat->elements_in_row; i++) {
51  out_dword ^= in->elements[i] & ctx->code_spec->goppa->g_mat->elements[j][i];
52  }
53  out_bit = BPU_getParity(out_dword);
54  BPU_gf2VecSetBit(tmp, j, out_bit);
55  }
56 
57  rc += BPU_gf2VecConcat(out, tmp, in);
58  BPU_gf2VecFree(&tmp);
59 
60  return rc;
61 }
62 #endif // BPU_CONF_ENCRYPTION
63 
64 /***********************************************************************************************************/
65 #ifdef BPU_CONF_DECRYPTION
66 int BPU_goppaDecode(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx) {
67  BPU_T_GF2_Vector *orig_enc;
68  int rc;
69 
70  // get error vector
71  rc = BPU_goppaGetError(ctx->e, in, ctx);
72 
73  // remove error
74  rc += BPU_gf2VecMalloc(&orig_enc, in->len);
75  BPU_gf2VecCopy(orig_enc, in);
76  rc += BPU_gf2VecXor(orig_enc, ctx->e);
77 
78  // get message
79  rc += BPU_gf2VecCrop(out, orig_enc, in->len - ctx->msg_len, ctx->msg_len);
80  BPU_gf2VecFree(&orig_enc);
81 
82  return rc;
83 }
84 
85 int BPU_goppaGetError(BPU_T_GF2_Vector *error, const BPU_T_GF2_Vector *encoded, const BPU_T_Code_Ctx *ctx) {
86  BPU_T_Perm_Vector *inv_perm;
87  BPU_T_GF2_16x_Poly *syndrome, *tau, *a, *b, *sigma, *inv_syndrome, *tmp, *tmp2;
88  int l;
89  BPU_T_GF2_16x tmp_eval;
90  BPU_T_GF2_Vector *enc_permuted;
91 
92  // permute code word
93  BPU_gf2VecMalloc(&enc_permuted, encoded->len);
94  BPU_gf2VecCopy(enc_permuted, encoded);
95 
96  BPU_permMalloc(&inv_perm, ctx->code_spec->goppa->permutation->size);
97  BPU_permGetInv(inv_perm, ctx->code_spec->goppa->permutation);
98  BPU_gf2VecPermute(enc_permuted, inv_perm);
99  BPU_permFree(&inv_perm);
100 
101  // Beginning of patterson
102  BPU_gf2xPolyMalloc(&syndrome, ctx->code_spec->goppa->g->deg - 1);
103  BPU_goppaDetSyndrome(syndrome, enc_permuted, ctx);
104  BPU_gf2VecFree(&enc_permuted);
105 
106  BPU_gf2xPolyMalloc(&inv_syndrome, (syndrome->deg > ctx->code_spec->goppa->g->deg) ? syndrome->deg : ctx->code_spec->goppa->g->deg);
107  BPU_gf2xPolyInv(inv_syndrome, syndrome, ctx->code_spec->goppa->g, ctx->math_ctx);
108  BPU_gf2xPolyFree(&syndrome);
109  inv_syndrome->coef[1] = inv_syndrome->coef[1] ^ 1;
110 
111  // get square root
112  BPU_gf2xPolyMalloc(&tau, ctx->code_spec->goppa->g->deg);
113  BPU_gf2xPolyRoot(tau, inv_syndrome, ctx->code_spec->goppa->g, ctx->math_ctx);
114  BPU_gf2xPolyFree(&inv_syndrome);
115  /**************** FROM NOW WE ARE NOT USING MODULUS g for a, b ********************/
116  BPU_gf2xPolyMalloc(&a, (tau->deg > ctx->code_spec->goppa->g->deg) ? tau->deg : ctx->code_spec->goppa->g->deg);
117  BPU_gf2xPolyMalloc(&b, a->max_deg);
118  BPU_goppaFindPolyAB(a, b, tau, ctx->code_spec->goppa->g, ctx->math_ctx);
119  BPU_gf2xPolyFree(&tau);
120 
121  BPU_gf2xPolyMalloc(&tmp2, 2 * ctx->code_spec->goppa->g->deg);
122  BPU_gf2xPolyMalloc(&tmp, 2 * ctx->code_spec->goppa->g->deg);
123 
124  // a^2, b^2
125  BPU_gf2xPolyMul(tmp, a, a, ctx->math_ctx);
126  BPU_gf2xPolyMul(tmp2, b, b, ctx->math_ctx);
127 
128  // copy a^2, b^2 to a, b
129  BPU_gf2xPolyCopy(a, tmp);
130  BPU_gf2xPolyFree(&tmp);
131 
132  BPU_gf2xPolyCopy(b, tmp2);
133  BPU_gf2xPolyFree(&tmp2);
134 
135  // b^2 * x
136  BPU_gf2xPolyShl(b, 1);
137  BPU_gf2xPolyMalloc(&sigma, ctx->code_spec->goppa->g->deg);
138 
139  // calculate sigma = a^2 + x * b^2
140  BPU_gf2xPolyAdd(sigma, a, b);
141  BPU_gf2xPolyFree(&a);
142  BPU_gf2xPolyFree(&b);
143  // check if there is enough space
144  if (error->len < ctx->code_spec->goppa->support_len) {
146  }
147  else {
148  BPU_gf2VecNull(error);
149  }
150  for (l = 0; l < ctx->code_spec->goppa->support_len; l++) {
151  tmp_eval = BPU_gf2xPolyEval(sigma, ctx->math_ctx->exp_table[l], ctx->math_ctx);
152 
153  if (tmp_eval == 0) {
154  BPU_gf2VecSetBit(error, l, 1);
155  }
156  }
157  // permute error vector
159  BPU_gf2xPolyFree(&sigma);
160  return 0;
161 }
162 
164  int row, column;
165 #ifdef BPU_CONF_GOPPA_WO_H
166  int k, e;
167  BPU_T_GF2_16x element, divider;
168 #endif
169  BPU_gf2xPolyNull(syndrome);
170 #ifdef BPU_CONF_GOPPA_WO_H
171  for(column = 0; column < z->len; column++) {
172  divider = BPU_gf2xPowerModT(BPU_gf2xPolyEval(ctx->code_spec->goppa->g, ctx->math_ctx->exp_table[column], ctx->math_ctx), -1, ctx->math_ctx);
173  if (BPU_gf2VecGetBit(z, column)) {
174  for(row = 0; row < ctx->code_spec->goppa->g->deg; row++) {
175  element = 0;
176  for(k = ctx->code_spec->goppa->g->deg - row, e = 0; k <= ctx->code_spec->goppa->g->deg; k++, e++) {
177  element ^= BPU_gf2xMulMod(ctx->code_spec->goppa->g->coef[k], BPU_gf2xPowerModT (ctx->math_ctx->exp_table[column], e, ctx->math_ctx), ctx->math_ctx->mod);
178  }
179  element = BPU_gf2xMulMod(element, divider, ctx->math_ctx->mod);
180  syndrome->coef[syndrome->max_deg - row] ^= element;
181  }
182  }
183  }
184 #else
185  for (column = 0; column < z->len; column++) {
186  for (row = 0; row < ctx->code_spec->goppa->h_mat->k; row++) {
187  syndrome->coef[syndrome->max_deg - row] ^= BPU_gf2VecGetBit(z, column) * ctx->code_spec->goppa->h_mat->elements[row][column];
188  }
189  }
190 #endif
191  syndrome->deg = BPU_gf2xPolyGetDeg(syndrome);
192 }
193 
195  BPU_T_GF2_16x_Poly *tmp;
196  int end_deg = mod->deg / 2;
197 
198  BPU_gf2xPolyMalloc(&tmp, (tau->deg > mod->deg) ? tau->deg : mod->deg);
199  BPU_gf2xPolyExtEuclid(a, b, tmp, tau, mod, end_deg, math_ctx);
200  BPU_gf2xPolyFree(&tmp);
201 }
202 #endif // BPU_CONF_DECRYPTION
203 
204 /***********************************************************************************************************/
205 #ifdef BPU_CONF_KEY_GEN
207  int bit, bit_in_element = -1, act_element = 0;
208  int element_bit_size = ctx->math_ctx->mod_deg;
209  int k, row, column, e;
210  BPU_T_GF2_16x element, divider;
211 
212  if (h2->k != ctx->code_spec->goppa->g->deg * element_bit_size || h2->n != ctx->code_spec->goppa->support_len) {
213  BPU_printError("Matrix h2 dimension should be %dx%d, current is %dx%d", ctx->code_spec->goppa->g->deg * element_bit_size, ctx->code_spec->goppa->support_len, h2->k, h2->n);
214 
215  return -1;
216  }
217 #ifndef BPU_CONF_GOPPA_WO_H
218  if (hx->k != ctx->code_spec->goppa->g->deg || hx->n != ctx->code_spec->goppa->support_len) {
219  BPU_printError("Matrix hx dimension should be %dx%d, current is %dx%d", ctx->code_spec->goppa->g->deg, ctx->math_ctx->ord, hx->k, hx->n);
220 
221  return -1;
222  }
223 #endif
224  for(column = 0; column < h2->n; column++) {
225  divider = BPU_gf2xPowerModT(BPU_gf2xPolyEval(ctx->code_spec->goppa->g, ctx->math_ctx->exp_table[column], ctx->math_ctx), -1, ctx->math_ctx);
226  if ((column - act_element * h2->element_bit_size) >= h2->element_bit_size) { // next elemenet, first bit
227  act_element++;
228  bit_in_element = 0;
229  }
230  else // same element, next bit
231  bit_in_element++;
232  for(row = 0; row < ctx->code_spec->goppa->g->deg; row++) {
233  element = 0;
234  for(k = ctx->code_spec->goppa->g->deg - row, e = 0; k <= ctx->code_spec->goppa->g->deg; k++, e++) {
235  element ^= BPU_gf2xMulModT(ctx->code_spec->goppa->g->coef[k], BPU_gf2xPowerModT(ctx->math_ctx->exp_table[column], e, ctx->math_ctx), ctx->math_ctx);
236  }
237  element = BPU_gf2xMulModT(element, divider, ctx->math_ctx);
238 #ifndef BPU_CONF_GOPPA_WO_H
239  hx->elements[row][column] = element;
240 #endif
241  for (bit = 0; bit < element_bit_size; bit++) { // bit loop through element of matrix
242  h2->elements[row*element_bit_size + bit][act_element] ^= BPU_getBit(element, bit) << (bit_in_element); // get bit from element and shift it
243  }
244  }
245  }
246  return 0;
247 }
248 
250  int rc = 0;
251  int permute = -1; // needed for equivalent codes
252  BPU_T_Perm_Vector *temp;
253 
254  BPU_gf2xPolyMalloc(&ctx->code_spec->goppa->g, ctx->t);
255  BPU_gf2xPolyGenGoppa(ctx->code_spec->goppa->g, ctx->t, ctx->math_ctx);
256 #ifdef BPU_CONF_GOPPA_WO_H
257  ctx->code_spec->goppa->h_mat = NULL;
258 #else
260 #endif
262  rc = BPU_goppaInitMatH2(ctx->code_spec->goppa->g_mat, ctx->code_spec->goppa->h_mat, ctx);
263  if (rc) {
264  BPU_printError("Can not initialize H matrix.");
265 
266  return rc;
267  }
268  // prepare permutations
273 
274  while (permute != 0) {
275  permute = BPU_gf2MatMakeSystematic(ctx->code_spec->goppa->g_mat);
276  if (permute != 0) {
277  BPU_permRandomize(temp);
279  BPU_gf2MatPermute(ctx->code_spec->goppa->g_mat, temp);
280  }
281  }
282  rc = BPU_gf2MatCrop(ctx->code_spec->goppa->g_mat, (ctx->code_spec->goppa->g_mat->n - ctx->code_spec->goppa->g_mat->k));
283  BPU_permFree(&temp);
284 
285  if (rc != 0) {
286 #ifdef BPU_CONF_PRINT
288 #endif
289  BPU_printError("BPU_genKeyPair: can not crop matrix");
290 
291  return -1;
292  }
293  return rc;
294 }
295 #endif // BPU_CONF_KEY_GEN
BPU_T_GF2_16x BPU_gf2xMulMod(BPU_T_GF2_16x a, BPU_T_GF2_16x b, BPU_T_GF2_16x mod)
Multiplication over Galois field, modulus mod.
Definition: gf2x.c:78
int BPU_gf2VecMalloc(BPU_T_GF2_Vector **v, int len)
Definition: gf2types.c:97
#define BPU_gf2VecNull(v_pointer)
Null GF2 vector.
Definition: gf2types.h:112
#define BPU_getBit(w, n)
Check if is set bit at n-th index.
Definition: gf2.h:173
int BPU_gf2VecXor(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in)
Xor two Vectors GF2 and store result in first vector.
Definition: gf2.c:481
void BPU_gf2xPolyMul(BPU_T_GF2_16x_Poly *out, const BPU_T_GF2_16x_Poly *a, const BPU_T_GF2_16x_Poly *b, const BPU_T_Math_Ctx *math_ctx)
Definition: gf2x.c:235
int BPU_gf2xPolyExtEuclid(BPU_T_GF2_16x_Poly *d, BPU_T_GF2_16x_Poly *s, BPU_T_GF2_16x_Poly *t, const BPU_T_GF2_16x_Poly *a, const BPU_T_GF2_16x_Poly *b, const int end_deg, const BPU_T_Math_Ctx *math_ctx)
Extended Euclidean to find greatest common divisor and Bézout coefficients s, t, where gcd(a...
Definition: gf2x.c:545
BPU_T_GF2_16x * exp_table
there are all elements referenced by i, so at i-th index is g^i element, g - generator ...
Definition: mathctx.h:33
BPU_T_GF2_16x mod
polynomial modulus
Definition: mathctx.h:35
int BPU_goppaInitMatH2(BPU_T_GF2_Matrix *h2, BPU_T_GF2_16x_Matrix *hx, const BPU_T_Code_Ctx *ctx)
BPU_goppaInitMatH2 Initialize control matrix.
Definition: goppa.c:206
BPU_T_Math_Ctx * math_ctx
Math context.
Definition: codectx.h:57
void BPU_permFree(BPU_T_Perm_Vector **p)
Free dynamically or statically alocated permutation vector.
Definition: permtypes.c:27
void BPU_gf2VecFree(BPU_T_GF2_Vector **v)
Free dynamically or statically allocated vector.
Definition: gf2types.c:45
#define BPU_gf2xPolyNull(d_pointer)
Copy Polynomial.
Definition: gf2xtypes.h:64
int BPU_permPermute(BPU_T_Perm_Vector *to_permute, const BPU_T_Perm_Vector *permutation)
Definition: perm.c:79
int BPU_gf2xMatMalloc(BPU_T_GF2_16x_Matrix **m, int rows, int cols)
Allocate memory for matrix.
Definition: gf2xtypes.c:28
BPU_T_GF2_Matrix * g_mat
Generator matrix.
Definition: goppatypes.h:28
int BPU_goppaGetError(BPU_T_GF2_Vector *error, const BPU_T_GF2_Vector *encoded, const BPU_T_Code_Ctx *ctx)
Definition: goppa.c:85
void BPU_printGf2Mat(const BPU_T_GF2_Matrix *m)
Definition: gf2.c:73
BPU_T_GF2_16x ** elements
all element of matrix
Definition: gf2xtypes.h:45
int BPU_gf2xPolyMalloc(BPU_T_GF2_16x_Poly **p, int16_t max_deg)
Definition: gf2xtypes.c:111
uint16_t elements_in_row
number of elements in one row
Definition: gf2types.h:46
uint16_t BPU_T_GF2_16x
Definition: gf2xtypes.h:26
BPU_T_Perm_Vector * permutation
permutation "matrix"
Definition: goppatypes.h:31
uint32_t k
rows
Definition: gf2types.h:47
int BPU_gf2MatPermute(BPU_T_GF2_Matrix *inout, BPU_T_Perm_Vector *permutation)
Definition: gf2.c:526
int BPU_gf2xPolyGetDeg(BPU_T_GF2_16x_Poly *poly)
Get degree of polynomial over GF2x.
Definition: gf2x.c:489
int BPU_permRandomize(BPU_T_Perm_Vector *permutation)
Definition: perm.c:43
BPU_T_GF2_16x_Matrix * h_mat
Control matrix H.
Definition: goppatypes.h:29
int BPU_goppaDecode(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
Definition: goppa.c:66
uint16_t n
cols
Definition: gf2xtypes.h:47
uint16_t msg_len
Code dimenzion.
Definition: codectx.h:62
#define BPU_printError(fmt,...)
print error message with filename, line
Definition: debugio.h:47
uint16_t support_len
number of elements in support
Definition: goppatypes.h:32
void BPU_goppaFindPolyAB(BPU_T_GF2_16x_Poly *a, BPU_T_GF2_16x_Poly *b, const BPU_T_GF2_16x_Poly *tau, const BPU_T_GF2_16x_Poly *mod, const BPU_T_Math_Ctx *math_ctx)
Find polynomials a, b of degree <= (t div 2)
Definition: goppa.c:194
uint32_t BPU_T_GF2
Definition: gf2types.h:26
BPU_T_GF2_16x BPU_gf2xPowerModT(BPU_T_GF2_16x a, int e, const BPU_T_Math_Ctx *math_ctx)
E-th power of a. It uses precomputed log and exp tables.
Definition: gf2x.c:110
#define BPU_gf2xMulModT(a, b, math_ctx)
Multiplication over Galois field, modulus mod.
Definition: gf2x.h:94
uint8_t element_bit_size
element size, is sizeof(BPU_T_GF2) i.e. 64 bits
Definition: gf2types.h:45
BPU_T_GF2 * elements
all element of matrix
Definition: gf2types.h:33
int BPU_gf2VecResize(BPU_T_GF2_Vector *v, int len)
BPU_gf2VecResize Resize vecor.
Definition: gf2types.c:107
BPU_T_Perm_Element size
permutation size
Definition: permtypes.h:33
BPU_T_GF2_Vector * e
Error vector.
Definition: codectx.h:58
#define BPU_gf2VecSetBit(v_pointer, i, bit)
Definition: gf2.h:215
int BPU_gf2MatMakeSystematic(BPU_T_GF2_Matrix *inout)
It brings Matrix GF2 into the systematic form -> with I on the left side.
Definition: gf2.c:376
void BPU_gf2VecCopy(BPU_T_GF2_Vector *dest, const BPU_T_GF2_Vector *src)
Copy VectorGF2.
Definition: gf2.c:454
int BPU_gf2MatCrop(BPU_T_GF2_Matrix *m, uint16_t width)
Crop matrix GF2 from left.
Definition: gf2.c:552
void BPU_gf2xPolyGenGoppa(BPU_T_GF2_16x_Poly *p, int t, const BPU_T_Math_Ctx *math_ctx)
Definition: gf2x.c:934
int16_t max_deg
degree
Definition: gf2xtypes.h:56
int BPU_gf2MatMalloc(BPU_T_GF2_Matrix **m, int rows, int cols)
Definition: gf2types.c:54
int BPU_gf2VecPermute(BPU_T_GF2_Vector *vec, const BPU_T_Perm_Vector *permutation)
Definition: gf2.c:289
void BPU_gf2xPolyRoot(BPU_T_GF2_16x_Poly *out, const BPU_T_GF2_16x_Poly *poly, const BPU_T_GF2_16x_Poly *mod, const BPU_T_Math_Ctx *math_ctx)
BPU_gf2xPolyRoot calculate root of given polynomial over GF2x.
Definition: gf2x.c:450
BPU_T_GF2_16x * coef
Polynomial over GF2m.
Definition: gf2xtypes.h:54
void BPU_gf2xPolyFree(BPU_T_GF2_16x_Poly **p)
Definition: gf2xtypes.c:102
uint32_t n
cols
Definition: gf2types.h:48
int BPU_permGetInv(BPU_T_Perm_Vector *out, const BPU_T_Perm_Vector *in)
Definition: perm.c:64
BPU_T_GF2_16x BPU_gf2xPolyEval(const BPU_T_GF2_16x_Poly *poly, const BPU_T_GF2_16x x, const BPU_T_Math_Ctx *math_ctx)
Evaluate polynomial over GF2^m with x.
Definition: gf2x.c:634
uint16_t k
rows
Definition: gf2xtypes.h:46
void BPU_gf2xPolyShl(BPU_T_GF2_16x_Poly *a, int n)
Shift polynomial left, it is like a mul 1/x^n.
Definition: gf2x.c:274
int16_t deg
degree
Definition: gf2xtypes.h:55
void BPU_gf2xPolyCopy(BPU_T_GF2_16x_Poly *dest, const BPU_T_GF2_16x_Poly *src)
Copy Polynomial.
Definition: gf2x.c:757
int BPU_gf2VecCrop(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const int start, const int length)
Definition: gf2.c:424
uint32_t len
cols
Definition: gf2types.h:36
void BPU_gf2xPolyAdd(BPU_T_GF2_16x_Poly *out, const BPU_T_GF2_16x_Poly *a, const BPU_T_GF2_16x_Poly *b)
Definition: gf2x.c:161
int BPU_goppaEncode(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
BPU_goppaEncode Encode message using goppa code.
Definition: goppa.c:32
int ord
group ord, number of elements
Definition: mathctx.h:37
BPU_T_Goppa_Spec * goppa
Definition: codectx.h:42
uint8_t BPU_getParity(BPU_T_GF2 dword)
BPU_getParity Get parity of word.
Definition: gf2.c:576
uint8_t t
Error code correction capability.
Definition: codectx.h:63
int BPU_permMalloc(BPU_T_Perm_Vector **p, int size)
Allocate permutation vector elements of size size.
Definition: permtypes.c:35
int BPU_goppaGenCode(BPU_T_Code_Ctx *ctx)
BPU_goppaGenCode Generate random code based on params.
Definition: goppa.c:249
#define BPU_gf2VecGetBit(v_pointer, i)
Check if is set bit at i-th position in vector.
Definition: gf2.h:192
int BPU_gf2VecConcat(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *vec1, const BPU_T_GF2_Vector *vec2)
Concats two vectors without allocation ouput.
Definition: gf2.c:399
uint8_t mod_deg
modulo degree, galois finite field GF(2^m)
Definition: mathctx.h:36
void BPU_goppaDetSyndrome(BPU_T_GF2_16x_Poly *syndrome, const BPU_T_GF2_Vector *z, const BPU_T_Code_Ctx *ctx)
BPU_goppaDetSyndrome.
Definition: goppa.c:163
BPU_T_UN_Code_Spec * code_spec
Code specific structure, like generator matrix, control matrix, gen. poly ...
Definition: codectx.h:59
BPU_T_GF2_16x_Poly * g
gen. polynomial
Definition: goppatypes.h:30
BPU_T_GF2 ** elements
all element of matrix
Definition: gf2types.h:44
void BPU_gf2xPolyInv(BPU_T_GF2_16x_Poly *out, const BPU_T_GF2_16x_Poly *a, const BPU_T_GF2_16x_Poly *mod, const BPU_T_Math_Ctx *math_ctx)
Get inverse polynomial over GF2_16x.
Definition: gf2x.c:770