forked from FudanMPL/Garnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
P2Data.h
executable file
·54 lines (38 loc) · 1.19 KB
/
P2Data.h
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
#ifndef _P2Data
#define _P2Data
/* This class defines all the data needed for representing
* plaintexts modulo 2
*/
#include "FHE/Ring.h"
#include "FHE/Matrix.h"
#include "Math/gf2n.h"
class P2Data
{
int slots;
// Data for the forward mapping ((slots*gf2n:deg) by phi_m)
imatrix A;
// Data for the backward mapping (phi_m by phi_m)
imatrix Ai;
public:
typedef gf2n_short T;
typedef int S;
typedef fixint<0> poly_type;
int num_slots() const { return slots; }
int degree() const { return A.size() ? A.size() : 0; }
int phi_m() const { return A[0].size(); }
void check_dimensions() const;
void forward(vector<poly_type>& ans,const vector<gf2n_short>& a) const;
void backward(vector<gf2n_short>& ans,const vector<poly_type>& a) const;
int get_prime() const { return 2; }
bool operator!=(const P2Data& other) const;
// no op because we require field to be initalized first
void init_field() const {}
void hash(octetStream& o) const;
void pack(octetStream& o) const;
void unpack(octetStream& o);
void load(const Ring& Rg);
void store(const Ring& Rg) const;
void load_or_generate(const Ring& Rg);
friend void init(P2Data& P2D,const Ring& Rg);
};
#endif