ABY Framework  1.0
Arithmetic Bool Yao Framework
 All Classes Files Functions Variables Enumerations Enumerator Macros
yaoserversharing.h
Go to the documentation of this file.
1 
19 #ifndef __YAOSERVERSHARING_H__
20 #define __YAOSERVERSHARING_H__
21 
22 #include "sharing.h"
23 #include <algorithm>
24 #include "yaosharing.h"
25 
26 typedef struct {
27  uint32_t gateid;
28  UGATE_T* inval;
30 
31 typedef struct {
32  uint32_t gateid;
33  uint32_t pos;
35 
36 //#define DEBUGYAOSERVER
41 
42 public:
46  YaoServerSharing(e_role role, uint32_t sharebitlen, ABYCircuit* circuit, crypto* crypt) :
47  YaoSharing(role, sharebitlen, circuit, crypt) {
48  InitServer();
49  }
50  ;
55  Reset();
56  }
57  ;
58 
59  //MEMBER FUNCTIONS FROM SUPER CLASS YAO SHARING
60  void Reset();
61  void PrepareSetupPhase(ABYSetup* setup);
62  void PerformSetupPhase(ABYSetup* setup);
63  void FinishSetupPhase(ABYSetup* setup);
64  void EvaluateLocalOperations(uint32_t gateid);
65  void EvaluateInteractiveOperations(uint32_t gateid);
66  void SendConversionValues(uint32_t gateid);
67 
68  void FinishCircuitLayer();
69 
70  void PrepareOnlinePhase();
71 
72  void InstantiateGate(GATE* gate);
73  void UsedGate(uint32_t gateid);
74 
75  void GetDataToSend(vector<BYTE*>& sendbuf, vector<uint32_t>& bytesize);
76  void GetBuffersToReceive(vector<BYTE*>& rcvbuf, vector<uint32_t>& rcvbytes);
77 
78  uint32_t AssignInput(CBitVector& input);
79  uint32_t GetOutput(CBitVector& out);
80 
81  const char* sharing_type() {
82  return "Yao server";
83  }
84  ;
85  //ENDS HERE..
86 
87 private:
88  //Global constant key
89  CBitVector m_vR;
90  //Permutation bits for the servers input keys
91  CBitVector m_vPermBits;
92  //Random values from output of ot extension
93  vector<CBitVector> m_vROTMasks;
94  uint32_t m_nClientInputKexIdx;
95  uint32_t m_nClientInputKeyCtr;
97  CBitVector m_vServerKeySndBuf;
98  vector<CBitVector> m_vClientKeySndBuf;
99  CBitVector m_vClientROTRcvBuf;
101  //vector<CBitVector> m_vClientConversionKeySndBuf;
102  //CBitVector m_vClientCOnversionROTRcvBuf;
103 
104  CBitVector m_vOutputShareSndBuf;
105  CBitVector m_vOutputShareRcvBuf;
107  vector<GATE*> m_vServerOutputGates;
109  uint32_t m_nOutputShareRcvCtr;
111  uint64_t m_nPermBitCtr;
112  uint32_t m_nServerInBitCtr;
114  uint32_t m_nServerKeyCtr;
115  uint32_t m_nClientInBitCtr;
117  uint8_t* m_bLMaskBuf[2];
118  uint8_t* m_bRMaskBuf[2];
119  uint8_t* m_bLKeyBuf;
120  uint8_t* m_bOKeyBuf[2];
121  uint8_t* m_bTmpBuf;
122  //CBitVector
123 
124  vector<uint32_t> m_vClientInputGate;
125  deque<input_gate_val_t> m_vPreSetInputGates;
126  deque<a2y_gate_pos_t> m_vPreSetA2YPositions;
127  e_role* m_vOutputDestionations;
128  uint32_t m_nOutputDestionationsCtr;
129 
130 
131  //deque<uint32_t> m_vClientInputGate;
132 
134  void InitServer();
136  void InitNewLayer();
137 
143  void CreateRandomWireKeys(CBitVector& vec, uint32_t numkeys);
148  void CreateAndSendGarbledCircuit(ABYSetup* setup);
152  void ReceiveGarbledCircuit();
158  void EvaluateInputGate(uint32_t gateid);
164  void EvaluateXORGate(GATE* gate);
170  void EvaluateANDGate(GATE* gate);
176  void EvaluateSIMDGate(uint32_t gateid);
182  void EvaluateInversionGate(GATE* gate);
188  void EvaluateConversionGate(uint32_t gateid);
196  void CreateGarbledTable(GATE* ggate, uint32_t pos, GATE* gleft, GATE* gright);
201  void PrecomputeGC(deque<uint32_t>& queue);
202 
203  //void EvaluateClientOutputGate(GATE* gate);
204  void CollectClientOutputShares();
210  void EvaluateOutputGate(GATE* gate);
211 
216  void SendServerInputKey(uint32_t gateid);
221  void SendClientInputKey(uint32_t gateid);
225  void AssignOutputShares();
226 };
227 
228 #endif /* __YAOSERVERSHARING_H__ */
void EvaluateInteractiveOperations(uint32_t gateid)
Definition: yaoserversharing.cpp:181
void GetDataToSend(vector< BYTE * > &sendbuf, vector< uint32_t > &bytesize)
Definition: yaoserversharing.cpp:661
void Reset()
Definition: yaoserversharing.cpp:968
Definition: yaoserversharing.h:26
const char * sharing_type()
Definition: yaoserversharing.h:81
Definition: yaoserversharing.h:40
Definition: crypto.h:58
Sharing class. A virtual class that contains the methods which the sharing schemes have to implement...
void InstantiateGate(GATE *gate)
Definition: yaoserversharing.cpp:843
Definition: abycircuit.h:122
uint32_t AssignInput(CBitVector &input)
Definition: yaoserversharing.cpp:925
~YaoServerSharing()
Definition: yaoserversharing.h:54
void FinishCircuitLayer()
Definition: yaoserversharing.cpp:689
uint32_t GetOutput(CBitVector &out)
Definition: yaoserversharing.cpp:951
YaoServerSharing(e_role role, uint32_t sharebitlen, ABYCircuit *circuit, crypto *crypt)
Definition: yaoserversharing.h:46
Definition: yaosharing.h:42
void PrepareSetupPhase(ABYSetup *setup)
Definition: yaoserversharing.cpp:56
void FinishSetupPhase(ABYSetup *setup)
Definition: yaoserversharing.cpp:137
void PerformSetupPhase(ABYSetup *setup)
Definition: yaoserversharing.cpp:129
void EvaluateLocalOperations(uint32_t gateid)
Definition: yaoserversharing.cpp:177
e_role
Defines the role of the party or the source / target for certain operations (e.g., input/output)
Definition: constants.h:139
void PrepareOnlinePhase()
Definition: yaoserversharing.cpp:275
void GetBuffersToReceive(vector< BYTE * > &rcvbuf, vector< uint32_t > &rcvbytes)
Definition: yaoserversharing.cpp:791
Definition: abycircuit.h:144
Definition: abysetup.h:77
void UsedGate(uint32_t gateid)
Definition: yaoserversharing.cpp:853
Definition: cbitvector.h:123
Definition: yaoserversharing.h:31
Yao Sharing class.