-
Notifications
You must be signed in to change notification settings - Fork 0
/
wire.py
67 lines (52 loc) · 1.85 KB
/
wire.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from Value import Value
def checkIndex(index, wire):
assert str(type(index)) == "<class 'int'>"
assert (index < wire) and (index > -1)
def checkArray(arr, n_parties):
assert str(type(arr)) == "<class 'list'>"
assert len(arr) == n_parties
class Wire:
def __init__(self, wire_data, n_parties, n_wires): # recieve from circuit.py
self.data = wire_data
self.n_wire = n_wires
self.n_parties = n_parties
def __repr__(self):
return "data: " + str(self.data) + " n_wires: " + str(self.n_wire)
def e(self, index):
checkIndex(index, self.n_wire)
return self.data[index]['e']
def set_e(self, index, val):
checkIndex(index, self.n_wire)
self.data[index]['e'] = val
return 1
def v(self, index):
checkIndex(index, self.n_wire)
return self.data[index]['v']
def set_v(self, index, arr):
checkIndex(index, self.n_wire)
checkArray(arr, self.n_parties)
self.data[index]['v'] = arr
return 1
def lambda_val(self, index):
checkIndex(index, self.n_wire)
return self.data[index]['lambda']
def set_lambda(self, index, arr):
checkIndex(index, self.n_wire)
checkArray(arr, self.n_parties)
self.data[index]['lambda'] = arr
return 1
def lam_hat(self, index):
checkIndex(index, self.n_wire)
return self.data[index]['lam_hat']
def set_lam_hat(self, index, arr, mult_count):
checkIndex(index, self.n_wire)
checkArray(arr, self.n_parties)
self.data[index]['lam_hat'][str(mult_count)] = arr
return 1
def e_hat(self, index):
checkIndex(index, self.n_wire)
return self.data[index]['e_hat']
def set_e_hat(self, index, val):
checkIndex(index, self.n_wire)
self.data[index]['e_hat'] = val
return 1