forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquare.h
48 lines (36 loc) · 1.08 KB
/
Square.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
/*
* gf2nSquare.h
*
*/
#ifndef MATH_SQUARE_H_
#define MATH_SQUARE_H_
#include "Tools/BitVector.h"
template<class U>
class Square
{
protected:
static const int N_ROWS = U::MAX_N_BITS;
public:
typedef U RowType;
static int n_rows() { return U::size_in_bits(); }
static int n_rows_allocated() { return n_rows(); }
static int n_columns() { return n_rows(); }
static int n_row_bytes() { return U::size(); }
static size_t size() { return U::length() * U::size(); }
U rows[N_ROWS];
Square& sub(const Square& other);
Square& rsub(const Square& other);
Square& sub(const void* other);
void bit_sub(const BitVector& bits, int start);
void randomize(int row, PRNG& G) { rows[row].randomize(G); }
void conditional_add(BitVector& conditions, Square& other,
int offset);
void to(U& result);
void to(U& result, false_type);
void to(U& result, true_type);
template<int X, int L>
void to(gfp_<X, L>& result, true_type);
void pack(octetStream& os) const;
void unpack(octetStream& os);
};
#endif /* MATH_SQUARE_H_ */