M4RIE 20250128
Loading...
Searching...
No Matches
blm.h
Go to the documentation of this file.
1
11#ifndef M4RIE_BLM_H
12#define M4RIE_BLM_H
13
14/******************************************************************************
15*
16* M4RIE: Linear Algebra over GF(2^e)
17*
18* Copyright (C) 2013 Martin Albrecht <martinralbrecht@googlemail.com>
19*
20* Distributed under the terms of the GNU General Public License (GEL)
21* version 2 or higher.
22*
23* This code is distributed in the hope that it will be useful,
24* but WITHOUT ANY WARRANTY; without even the implied warranty of
25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26* General Public License for more details.
27*
28* The full text of the GPL is available at:
29*
30* http://www.gnu.org/licenses/
31******************************************************************************/
32
33#include <m4ri/m4ri.h>
34#include "m4rie/gf2e.h"
35
40#define M4RIE_CRT_LEN (M4RIE_MAX_DEGREE + 1)
41
51typedef struct {
52 mzd_t *H;
53 djb_t *h;
55 mzd_t *F;
56 djb_t *f;
58 mzd_t *G;
59 djb_t *g;
60} blm_t;
61
66extern const int costs[17];
67
72static inline int blm_cost_crt(const int p[M4RIE_CRT_LEN]) {
73 int cost = costs[p[0]];
74 for(deg_t d=1; d<M4RIE_CRT_LEN; d++)
75 cost += costs[d] * p[d];
76 return cost;
77}
78
86int *crt_init(const deg_t f_len, const deg_t g_len);
87
97blm_t *blm_init_crt(const gf2e *ff, const deg_t f_ncols, const deg_t g_ncols, const int *p, int djb);
98
106blm_t *_blm_finish_polymult(const gf2e *ff, blm_t *f);
107
112void blm_free(blm_t *f);
113
121
131void _mzd_ptr_apply_blm_mzd(mzd_t **X, const mzd_t **A, const mzd_t **B, const blm_t *f);
132
142void _mzd_ptr_apply_blm_djb(mzd_t **X, const mzd_t **A, const mzd_t **B, const blm_t *f);
143
153static inline void _mzd_ptr_apply_blm(mzd_t **X, const mzd_t **A, const mzd_t **B, const blm_t *f) {
154 if (f->f!=NULL)
155 _mzd_ptr_apply_blm_djb(X, A, B, f);
156 else
157 _mzd_ptr_apply_blm_mzd(X, A, B, f);
158}
159
160
161#endif //M4RIE_BLM_H
const int costs[17]
Definition blm.c:837
static int blm_cost_crt(const int p[M4RIE_CRT_LEN])
Definition blm.h:72
blm_t * _blm_djb_compile(blm_t *f)
Compile DJB map for f.
Definition blm.c:43
int * crt_init(const deg_t f_len, const deg_t g_len)
Definition blm.c:105
void _mzd_ptr_apply_blm_djb(mzd_t **X, const mzd_t **A, const mzd_t **B, const blm_t *f)
Apply f (stored as a DJB map) on A and B, writing to X.
Definition blm.c:65
blm_t * blm_init_crt(const gf2e *ff, const deg_t f_ncols, const deg_t g_ncols, const int *p, int djb)
Definition blm.c:840
blm_t * _blm_finish_polymult(const gf2e *ff, blm_t *f)
Definition blm.c:734
#define M4RIE_CRT_LEN
We consider at most polynomials of degree M4RIE_MAX_DEGREE in CRT.
Definition blm.h:40
static void _mzd_ptr_apply_blm(mzd_t **X, const mzd_t **A, const mzd_t **B, const blm_t *f)
Apply f on A and B, writing to X.
Definition blm.h:153
void _mzd_ptr_apply_blm_mzd(mzd_t **X, const mzd_t **A, const mzd_t **B, const blm_t *f)
Apply f (stored as a matrix) on A and B, writing to X.
Definition blm.c:6
void blm_free(blm_t *f)
Definition blm.c:964
int deg_t
Definition gf2x.h:37
Bilinear Maps on Matrices over GF(2).
Definition blm.h:51
djb_t * g
Definition blm.h:59
djb_t * h
Definition blm.h:53
mzd_t * H
Definition blm.h:52
mzd_t * G
Definition blm.h:58
djb_t * f
Definition blm.h:56
mzd_t * F
Definition blm.h:55
Definition gf2e.h:62