-
Notifications
You must be signed in to change notification settings - Fork 27
/
file_proof.py
583 lines (490 loc) · 24.4 KB
/
file_proof.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
#!/bin/sh
""":" .
exec python "$0" "$@"
"""
# -*- coding: utf-8 -*-
"""
Copyright (c) 2017 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import argparse
import binascii
import datetime
import hashlib
import os
import json
import sys
sys.path.extend(["../../"])
from bbc1.core import bbc_app
from bbc1.core.bbc_config import DEFAULT_CORE_PORT
from bbc1.core import bbclib
from bbc1.core.message_key_types import KeyType
from bbc1.core.bbc_error import *
MAPPING_FILE = ".bbc_id_mappings"
PRIVATE_KEY = ".private_key"
PUBLIC_KEY = ".public_key"
domain_id = bbclib.get_new_id("file_proof_test_domain", include_timestamp=False)
asset_group_id = bbclib.get_new_id("file_proof_asset_group", include_timestamp=False)
user_name = "user_default"
user_id = bbclib.get_new_id(user_name, include_timestamp=False)
key_pair = None
def store_id_mappings(name, asset_group_id, transaction_id=None, asset_ids=None):
if transaction_id is None and asset_ids is None:
return
mapping = dict()
asset_group_id_str = binascii.b2a_hex(asset_group_id).decode()
if os.path.exists(MAPPING_FILE):
with open(MAPPING_FILE, "r") as f:
mapping = json.load(f)
mapping.setdefault(asset_group_id_str, dict()).setdefault(name, dict())
if transaction_id is not None:
mapping[asset_group_id_str][name]['transaction_id'] = binascii.b2a_hex(transaction_id).decode()
if asset_ids is not None:
if isinstance(asset_ids, list):
entry = []
for ast in asset_ids:
entry.append(binascii.b2a_hex(ast))
mapping[asset_group_id_str][name]['asset_id'] = entry
else:
mapping[asset_group_id_str][name]['asset_id'] = binascii.b2a_hex(asset_ids).decode()
with open(MAPPING_FILE, "w") as f:
json.dump(mapping, f, indent=4)
def remove_id_mappings(name, asset_group_id):
mapping = dict()
asset_group_id_str = binascii.b2a_hex(asset_group_id).decode()
if os.path.exists(MAPPING_FILE):
with open(MAPPING_FILE, "r") as f:
mapping = json.load(f)
if asset_group_id_str in mapping:
mapping[asset_group_id_str].pop(name, None)
if len(mapping[asset_group_id_str].keys()) == 0:
del mapping[asset_group_id_str]
with open(MAPPING_FILE, "w") as f:
json.dump(mapping, f, indent=4)
def get_id_from_mappings(name, asset_group_id):
if not os.path.exists(MAPPING_FILE):
return None
asset_group_id_str = binascii.b2a_hex(asset_group_id).decode()
with open(MAPPING_FILE, "r") as f:
mapping = json.load(f)
if mapping is None:
return None
if asset_group_id_str in mapping and name in mapping[asset_group_id_str]:
result = dict()
if 'transaction_id' in mapping[asset_group_id_str][name]:
result['transaction_id'] = binascii.a2b_hex(mapping[asset_group_id_str][name]['transaction_id'])
if 'asset_id' in mapping[asset_group_id_str][name]:
if isinstance(mapping[asset_group_id_str][name]['asset_id'], list):
entry = []
for ast in mapping[asset_group_id_str][name]['asset_id']:
entry.append(binascii.a2b_hex(ast))
result['asset_id'] = entry
else:
result['asset_id'] = binascii.a2b_hex(mapping[asset_group_id_str][name]['asset_id'])
return result
return None
def get_list_from_mappings(asset_group_id):
if not os.path.exists(MAPPING_FILE):
return None
asset_group_id_str = binascii.b2a_hex(asset_group_id).decode()
with open(MAPPING_FILE, "r") as f:
mapping = json.load(f)
if mapping is None:
return None
if asset_group_id_str in mapping:
result = []
for name in mapping[asset_group_id_str]:
result.append(name)
return result
return None
def domain_setup():
tmpclient = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT, multiq=False, loglevel="all")
if os.path.exists("node_key.pem"):
tmpclient.set_node_key("node_key.pem")
tmpclient.domain_setup(domain_id)
tmpclient.callback.synchronize()
tmpclient.unregister_from_core()
print("Domain %s is created." % (binascii.b2a_hex(domain_id[:4]).decode()))
print("Setup is done.")
def setup_bbc_client():
bbc_app_client = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT, multiq=False, loglevel="all")
bbc_app_client.set_user_id(user_id)
bbc_app_client.set_domain_id(domain_id)
bbc_app_client.set_callback(bbc_app.Callback())
ret = bbc_app_client.register_to_core()
assert ret
return bbc_app_client
def require_receiver_info_for(filename):
print("Your name is [", user_name, "] and user_id is [", binascii.b2a_hex(user_id).decode(), "]")
print("Please enter the receiver user name for file %s." % filename)
receiver_name = input('>> ')
receiver_user_id = bbclib.get_new_id(receiver_name, include_timestamp=False)
return receiver_name, receiver_user_id
def search_reference_txid_from_mappings(filename):
reference_txid = None
file_info = get_id_from_mappings(os.path.basename(filename), asset_group_id)
if file_info:
reference_txid = file_info["transaction_id"]
return reference_txid
def send_signreq(receiver_name, receiver_user_id, ref_txids=None, file_data=None, bbc_app_client=None):
transaction = bbclib.make_transaction(relation_num=1, witness=True)
user_info_msg = "Ownership is transfered from %s to %s" % (user_name, receiver_name)
bbclib.add_relation_asset(transaction, relation_idx=0, asset_group_id=asset_group_id,
user_id=receiver_user_id, asset_body=user_info_msg, asset_file=file_data)
transaction.witness.add_witness(user_id)
transaction.witness.add_witness(receiver_user_id)
for i, ref_txid in enumerate(ref_txids):
bbc_app_client.search_transaction(ref_txid)
response_data = bbc_app_client.callback.synchronize()
if response_data[KeyType.status] < ESUCCESS:
print("ERROR: ", response_data[KeyType.reason].decode())
sys.exit(0)
prev_tx, fmt_type = bbclib.deserialize(response_data[KeyType.transaction_data])
bbclib.add_relation_pointer(transaction, 0, ref_transaction_id=prev_tx.digest())
asset_id = transaction.relations[0].asset.asset_id
asset_files = {asset_id: file_data}
ret = bbc_app_client.gather_signatures(transaction, destinations=[receiver_user_id], asset_files=asset_files)
if not ret:
print("Failed to send sign request")
sys.exit(0)
return transaction
def wait_for_signs(transaction, bbc_app_client):
response_data = bbc_app_client.callback.synchronize()
if response_data[KeyType.status] < ESUCCESS:
print("Rejected because ", response_data[KeyType.reason].decode(), "")
sys.exit(0)
result = response_data[KeyType.result]
transaction.witness.add_signature(user_id=result[1], signature=result[2])
sig_mine = transaction.sign(private_key=key_pair.private_key,
public_key=key_pair.public_key)
transaction.witness.add_signature(user_id=user_id, signature=sig_mine)
transaction.digest()
return transaction
def create_transaction_object_for_filedata(receiver_name, receiver_user_id, ref_txids=None, file_data=None,
bbc_app_client=None):
if ref_txids is None or ref_txids[0] is None:
ref_txids = []
transaction = send_signreq(receiver_name, receiver_user_id, ref_txids, file_data, bbc_app_client)
return wait_for_signs(transaction, bbc_app_client)
def insert_signed_transaction_to_bbc_core(transaction=None, bbc_app_client=None, file_name=None):
print("Insert the transaction into BBc-1")
ret = bbc_app_client.insert_transaction(transaction)
assert ret
response_data = bbc_app_client.callback.synchronize()
if response_data[KeyType.status] < ESUCCESS:
print("ERROR: ", response_data[KeyType.reason].decode())
sys.exit(0)
def send_transaction_info_msg(bbc_app_client=None, transaction=None, file_name=None, receiver_user_id=None):
transaction_info = [os.path.basename(file_name), transaction.transaction_id]
bbc_app_client.send_message(transaction_info, receiver_user_id)
def wait_for_transaction_msg(bbc_app_client=None):
print("Your name is [", user_name, "] and user_id is [", binascii.b2a_hex(user_id).decode(), "]")
print("Waiting for file transfer.....")
response_data = bbc_app_client.callback.synchronize()
if KeyType.transaction_data not in response_data or KeyType.all_asset_files not in response_data:
print("**** Invalid message is received...")
print(response_data)
bbc_app_client.sendback_denial_of_sign(response_data[KeyType.source_user_id],
response_data[KeyType.transaction_id],
"Invalid message is received.")
sys.exit(1)
return response_data
def pick_valid_transaction_info(received_data=None, bbc_app_client=None):
transaction, fmt_type = bbclib.deserialize(received_data[KeyType.transaction_data])
asset_files = received_data[KeyType.all_asset_files]
asset_id = transaction.relations[0].asset.asset_id
if asset_id not in asset_files:
print("**** No valid file is received...")
print(received_data)
bbc_app_client.sendback_denial_of_sign(received_data[KeyType.source_user_id],
transaction.transaction_id,
"No valid file is received.")
sys.exit(1)
file_to_obtain = asset_files[asset_id]
file_digest = hashlib.sha256(file_to_obtain).digest()
print("--------------------------")
print("File digest written in the transaction data: ",
binascii.b2a_hex(transaction.relations[0].asset.asset_file_digest).decode())
print("File digest calculated from the received file:", binascii.b2a_hex(file_digest).decode())
print("--------------------------")
return transaction, received_data[KeyType.source_user_id]
def prompt_user_to_accept_the_file(bbc_app_client=None, source_id=None, transaction_id=None):
print("====> Do you want to accept the file?")
answer = input('(Y/N) >> ')
if answer != "Y":
bbc_app_client.sendback_denial_of_sign(source_id, transaction_id, "Denied to accept the file")
sys.exit(1)
def wait_for_file_info_msg(bbc_app_client=None):
print("Waiting for the message from the sender...")
response_data = bbc_app_client.callback.synchronize(timeout=10)
if response_data is None:
print("No final message received... Ask the sender about the filename and transaction_id")
sys.exit(0)
if KeyType.message not in response_data:
print("Received invalid message....")
sys.exit(0)
filename, transaction_id = response_data[KeyType.message]
print("--> file name is %s and the transaction_id is %s" % (filename.decode(),
binascii.b2a_hex(transaction_id).decode()))
return filename, transaction_id
def store_proc(file, txid=None):
with open(file, "rb") as fin:
data = fin.read()
bbc_app_client = setup_bbc_client()
store_transaction = bbclib.make_transaction(relation_num=1, witness=True)
user_info = "Owner is %s" % user_name
bbclib.add_relation_asset(store_transaction, relation_idx=0, asset_group_id=asset_group_id,
user_id=user_id, asset_body=user_info, asset_file=data)
store_transaction.witness.add_witness(user_id)
if txid:
bbc_app_client.search_transaction(txid)
response_data = bbc_app_client.callback.synchronize()
if response_data[KeyType.status] < ESUCCESS:
print("ERROR: ", response_data[KeyType.reason].decode())
sys.exit(0)
prev_tx, fmt_type = bbclib.deserialize(response_data[KeyType.transaction_data])
bbclib.add_relation_pointer(transaction=store_transaction, relation_idx=0,
ref_transaction_id=prev_tx.transaction_id)
sig = store_transaction.sign(private_key=key_pair.private_key,
public_key=key_pair.public_key)
store_transaction.get_sig_index(user_id)
store_transaction.add_signature_object(user_id=user_id, signature=sig)
store_transaction.digest()
print(store_transaction)
ret = bbc_app_client.insert_transaction(store_transaction)
assert ret
response_data = bbc_app_client.callback.synchronize()
if response_data[KeyType.status] < ESUCCESS:
print("ERROR: ", response_data[KeyType.reason].decode())
sys.exit(0)
store_id_mappings(os.path.basename(file), asset_group_id, transaction_id=response_data[KeyType.transaction_id],
asset_ids=store_transaction.relations[0].asset.asset_id)
def store_file(file):
fileinfo = get_id_from_mappings(os.path.basename(file), asset_group_id)
if fileinfo is not None:
print("the file already stored : %s" % os.path.basename(file))
sys.exit(0)
store_proc(file=file, txid=None)
print("file stored : %s" % os.path.basename(file))
print("done store %s" % file)
def get_file(file):
fileinfo = get_id_from_mappings(os.path.basename(file), asset_group_id)
if fileinfo is None:
print("Not exists in local mapping cache. So, asset_id is not known...")
sys.exit(1)
bbc_app_client = setup_bbc_client()
ret = bbc_app_client.search_transaction_with_condition(asset_group_id=asset_group_id, asset_id=fileinfo["asset_id"])
assert ret
response_data = bbc_app_client.callback.synchronize()
if response_data[KeyType.status] < ESUCCESS:
print("ERROR: ", response_data[KeyType.reason].decode())
sys.exit(0)
get_transaction, fmt_type = bbclib.deserialize(response_data[KeyType.transactions][0])
if KeyType.all_asset_files in response_data:
asset_file_dict = response_data[KeyType.all_asset_files]
asset_id = get_transaction.relations[0].asset.asset_id
data = asset_file_dict[asset_id]
else:
data = get_transaction.relations[0].asset.asset_body
out_file_name = file
if os.path.exists(out_file_name):
current_datetime = datetime.datetime.now()
time_str = current_datetime.strftime('_%Y%m%d%H%M%S')
out_file_name += time_str
with open(out_file_name, "wb") as outfile:
outfile.write(data)
print("done get %s" % out_file_name)
def remove_file(file):
fileinfo = get_id_from_mappings(os.path.basename(file), asset_group_id)
if fileinfo is None:
print("File does not exist: %s" % os.path.basename(file))
sys.exit(0)
fileinfo = remove_id_mappings(os.path.basename(file), asset_group_id)
print("done remove %s" % file)
def list_file():
fileinfo = get_list_from_mappings(asset_group_id)
if fileinfo is None:
print("No files present in local mapping cache. So, asset_id is not known...")
sys.exit(1)
print("%s" % '\n'.join(fileinfo))
def update_file(file):
fileinfo = get_id_from_mappings(os.path.basename(file), asset_group_id)
if fileinfo is None:
print("Not exists in local mapping cache. So, transaction_id is not known...")
sys.exit(1)
transaction_id = fileinfo["transaction_id"]
# TODO consider whether to check existence of the transaction object
store_proc(file=file, txid=transaction_id)
print("done update %s" % os.path.basename(file))
def verify_file(file):
fileinfo = get_id_from_mappings(os.path.basename(file), asset_group_id)
if fileinfo is None:
print("Not exists in local mapping cache. So, asset_id is not known...")
sys.exit(1)
bbc_app_client = setup_bbc_client()
ret = bbc_app_client.search_transaction_with_condition(asset_group_id=asset_group_id, asset_id=fileinfo["asset_id"])
assert ret
response_data = bbc_app_client.callback.synchronize()
if response_data[KeyType.status] < ESUCCESS:
print("ERROR: ", response_data[KeyType.reason].decode())
sys.exit(0)
transaction, fmt_type = bbclib.deserialize(response_data[KeyType.transactions][0])
digest = transaction.digest()
ret = transaction.signatures[0].verify(digest)
if not ret:
print("Transaction data is invalid.")
sys.exit(1)
with open(file, "rb") as fin:
data = fin.read()
file_digest = hashlib.sha256(data).digest()
if file_digest == transaction.relations[0].asset.asset_file_digest:
print("%s is valid" % file)
else:
print("%s is invalid" % file)
print("done verify %s" % os.path.basename(file))
print("Content of the transaction:::")
print(transaction)
def create_keypair():
keypair = bbclib.KeyPair()
keypair.generate()
with open(PRIVATE_KEY, "wb") as fout:
fout.write(keypair.private_key)
with open(PUBLIC_KEY, "wb") as fout:
fout.write(keypair.public_key)
print("created private_key and public_key : %s, %s" % (PRIVATE_KEY, PUBLIC_KEY))
def enter_file_wait_mode():
bbc_app_client = setup_bbc_client()
recvdat = wait_for_transaction_msg(bbc_app_client=bbc_app_client)
transaction, source_id = pick_valid_transaction_info(received_data=recvdat,
bbc_app_client=bbc_app_client)
prompt_user_to_accept_the_file(bbc_app_client=bbc_app_client, source_id=source_id, transaction_id=transaction.transaction_id)
signature = transaction.sign(keypair=key_pair)
bbc_app_client.sendback_signature(source_id, transaction.transaction_id, -1, signature)
filename, transaction_id = wait_for_file_info_msg(bbc_app_client=bbc_app_client)
store_id_mappings(os.path.basename(filename.decode()), asset_group_id,
transaction_id=transaction_id, asset_ids=transaction.relations[0].asset.asset_id)
def enter_file_send_mode(filename):
receiver_name, receiver_user_id = require_receiver_info_for(filename)
with open(filename, "rb") as fin:
file_data = fin.read()
txid_for_reference = search_reference_txid_from_mappings(filename)
bbc_app_client = setup_bbc_client()
transfer_transaction = create_transaction_object_for_filedata(receiver_name,
receiver_user_id,
ref_txids=[txid_for_reference],
file_data=file_data,
bbc_app_client=bbc_app_client)
insert_signed_transaction_to_bbc_core(transaction=transfer_transaction,
bbc_app_client=bbc_app_client,
file_name=filename)
remove_id_mappings(os.path.basename(filename), asset_group_id)
send_transaction_info_msg(bbc_app_client=bbc_app_client,
transaction=transfer_transaction,
file_name=filename,
receiver_user_id=receiver_user_id)
print("Transfer is done.....")
def sys_check(args):
if args.command_type in ("store", "update", "verify") and \
not os.path.exists(args.target_file):
raise Exception("file not found : %s" % args.target_file)
# TODO consider whether to check core accessibility
if args.command_type != "keypair":
if not os.path.exists(PRIVATE_KEY):
message = "not exist private key\n"
message += "create a key pair with keypair option"
raise Exception(message)
if not os.path.exists(PUBLIC_KEY):
message = "not exist public key\n"
message += "create a key pair with keypair option"
raise Exception(message)
with open(PRIVATE_KEY, "rb") as fin:
private_key = fin.read()
with open(PUBLIC_KEY, "rb") as fin:
public_key = fin.read()
global key_pair
key_pair = bbclib.KeyPair(privkey=private_key, pubkey=public_key)
def argument_parser():
argparser = argparse.ArgumentParser()
subparsers = argparser.add_subparsers(dest="command_type", help='commands')
# put command
store_parser = subparsers.add_parser('store', help='Store a file')
store_parser.add_argument('target_file', action='store', help='A target file')
store_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# get command
get_parser = subparsers.add_parser('get', help='Get a file')
get_parser.add_argument('target_file', action='store', help='A target file')
get_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# remove command
get_parser = subparsers.add_parser('remove', help='Remove a file')
get_parser.add_argument('target_file', action='store', help='A target file')
get_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# list command
list_parser = subparsers.add_parser('list', help='Get a file list')
list_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# update command
update_parser = subparsers.add_parser('update', help='Update a file')
update_parser.add_argument('target_file', action='store', help='A target file')
update_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# verify command
verify_parser = subparsers.add_parser('verify', help='Verify a file')
verify_parser.add_argument('target_file', action='store', help='A target file')
verify_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# key pair command
subparsers.add_parser('keypair', help='Create a key pair')
# wait mode for receiving file
wait_parser = subparsers.add_parser('wait', help='Wait for receiving a file')
wait_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# send mode
send_parser = subparsers.add_parser('send', help='Send a file')
send_parser.add_argument('target_file', action='store', help='A target file')
send_parser.add_argument('-o', '--user', action='store', help='Your name (for calculating user_id)',
default='user_default')
# setup command
store_parser = subparsers.add_parser('setup', help='Setup domain and asset group')
return argparser.parse_args()
if __name__ == '__main__':
parsed_args = argument_parser()
try:
sys_check(parsed_args)
except Exception as e:
print(str(e))
sys.exit(0)
if parsed_args.command_type == "keypair":
create_keypair()
elif parsed_args.command_type == "setup":
domain_setup()
else:
user_name = parsed_args.user
user_id = bbclib.get_new_id(user_name, include_timestamp=False)
if parsed_args.command_type == "store":
store_file(file=parsed_args.target_file)
elif parsed_args.command_type == "get":
get_file(file=parsed_args.target_file)
elif parsed_args.command_type == "remove":
remove_file(file=parsed_args.target_file)
elif parsed_args.command_type == "list":
list_file()
elif parsed_args.command_type == "update":
update_file(file=parsed_args.target_file)
elif parsed_args.command_type == "verify":
verify_file(file=parsed_args.target_file)
elif parsed_args.command_type == "wait":
enter_file_wait_mode()
elif parsed_args.command_type == "send":
enter_file_send_mode(filename=parsed_args.target_file)
sys.exit(0)