ABY Framework  1.0
Arithmetic Bool Yao Framework
 All Classes Files Functions Variables Enumerations Enumerator Macros
arithmeticcircuits.h
Go to the documentation of this file.
1 
19 #ifndef __ARITHMETICCIRCUITS_H_
20 #define __ARITHMETICCIRCUITS_H_
21 
22 #include "../util/typedefs.h"
23 #include "abycircuit.h"
24 #include "circuit.h"
25 
27 class ArithmeticCircuit: public Circuit {
28 public:
29  ArithmeticCircuit(ABYCircuit* aby, e_sharing context, e_role myrole, uint32_t bitlen) :
30  Circuit(aby, context, myrole, bitlen, C_ARITHMETIC) {
31  Init();
32  }
33  ;
35  Cleanup();
36  }
37  ;
38 
39  void Init();
40  void Cleanup();
41  void Reset();
42 
43  uint32_t PutMULGate(uint32_t left, uint32_t right);
44  uint32_t PutADDGate(uint32_t left, uint32_t right);
45 
46  uint32_t PutINGate(uint32_t nvals, e_role src);
47  share* PutINGate(uint32_t nvals, uint64_t val, uint32_t bitlen, e_role role);
48  share* PutINGate(uint32_t nvals, uint8_t* val, uint32_t bitlen, e_role role);
49  share* PutINGate(uint32_t nvals, uint32_t* val, uint32_t bitlen, e_role role);
50  template<class T> uint32_t PutINGate(uint32_t nvals, T val);
51  template<class T> uint32_t PutINGate(uint32_t nvals, T val, e_role role);
52  uint32_t PutOUTGate(uint32_t parent, e_role dst);
53  share* PutOUTGate(share* parent, e_role dst);
54 
55  share* PutCallbackGate(share* in, uint32_t rounds, void (*callback)(GATE*, void*), void* infos, uint32_t nvals);
56 
57  uint32_t PutINVGate(uint32_t parentid);
58  uint32_t PutCONVGate(vector<uint32_t>& parentids);
59 
60  share* PutADDGate(share* ina, share* inb);
61 
62  share* PutSUBGate(share* ina, share* inb) {
63  cerr << "SUB not implemented in arithmetic sharing" << endl;
64  return new arithshare(this);
65  }
66  share* PutANDGate(share* ina, share* inb) {
67  cerr << "AND not implemented in arithmetic sharing" << endl;
68  return new arithshare(this);
69  }
70  share* PutXORGate(share* ina, share* inb) {
71  cerr << "XOR not implemented in arithmetic sharing" << endl;
72  return new arithshare(this);
73  }
74  share* PutSubGate(share* ina, share* inb) {
75  cerr << "Sub not implemented in arithmetic sharing" << endl;
76  return new arithshare(this);
77  }
78  share* PutMULGate(share* ina, share* inb);
79 
80  share* PutGEGate(share* ina, share* inb) {
81  cerr << "GE not implemented in arithmetic sharing" << endl;
82  return new arithshare(this);
83  }
84  share* PutEQGate(share* ina, share* inb) {
85  cerr << "EQ not implemented in arithmetic sharing" << endl;
86  return new arithshare(this);
87  }
88  share* PutMUXGate(share* ina, share* inb, share* sel) {
89  cerr << "MUX not implemented in arithmetic sharing" << endl;
90  return new arithshare(this);
91  }
92  share* PutY2BGate(share* ina) {
93  cerr << "Y2B not implemented in arithmetic sharing" << endl;
94  return new arithshare(this);
95  }
96  share* PutB2YGate(share* ina) {
97  cerr << "B2Y not implemented in arithmetic sharing" << endl;
98  return new arithshare(this);
99  }
100  share* PutA2YGate(share* ina) {
101  cerr << "A2Y not implemented in arithmetic sharing" << endl;
102  return new arithshare(this);
103  }
104  share* PutANDVecGate(share* ina, share* inb) {
105  cerr << "ANDVec Gate not implemented in arithmetic sharing" << endl;
106  return new arithshare(this);
107  }
108  uint32_t PutB2AGate(vector<uint32_t> ina);
109  share* PutB2AGate(share* ina);
110  //TODO: implement
111  //uint32_t PutY2AGate(vector<uint32_t>& parentids, uint32_t mindepth=0);
112 
113  uint32_t GetNumMULGates() {
114  return m_nMULs;
115  }
116  ;
117  uint32_t GetNumCONVGates() {
118  return m_nCONVGates;
119  }
120  ;
121 
122  //share* PutCONSGate(UGATE_T val, uint32_t nvals = 1);
123  share* PutCONSGate(uint32_t nvals, UGATE_T val, uint32_t bitlen);
124  share* PutCONSGate(uint32_t nvals, uint8_t* val, uint32_t bitlen);
125  share* PutCONSGate(uint32_t nvals, uint32_t* val, uint32_t bitlen);
126  uint32_t PutConstantGate(UGATE_T val, uint32_t nvals = 1);
127  uint32_t GetMaxCommunicationRounds() {
128  return m_nMaxDepth;
129  }
130  ;
131 
132 private:
133  void UpdateInteractiveQueue(uint32_t gateid);
134  void UpdateLocalQueue(uint32_t gateid);
135 
136  uint32_t m_nMULs; //number of AND gates in the circuit
137  uint32_t m_nCONVGates; //number of Boolean to arithmetic conversion gates
138 };
139 
140 #endif /* __ARITHMETICCIRCUITS_H_ */
Definition: abycircuit.h:122
Definition: circuit.h:258
ABYCircuit class.
Contains the class for generic circuits, which is a super-class of Boolean and Arithmetic circuits...
Circuit(ABYCircuit *aby, e_sharing context, e_role myrole, uint32_t bitlen, e_circuit circ)
Definition: circuit.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
Definition: abycircuit.h:144
e_sharing
Enumeration which defines the different sharing which are there in the framework. ...
Definition: constants.h:124
Definition: circuit.h:30
Definition: constants.h:47
Definition: arithmeticcircuits.h:27
Definition: circuit.h:360