-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproactivizer.py
More file actions
52 lines (38 loc) · 1.33 KB
/
proactivizer.py
File metadata and controls
52 lines (38 loc) · 1.33 KB
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
import fileOp
import additiveShares
import thresholdShares
def refresh_shares():
'''Refreshes all shares in list old_shares,share field size is f'''
additive_shares = fileOp.read_list("FadditiveShares")
n = fileOp.read_list("FmodulusRSA")[0]
old_shares = additive_shares
l = len(old_shares)
new_shares = [0 for _ in range(l)]
#Refresh previous additive shares
for i in old_shares:
share_div = additiveShares.additive_sharing(i,l)
new_shares = [(a+b) for a,b in zip(new_shares,share_div)]
#Update new refreshed shares
fileOp.write_list("FadditiveShares",new_shares)
#Threshold on new shares
print("Running")
thresholdShares.threshold_additive_shares()
print("Done")
def proactive_timer():
'''f is field size for shares == n = p.q'''
global n
global additive_shares
while True:
refresh_shares()
additive_signature()
print("Original:",additive_shares)
time.sleep(15) #Shares refreshed every 3 seconds
#Verify all signatures
add_sig_ver = signature_verify()
#Detect Faulty Additive share (if any)
if not add_sig_ver:
additive_signature_verify()
#Invoke Share reconstruction if faulty share present
invoke_backup()
if __name__ == '__main__':
refresh_shares()