forked from hclivess/nado
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeys.py
More file actions
37 lines (26 loc) · 816 Bytes
/
keys.py
File metadata and controls
37 lines (26 loc) · 816 Bytes
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
import json
import os
from Curve25519 import generate_keydict
from data_ops import get_home
def save_keys(keydict, file=f"{get_home()}/private/keys.dat"):
with open(file, "w") as keyfile:
json.dump(keydict, keyfile)
def load_keys(file=f"{get_home()}/private/keys.dat"):
"""{"private_key": "", "public_key": "", "address": ""}"""
with open(file, "r") as keyfile:
keydict = json.load(keyfile)
return keydict
def keyfile_found(file=f"{get_home()}/private/keys.dat"):
if os.path.isfile(file):
return True
else:
return False
def generate_keys():
keydict = generate_keydict()
return keydict
if __name__ == "__main__":
if not keyfile_found():
keydict = generate_keys()
save_keys(keydict)
else:
keydict = load_keys()