-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackgroundProac.py
More file actions
39 lines (29 loc) · 1.09 KB
/
backgroundProac.py
File metadata and controls
39 lines (29 loc) · 1.09 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
import refreshShares
import additiveShares
import partialSignatures
import additiveSignatures
def background(f): #Runs function under @background in the background
'''
a threading decorator
use @background above the function you want to run in the background
'''
def backgrnd_func(*a, **kw):
threading.Thread(target=f, args=a, kwargs=kw).start()
return backgrnd_func
@background
def proactive_timer():
'''f is field size for shares == n = p.q'''
n = fileOp.read_list("FpublicKey")[0]
additive_shares = fileOp.read_list("FadditiveShares")[0]
while True:
refreshShares.refresh_shares()
additiveShares.additive_signature()
print("Original:",additive_shares)
time.sleep(15) #Shares refreshed every 3 seconds
#Verify all signatures
add_sig_ver = partialSignatures.signature_verify()
#Detect Faulty Additive share (if any)
if not add_sig_ver:
additiveSignatures.additive_signature_verify()
#Invoke Share reconstruction if faulty share present
invoke_backup()