ABY Framework  1.0
Arithmetic Bool Yao Framework
 All Classes Files Functions Variables Enumerations Enumerator Macros
boolsharing.h
Go to the documentation of this file.
1 
19 #ifndef __BOOLSHARING_H__
20 #define __BOOLSHARING_H__
21 
22 #include "sharing.h"
23 #include <algorithm>
24 #include "../circuit/booleancircuits.h"
25 
26 //#define DEBUGBOOL
30 class BoolSharing: public Sharing {
31 
32 public:
34  BoolSharing(e_role role, uint32_t sharebitlen, ABYCircuit* circuit, crypto* crypt) :\
35 
36  Sharing(role, sharebitlen, circuit, crypt) {
37  Init();
38  }
39  ;
42  }
43  ;
44 
45  //SUPER CLASS MEMBER FUNCTION
46  void PrepareSetupPhase(ABYSetup* setup);
47  void PerformSetupPhase(ABYSetup* setup);
48  void FinishSetupPhase(ABYSetup* setup);
49  void EvaluateLocalOperations(uint32_t level);
50  void EvaluateInteractiveOperations(uint32_t level);
51 
52  void FinishCircuitLayer();
53 
54  void PrepareOnlinePhase();
55 
56  inline void InstantiateGate(GATE* gate);
57  inline void UsedGate(uint32_t gateid);
58 
59  void GetDataToSend(vector<BYTE*>& sendbuf, vector<uint32_t>& bytesize);
60  void GetBuffersToReceive(vector<BYTE*>& rcvbuf, vector<uint32_t>& rcvbytes);
61 
62  void EvaluateSIMDGate(uint32_t gateid);
63 
65  return m_cBoolCircuit;
66  }
67  ;
68 
69  uint32_t AssignInput(CBitVector& input);
70  uint32_t GetOutput(CBitVector& out);
71 
73  return m_cBoolCircuit->GetMaxDepth();
74  }
75  ;
77  return m_nTotalNumMTs;
78  }
79  ;
80 
81  void Reset();
82  vector<uint32_t> GetNumOTs() {
83  return m_nNumMTs;
84  }
85  ;
86 
87  const char* sharing_type() {
88  return "Boolean";
89  }
90  ;
91 
93  //ENDS HERE
94 private:
95  uint32_t m_nNumANDSizes;
96 
97  uint32_t m_nTotalNumMTs;
98  vector<uint32_t> m_nNumMTs;
99  uint32_t m_nXORGates;
100 
101  XORMasking *fMaskFct; // = new XORMasking(1);
102  vector<uint32_t> m_vMTStartIdx;
103  vector<uint32_t> m_vMTIdx;
104  vector<vector<uint32_t> > m_vANDGates;
105  vector<uint32_t> m_vInputShareGates;
106  vector<uint32_t> m_vOutputShareGates;
107 
108  uint32_t m_nInputShareSndSize;
109  uint32_t m_nOutputShareSndSize;
110 
111  uint32_t m_nInputShareRcvSize;
112  uint32_t m_nOutputShareRcvSize;
113 
114  vector<CBitVector> m_vA; //Dim 1 for all pairs of sender / receiver, Dim 2 for MTs of different bitlengths as sender / receiver
115  vector<CBitVector> m_vB; //value B of a multiplication triple
116  vector<CBitVector> m_vS; // temporary value for the computation of the multiplication triples
117  vector<CBitVector> m_vC; // value C of a multiplication triple
118  vector<CBitVector> m_vD_snd; //Stores the D values (x ^ a) between an input and the multiplication value a
119  vector<CBitVector> m_vE_snd; //Stores the E values (y ^ b) between the other input and the multiplication value b
120  vector<CBitVector> m_vD_rcv;
121  vector<CBitVector> m_vE_rcv;
122  vector<CBitVector> m_vResA;
123  vector<CBitVector> m_vResB;
124  non_lin_vec_ctx* m_vANDs;
125 
126  CBitVector m_vInputShareSndBuf;
127  CBitVector m_vOutputShareSndBuf;
128 
129  CBitVector m_vInputShareRcvBuf;
130  CBitVector m_vOutputShareRcvBuf;
131 
132  BooleanCircuit* m_cBoolCircuit;
133 
138  inline void ShareValues(uint32_t gateid);
143  inline void ReconstructValue(uint32_t gateid);
144 
148  void AssignInputShares();
152  void AssignOutputShares();
153 
158  inline void SelectiveOpen(uint32_t gateid);
163  inline void SelectiveOpenVec(uint32_t gateid);
167  void EvaluateMTs();
171  void EvaluateANDGate();
177  inline void EvaluateXORGate(uint32_t gateid);
183  inline void EvaluateINVGate(uint32_t gateid);
189  inline void EvaluateCONVGate(uint32_t gateid);
195  inline void EvaluateConstantGate(uint32_t gateid);
199  void InitializeMTs();
203  void ComputeMTs();
204 
208  void Init();
212  void InitNewLayer();
213 
214 };
215 
216 #endif /* __BOOLSHARING_H__ */
Definition: booleancircuits.h:27
Definition: sharing.h:43
~BoolSharing()
Definition: boolsharing.h:41
void FinishSetupPhase(ABYSetup *setup)
Definition: boolsharing.cpp:100
void InstantiateGate(GATE *gate)
Definition: boolsharing.cpp:746
void FinishCircuitLayer()
Definition: boolsharing.cpp:476
uint32_t GetMaxCommunicationRounds()
Definition: boolsharing.h:72
uint32_t GetNumNonLinearOperations()
Definition: boolsharing.h:76
uint32_t GetMaxDepth()
Definition: circuit.h:70
void GetBuffersToReceive(vector< BYTE * > &rcvbuf, vector< uint32_t > &rcvbytes)
Definition: boolsharing.cpp:717
Definition: crypto.h:58
Sharing class. A virtual class that contains the methods which the sharing schemes have to implement...
void Reset()
Definition: boolsharing.cpp:910
void PrintPerformanceStatistics()
Definition: boolsharing.cpp:903
Definition: abycircuit.h:122
Definition: boolsharing.h:30
Definition: xormasking.h:24
void PerformSetupPhase(ABYSetup *setup)
Definition: boolsharing.cpp:97
void GetDataToSend(vector< BYTE * > &sendbuf, vector< uint32_t > &bytesize)
Definition: boolsharing.cpp:676
uint32_t AssignInput(CBitVector &input)
Definition: boolsharing.cpp:860
void EvaluateLocalOperations(uint32_t level)
Definition: boolsharing.cpp:227
void PrepareSetupPhase(ABYSetup *setup)
Definition: boolsharing.cpp:52
void EvaluateInteractiveOperations(uint32_t level)
Definition: boolsharing.cpp:266
BoolSharing(e_role role, uint32_t sharebitlen, ABYCircuit *circuit, crypto *crypt)
Definition: boolsharing.h:34
e_role
Defines the role of the party or the source / target for certain operations (e.g., input/output)
Definition: constants.h:139
uint32_t GetOutput(CBitVector &out)
Definition: boolsharing.cpp:886
const char * sharing_type()
Definition: boolsharing.h:87
void UsedGate(uint32_t gateid)
Definition: boolsharing.cpp:751
Definition: abycircuit.h:144
Definition: abysetup.h:77
Definition: circuit.h:30
Definition: abycircuit.h:137
void PrepareOnlinePhase()
Definition: boolsharing.cpp:157
Definition: cbitvector.h:123
Circuit * GetCircuitBuildRoutine()
Definition: boolsharing.h:64