-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added keystore that supports encryption so nsecs are no longer kept i…
…n cleartext - this replaces alias.py which will be removed
- Loading branch information
monty
committed
Jun 4, 2024
1 parent
66ee763
commit 3d44f86
Showing
3 changed files
with
431 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import asyncio | ||
import logging | ||
from hashlib import sha256 | ||
from monstr.ident.keystore import NamedKeys, FileKeyStore, KeyDataEncrypter, SQLiteKeyStore | ||
from monstr.ident.persist import MemoryProfileStore | ||
from monstr.ident.profile import Profile | ||
|
||
# logging.getLogger().setLevel(logging.DEBUG) | ||
|
||
|
||
async def convert_store(): | ||
# load the old data as alias stores it | ||
old_file = '/home/monty/.nostrpy/profiles.csv' | ||
|
||
# create a new key store and copy name/key maps in | ||
new_file = '/home/monty/.nostrpy/keystore.db' | ||
|
||
|
||
async def get_key() -> str: | ||
# will block, use aiconsole where it matters | ||
return input('keystore key: ') | ||
|
||
my_enc = KeyDataEncrypter(get_key=get_key) | ||
new_store = SQLiteKeyStore(new_file, | ||
encrypter=my_enc) | ||
|
||
await new_store.convert_memstore(old_file) | ||
|
||
|
||
|
||
async def test_store(): | ||
# create a new key store and copy name/key maps in | ||
new_file = '/home/monty/.nostrpy/keystore.db' | ||
async def get_key() -> str: | ||
# will block, use aiconsole where it matters | ||
return input('keystore key: ') | ||
|
||
my_enc = KeyDataEncrypter(get_key=get_key) | ||
|
||
new_store = SQLiteKeyStore(new_file, | ||
encrypter=my_enc) | ||
|
||
await new_store.add(NamedKeys('moobs')) | ||
|
||
# print(await new_store.get('monty_test')) | ||
# | ||
# from monstr.encrypt import Keys | ||
# await new_store.update(Keys(), 'monty_test') | ||
|
||
asyncio.run(convert_store()) | ||
|
||
|
||
|
||
# nk = NamedKeys('shaun') | ||
# | ||
# print(nk) | ||
# | ||
# my_store = FileKeyStore('/home/monty/.nostrpy/profiles.csv') | ||
# print(my_store.get('che')) | ||
# | ||
# k = NamedKeys(name='c') | ||
# my_store.update(k) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.