7
7
'''
8
8
9
9
import json
10
- import hashlib
11
- import urllib .request
12
10
import sys
13
11
14
12
filename_input = sys .argv [1 ]
19
17
num_groups = len (doc ['testGroups' ])
20
18
21
19
def to_c_array (x ):
22
- if x == "" : return ""
20
+ if x == "" :
21
+ return ""
23
22
s = ',0x' .join (a + b for a ,b in zip (x [::2 ], x [1 ::2 ]))
24
23
return "0x" + s
25
24
@@ -43,18 +42,23 @@ def to_c_array(x):
43
42
sig_size = len (test_vector ['sig' ]) // 2
44
43
msg_size = len (test_vector ['msg' ]) // 2
45
44
46
- if test_vector ['result' ] == "invalid" : expected_verify = 0
47
- elif test_vector ['result' ] == "valid" : expected_verify = 1
48
- else : raise ValueError ("invalid result field" )
45
+ if test_vector ['result' ] == "invalid" :
46
+ expected_verify = 0
47
+ elif test_vector ['result' ] == "valid" :
48
+ expected_verify = 1
49
+ else :
50
+ raise ValueError ("invalid result field" )
49
51
50
- if num_vectors != 0 and sig_size != 0 : signatures += ",\n "
52
+ if num_vectors != 0 and sig_size != 0 :
53
+ signatures += ",\n "
51
54
52
55
new_msg = False
53
56
msg = to_c_array (test_vector ['msg' ])
54
57
msg_offset = offset_msg_running
55
58
# check for repeated msg
56
59
if msg not in cache_msgs .keys ():
57
- if num_vectors != 0 and msg_size != 0 : messages += ",\n "
60
+ if num_vectors != 0 and msg_size != 0 :
61
+ messages += ",\n "
58
62
cache_msgs [msg ] = offset_msg_running
59
63
messages += msg
60
64
new_msg = True
@@ -66,7 +70,8 @@ def to_c_array(x):
66
70
pk_offset = offset_pk_running
67
71
# check for repeated pk
68
72
if pk not in cache_public_keys .keys ():
69
- if num_vectors != 0 : public_keys += ",\n "
73
+ if num_vectors != 0 :
74
+ public_keys += ",\n "
70
75
cache_public_keys [pk ] = offset_pk_running
71
76
public_keys += pk
72
77
new_pk = True
@@ -83,8 +88,10 @@ def to_c_array(x):
83
88
offset_sig ,
84
89
sig_size ,
85
90
expected_verify ) + " },\n "
86
- if new_msg : offset_msg_running += msg_size
87
- if new_pk : offset_pk_running += 65
91
+ if new_msg :
92
+ offset_msg_running += msg_size
93
+ if new_pk :
94
+ offset_pk_running += 65
88
95
offset_sig += sig_size
89
96
num_vectors += 1
90
97
0 commit comments