BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gf2types.h File Reference
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  _BPU_T_GF2_Vector
 
struct  _BPU_T_GF2_Matrix
 
struct  _BPU_T_GF2_Sparse_Poly
 
struct  _BPU_T_GF2_QC_Matrix
 
struct  _BPU_T_GF2_Sparse_Qc_Matrix
 

Macros

#define BPU_gf2MatNullRow(m_pointer, row)   memset((void *) ((m_pointer)->elements[row]), 0, (m_pointer)->element_bit_size / 8 * (m_pointer)->elements_in_row)
 Null GF2 matrix row. More...
 
#define BPU_gf2VecNull(v_pointer)   memset((void *) ((v_pointer)->elements), 0, (v_pointer)->element_bit_size / 8 * (v_pointer)->elements_in_row)
 Null GF2 vector. More...
 

Typedefs

typedef uint32_t BPU_T_GF2
 
typedef struct _BPU_T_GF2_Vector BPU_T_GF2_Vector
 
typedef struct _BPU_T_GF2_Matrix BPU_T_GF2_Matrix
 
typedef BPU_T_GF2_Vector BPU_T_GF2_Poly
 
typedef struct
_BPU_T_GF2_Sparse_Poly 
BPU_T_GF2_Sparse_Poly
 
typedef struct _BPU_T_GF2_QC_Matrix BPU_T_GF2_QC_Matrix
 
typedef struct
_BPU_T_GF2_Sparse_Qc_Matrix 
BPU_T_GF2_Sparse_Qc_Matrix
 

Functions

void BPU_gf2MatFree (BPU_T_GF2_Matrix **m)
 Free dynamically or statically allocated matrix. More...
 
void BPU_gf2VecFree (BPU_T_GF2_Vector **v)
 Free dynamically or statically allocated vector. More...
 
int BPU_gf2MatMalloc (BPU_T_GF2_Matrix **m, int rows, int cols)
 
int BPU_gf2VecMalloc (BPU_T_GF2_Vector **v, int len)
 
int BPU_gf2VecResize (BPU_T_GF2_Vector *v, int len)
 BPU_gf2VecResize Resize vecor. More...
 
int BPU_gf2VecMallocElements (BPU_T_GF2_Vector *v, int len)
 BPU_gf2VecMallocElements Malloc vector elements and set to zero. More...
 
int BPU_gf2PolyMalloc (BPU_T_GF2_Poly *p, int len)
 
void BPU_gf2PolyFree (BPU_T_GF2_Poly *p, int is_dyn)
 
void BPU_gf2SparsePolyMalloc (BPU_T_GF2_Sparse_Poly *p, int weight)
 
void BPU_gf2SparsePolyFree (BPU_T_GF2_Sparse_Poly *p, int is_dyn)
 
int BPU_gf2QcMatrixMalloc (BPU_T_GF2_QC_Matrix *v, int element_count, int element_size, int isVertical, int is_I_appended)
 
void BPU_gf2QcMatrixFree (BPU_T_GF2_QC_Matrix *v, int is_dyn)
 
void BPU_gf2SparseQcMatrixMalloc (BPU_T_GF2_Sparse_Qc_Matrix *v, int element_count, int element_size, int isVertical)
 
void BPU_gf2SparseQcMatrixFree (BPU_T_GF2_Sparse_Qc_Matrix *v, int is_dyn)
 

Macro Definition Documentation

#define BPU_gf2MatNullRow (   m_pointer,
  row 
)    memset((void *) ((m_pointer)->elements[row]), 0, (m_pointer)->element_bit_size / 8 * (m_pointer)->elements_in_row)

Null GF2 matrix row.

Null GF2 matrix row.

Parameters
[out]m_pointerpointer to GF2 matrix
[in]rowrow to null

Definition at line 105 of file gf2types.h.

#define BPU_gf2VecNull (   v_pointer)    memset((void *) ((v_pointer)->elements), 0, (v_pointer)->element_bit_size / 8 * (v_pointer)->elements_in_row)

Null GF2 vector.

Null GF2 vector.

Parameters
[out]v_pointerpointer to GF2 vector

Definition at line 112 of file gf2types.h.

Typedef Documentation

typedef uint32_t BPU_T_GF2

Binary representation GF2

Definition at line 26 of file gf2types.h.

Matrix representation over GF2. Every element is one bit.

Polynomial over GF2, represented as Vector. Indexes are stored in elements, degree of polynomial is len - 1

Definition at line 55 of file gf2types.h.

Quasi-cyclic matrix over GF2. Cyclic matrices are stored as polynomials. Matrix can have multiple cyclic matrices (but just one in row and more in columns, or in reverse) The orientation of is set in isVertical. For appended identity matrix in left set is_I_appended to 1.

Sparse polynomial over GF2. More effective than BPU_T_GF2_Poly for low weight polynomials. Every set coefficient is stored in array of indexes.

Quasi-cyclic matrix over GF2 with sparse cyclic matrices. More effective than BPU_T_QC_Matrix_GF2 for low weight cyclic matrices. Matrix can have multiple cyclic matrices (but just one in row and more in columns, or in reverse) The orientation of is set in isVertical.

Row vector GF2 representation. Every element is one bit.

Function Documentation

void BPU_gf2MatFree ( BPU_T_GF2_Matrix **  m)

Free dynamically or statically allocated matrix.

Free dynamically or statically allocated matrix GF2.

Parameters
[out]*maddress of matrix object

Definition at line 29 of file gf2types.c.

int BPU_gf2MatMalloc ( BPU_T_GF2_Matrix **  m,
int  rows,
int  cols 
)

Allocate memory for matrix GF2. It also nulls new matrix. After work you have to free memory using call BPU_freeMatGF2

Parameters
rowsrows
colscols
Returns
on succes 0, else error

Definition at line 54 of file gf2types.c.

void BPU_gf2PolyFree ( BPU_T_GF2_Poly p,
int  is_dyn 
)

Free dynamically or statically allocated polynomial over GF2.

Parameters
ppolynomial to free
is_dynboolean param, if 0 do not free object self, else free also object

Definition at line 187 of file gf2types.c.

int BPU_gf2PolyMalloc ( BPU_T_GF2_Poly p,
int  len 
)

Allocate memory for polynomial over GF2. Allocate memory, so after work it has to be freed by using call BPU_gf2PolyFree.

Parameters
ppolynomial to allocate
lenlength of polynomial (length - 1 = degree of polynomial)
Returns
on succes 0, else error

Definition at line 195 of file gf2types.c.

void BPU_gf2QcMatrixFree ( BPU_T_GF2_QC_Matrix v,
int  is_dyn 
)

Free dynamically or statically allocated quasi-cyclic matrix over GF2.

Parameters
vquasi-cyclic matrix
is_dynboolean param, if 0 do not free object self, else free also object

Definition at line 251 of file gf2types.c.

int BPU_gf2QcMatrixMalloc ( BPU_T_GF2_QC_Matrix v,
int  element_count,
int  element_size,
int  isVertical,
int  is_I_appended 
)

Allocate memory for quasi-cyclic matrix over GF2. Allocate memory, so after work it has to be freed by using call BPU_gf2QcMatrixFree.

Parameters
vquasi-cyclic matrix
element_countcount of cyclic elements
element_sizesize of one cyclic element
isVerticalboolean, if 1, elements are in vertical orientation, if 0 horizontal orientation
is_I_appendedboolean, if 1, identity matrix is appended to the left, if 0, no identity matrix
Returns
0 - succes, else error

Definition at line 220 of file gf2types.c.

void BPU_gf2SparsePolyFree ( BPU_T_GF2_Sparse_Poly p,
int  is_dyn 
)

Free dynamically or statically allocated sparse polynomial over GF2.

Parameters
psparse polynomial to free
is_dynboolean param, if 0 do not free object self, else free also object

Definition at line 147 of file gf2types.c.

void BPU_gf2SparsePolyMalloc ( BPU_T_GF2_Sparse_Poly p,
int  weight 
)

Allocate memory for sparse polynomial over GF2. Allocate memory, so after work it has to be freed by using call BPU_gf2SparsePolyFree.

Parameters
psparse polynomial to allocate
weightweight of sparse polynomial

Definition at line 140 of file gf2types.c.

void BPU_gf2SparseQcMatrixFree ( BPU_T_GF2_Sparse_Qc_Matrix v,
int  is_dyn 
)

Free dynamically or statically allocated sparse quasi-cyclic matrix over GF2.

Parameters
vsparse quasi-cyclic matrix
is_dynboolean param, if 0 do not free object self, else free also object

Definition at line 174 of file gf2types.c.

void BPU_gf2SparseQcMatrixMalloc ( BPU_T_GF2_Sparse_Qc_Matrix v,
int  element_count,
int  element_size,
int  isVertical 
)

Allocate memory for sparse quasi-cyclic matrix over GF2. Allocate memory, so after work it has to be freed by using call BPU_gf2SparseQcMatrixFree.

Parameters
vsparse quasi-cyclic matrix
element_countcount of cyclic elements
element_sizesize of one cyclic element
isVerticalboolean, if 1, elements are in vertical orientation, if 0 horizontal orientation

Definition at line 154 of file gf2types.c.

void BPU_gf2VecFree ( BPU_T_GF2_Vector **  v)

Free dynamically or statically allocated vector.

Free dynamically or statically allocated vector GF2.

Parameters
[out]*maddress of vector object

Definition at line 45 of file gf2types.c.

int BPU_gf2VecMalloc ( BPU_T_GF2_Vector **  v,
int  len 
)

Allocate memory for vector GF2. It also null vector. After work you have to free memory using call BPU_freeVecGF2.

Parameters
lenlen of vector
Returns
on succes 0, else error

Definition at line 97 of file gf2types.c.

int BPU_gf2VecMallocElements ( BPU_T_GF2_Vector v,
int  len 
)

BPU_gf2VecMallocElements Malloc vector elements and set to zero.

Parameters
v
len
Returns

Definition at line 114 of file gf2types.c.

int BPU_gf2VecResize ( BPU_T_GF2_Vector v,
int  len 
)

BPU_gf2VecResize Resize vecor.

Parameters
v
len
Returns

Definition at line 107 of file gf2types.c.