-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncoder.h
More file actions
132 lines (98 loc) · 3.38 KB
/
Encoder.h
File metadata and controls
132 lines (98 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef ENCODER_H
#define ENCODER_H
#include "GF.h"
#include <NTL/mat_ZZ_p.h>
#include <vector>
using namespace NTL;
using namespace std;
class Encoder: public GF
{
public:
Encoder(int mlen, int numVec, int lengthExtension = 1);
~Encoder();
int numVec;
Mat<ZZ_p> enVec;
/**
Set encoding/decoding matrix (Hilbert Matrix, a special case of Cauchy Matrix, was used by default)
@param numVec The number of columns of the matrix, which is equal to number of decoding parity + number of checker parity.
*/
void setEnVec(int numVec);
/**
Print to screen the specifications of the encoder.
*/
void toString();
/**
Returns a list of parities (done in sender's side).
@param data A list of integers representing the original binary sequence.
@return A list of parities.
*/
Vec<ZZ_p> paritize(Vec<ZZ_p> data);
/**
Returns a list of parities (done in sender's side).
@param s The original binary sequence.
@return A list of parities.
*/
Vec<ZZ_p> paritize(string s);
/**
Converts a list of binary strings to integers (NTL ZZ_p).
@param v A list of binary strings.
@return A list of integers (NTL ZZ_p.
*/
Vec<ZZ_p> bin2zz(vector<string> v);
/**
Converts a number to a binary string.
@param zz A number.
@param size The bit length of the output binary string.
@return A binary string represents the input number.
*/
string zz2bin(ZZ_p zz, int size);
/**
Converts a number to a binary string.
@param n A number.
@param size The bit length of the output binary string.
@return A binary string represents the input number.
*/
string zz2bin(long n, int size);
/**
Converts a list numbers to a list binary strings.
@param vec A list of numbers.
@param size The bit length of the output binary strings.
@return A list binary strings represents the input numbers.
*/
vector<string> zz2bin(Vec<ZZ_p> vec, int size);
/**
Converts a list numbers to a list binary string.
@param vec A list of numbers.
@param size The list of corresponding bit lengths of the output binary strings.
@return A list binary strings represents the input numbers.
*/
vector<string> zz2bin(Vec<ZZ_p> vec, vector<int> size);
/**
Break a long binary string into blocks of smaller binary strings
with each block has the length of blocklength - number of deletion in that block.
@param s The full string.
@param dels The list block indices where a bit is deleted.
@return A list sub binary strings broken from the input binary string.
*/
vector<string> breakString(string s, vector<long> dels = vector<long>());
/**
Generate a random binary string of size mlen. mlen should is a multiple of 16 bits.
@return A random binary string sized mlen (a class variable).
*/
string randBin();
/**
Delete one bit from string s at index idx.
@param s The binary string.
@param idx The index of the deleted bit.
@return A copy of string s with the bit at idx deleted.
*/
string erase(string s, long idx);
/**
Delete several bits from string s.
@param s The binary string.
@param idxs The list of indices of the deletions.
@return A copy of string s with several bits deleted.
*/
string erase(string s, vector<long> idxs);
};
#endif // ENCODER_H