-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.py
62 lines (44 loc) · 1.33 KB
/
client.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
'''
' Client.py
' Generates pairings and groupings for key generation
' Input json file name, length of key generation, output is filled in json file
'''
import sys
import random
import json
# A: 01, 23
# B: 02, 13
# C: 03, 12
# 00: phi+phi-
# 01: phi-phi+
# 10: psi+psi-
# 11: psi-psi+
# Values that correspond to pairings of
pairings_list = [[[0, 1], [2, 3]], [[0, 2], [1, 3]], [[0, 3], [1, 2]]]
bell_state_grouping = [0, 1, 2, 3]
def generate_pairings_and_groupings(key_length):
#start random generation
random.seed() #uses system time
pairings = []
groupings = []
for _ in range(key_length):
random_pair = pairings_list[random.randrange(0, len(pairings_list))]
pairings.append(random_pair)
for _ in range(key_length):
random_grouping = bell_state_grouping[random.randrange(0, len(bell_state_grouping))]
groupings.append(random_grouping)
json_output = {
"pairings": pairings,
"groupings": groupings
}
return json_output
def main():
#get inputs
outfile = sys.argv[1]
key_length = int(sys.argv[2])
json_output = generate_pairings_and_groupings(key_length)
# output
with open(outfile) as fp:
json.dump(json_output, fp)
if __name__ == "__main__":
main()