-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprotocolNTRU.py
40 lines (30 loc) · 1.27 KB
/
protocolNTRU.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
import time
from ttpNTRU import TTP
from clientNTRU import CLIENT
from serverNTRU import SERVER
ENROLLED = 1 # which sample is in database; nr from 1 to 5
if __name__ == '__main__':
security_in_bits = 256 # {112, 128, 192, 256}
factor_keep = 0.25
ttp = TTP(security_in_bits, factor_keep)
# ttp.FACTOR_KEEP = 0.125 # it is possible to adjust this factor during runtime
id_probe = (174, 5)
print('factor keep:', ttp.FACTOR_KEEP)
print('ID probe:', id_probe)
client1 = CLIENT(ttp.ring, ttp.pk)
t0 = time.time()
server1 = SERVER(ttp.ring, ttp.pk, ENROLLED)
t1 = time.time()
probe = client1.CLIENTencryptProbe(id_probe)
t2 = time.time()
print('verification:', server1.SERVERverification(ttp, probe, id_probe))
t3 = time.time()
print('baseline_verification:', server1.SERVERverificationAll(ttp, probe, id_probe))
t4 = time.time()
print('identification with factor keep:', ttp.FACTOR_KEEP, ', ID found:', server1.SERVERidentification(ttp, probe))
t5 = time.time()
print('server_init: ', t1 - t0)
print('probe_encryption: ', t2 - t1)
print('verification: ', t3 - t2)
print('baseline_verification:', t4 - t3)
print('identification: ', t5 - t4)