ABY Framework  1.0
Arithmetic Bool Yao Framework
 All Classes Files Functions Variables Enumerations Enumerator Macros
arithsharing.h
Go to the documentation of this file.
1 
19 #ifndef __ARITHSHARING_H__
20 #define __ARITHSHARING_H__
21 
22 #include "sharing.h"
23 #include <algorithm>
24 #include "../circuit/arithmeticcircuits.h"
25 
26 //#define DEBUGARITH
27 //#define VERIFY_ARITH_MT
28 
29 template<typename T>
31 class ArithSharing: public Sharing {
32 
33 public:
35  ArithSharing(e_role role, uint32_t sharebitlen, ABYCircuit* circuit, crypto* crypt, e_mt_gen_alg mt_alg) :
36  Sharing(role, sharebitlen, circuit, crypt) {
37  m_eMTGenAlg = mt_alg;
38  Init();
39  }
40  ;
43  Reset();
44  }
45  ;
46 
47  //MEMBER FUNCTIONS OF THE SUPER CLASS
48  void Reset();
49  void PrepareSetupPhase(ABYSetup* setup);
50  void PerformSetupPhase(ABYSetup* setup);
51  void FinishSetupPhase(ABYSetup* setup);
52  void EvaluateLocalOperations(uint32_t gateid);
53  void EvaluateInteractiveOperations(uint32_t gateid);
54 
55  void FinishCircuitLayer();
56 
57  void PrepareOnlinePhase();
58 
59  void InstantiateGate(GATE* gate);
60  void UsedGate(uint32_t gateid);
61 
62  void GetDataToSend(vector<BYTE*>& sendbuf, vector<uint32_t>& bytesize);
63  void GetBuffersToReceive(vector<BYTE*>& rcvbuf, vector<uint32_t>& rcvbytes);
64 
65  uint32_t AssignInput(CBitVector& input);
66  uint32_t GetOutput(CBitVector& out);
67 
69  return m_cArithCircuit->GetMaxDepth();
70  }
71  ;
73  return m_nMTs;
74  }
75  ;
76 
78  return m_cArithCircuit;
79  }
80  ;
81 
82  const char* sharing_type() {
83  return "Arithmetic";
84  }
85  ;
86 
88  //ENDS HERE...
93  void EvaluateSIMDGate(uint32_t gateid);
94 
99  void EvaluateINVGate(GATE* gate);
104  void EvaluateCONVGate(GATE* gate);
105 
106 private:
107 
108  ArithmeticCircuit* m_cArithCircuit;
109 
110  e_mt_gen_alg m_eMTGenAlg;
111 
112  uint32_t m_nMTs;
113  uint32_t m_nNumCONVs;
114 
115  uint32_t m_nTypeBitLen;
116  uint64_t m_nTypeBitMask;
117 
118  vector<uint32_t> m_vMTStartIdx;
119  vector<uint32_t> m_vMTIdx;
120  vector<GATE*> m_vMULGates;
121  vector<GATE*> m_vInputShareGates;
122  vector<GATE*> m_vOutputShareGates;
123  vector<GATE*> m_vCONVGates;
124 
125  uint32_t m_nInputShareSndCtr;
126  uint32_t m_nOutputShareSndCtr;
127 
128  uint32_t m_nInputShareRcvCtr;
129  uint32_t m_nOutputShareRcvCtr;
130 
131  vector<CBitVector> m_vA; //Dim 1 for all pairs of sender / receiver, Dim 2 for MTs of different bitlengths as sender / receiver
132  vector<CBitVector> m_vB; //value B of a multiplication triple
133  vector<CBitVector> m_vS; // temporary value for the computation of the multiplication triples
134  vector<CBitVector> m_vC; // value C of a multiplication triple
135  vector<CBitVector> m_vD_snd; //Stores the D values (x ^ a) between an input and the multiplication value a
136  vector<CBitVector> m_vE_snd; //Stores the E values (y ^ b) between the other input and the multiplication value b
137  vector<CBitVector> m_vD_rcv;
138  vector<CBitVector> m_vE_rcv;
139  vector<CBitVector> m_vResA;
140  vector<CBitVector> m_vResB;
141 
142  CBitVector m_vInputShareSndBuf;
143  CBitVector m_vOutputShareSndBuf;
144 
145  CBitVector m_vInputShareRcvBuf;
146  CBitVector m_vOutputShareRcvBuf;
147 
148  CBitVector m_vConvShareSndBuf;
149  CBitVector m_vConvShareRcvBuf;
150 
151  vector<CBitVector> m_vConversionMasks;
152 
153  CBitVector m_vConversionRandomness;
154 
155  uint32_t m_nConvShareIdx; //the global
156  uint32_t m_nConvShareSndCtr; //counts for each round
157  uint32_t m_nConvShareRcvCtr;
162  void ShareValues(GATE* gate);
167  void ReconstructValue(GATE* gate);
171  void AssignInputShares();
176  void AssignOutputShares();
177 
182  void SelectiveOpen(GATE* gate);
186  void EvaluateMTs();
191  void EvaluateADDGate(GATE* gate);
195  void EvaluateMULGate();
196 
200  void AssignConversionShares();
201 
205  void AssignServerConversionShares();
206 
210  void AssignClientConversionShares();
211 
212 #ifdef VERIFY_ARITH_MT
213  //called at setup -> finish
214  void VerifyArithMT(ABYSetup* setup);
215 #endif
216 
219  void InitMTs();
220 
224  void ComputeMTsFromOTs();
228  void FinishMTGeneration();
232  void Init();
236  void InitNewLayer();
237 };
238 
239 #endif /* ArithSharing */
Definition: arithsharing.h:31
Definition: sharing.h:43
void GetDataToSend(vector< BYTE * > &sendbuf, vector< uint32_t > &bytesize)
Definition: arithsharing.cpp:731
const char * sharing_type()
Definition: arithsharing.h:82
void EvaluateINVGate(GATE *gate)
Definition: arithsharing.cpp:715
uint32_t GetMaxDepth()
Definition: circuit.h:70
void EvaluateSIMDGate(uint32_t gateid)
Definition: arithsharing.cpp:856
Definition: crypto.h:58
Sharing class. A virtual class that contains the methods which the sharing schemes have to implement...
void PrepareSetupPhase(ABYSetup *setup)
Definition: arithsharing.cpp:70
void EvaluateInteractiveOperations(uint32_t gateid)
Definition: arithsharing.cpp:294
void FinishSetupPhase(ABYSetup *setup)
Definition: arithsharing.cpp:145
uint32_t GetMaxCommunicationRounds()
Definition: arithsharing.h:68
Definition: abycircuit.h:122
uint32_t GetNumNonLinearOperations()
Definition: arithsharing.h:72
e_mt_gen_alg
Enumeration which defines the method that is used for arithmetic multiplication triple generation...
Definition: constants.h:55
void GetBuffersToReceive(vector< BYTE * > &rcvbuf, vector< uint32_t > &rcvbytes)
Definition: arithsharing.cpp:788
void InstantiateGate(GATE *gate)
Definition: arithsharing.cpp:840
ArithSharing(e_role role, uint32_t sharebitlen, ABYCircuit *circuit, crypto *crypt, e_mt_gen_alg mt_alg)
Definition: arithsharing.h:35
void EvaluateLocalOperations(uint32_t gateid)
Definition: arithsharing.cpp:256
uint32_t AssignInput(CBitVector &input)
Definition: arithsharing.cpp:990
uint32_t GetOutput(CBitVector &out)
Definition: arithsharing.cpp:1016
void FinishCircuitLayer()
Definition: arithsharing.cpp:477
e_role
Defines the role of the party or the source / target for certain operations (e.g., input/output)
Definition: constants.h:139
void PrintPerformanceStatistics()
Definition: arithsharing.cpp:1035
void Reset()
Definition: arithsharing.cpp:1040
void EvaluateCONVGate(GATE *gate)
Definition: arithsharing.cpp:399
Definition: abycircuit.h:144
Definition: abysetup.h:77
void PerformSetupPhase(ABYSetup *setup)
Definition: arithsharing.cpp:140
void UsedGate(uint32_t gateid)
Definition: arithsharing.cpp:846
Definition: circuit.h:30
void PrepareOnlinePhase()
Definition: arithsharing.cpp:232
Definition: arithmeticcircuits.h:27
Definition: cbitvector.h:123
Circuit * GetCircuitBuildRoutine()
Definition: arithsharing.h:77
~ArithSharing()
Definition: arithsharing.h:42