From 382627426b2c2cdce9caeb6e5ef36e2d56cae037 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 9 Sep 2019 03:52:40 -0500 Subject: [PATCH] added vanity address support --- onionr/keymanager.py | 3 ++- onionr/onionrcommands/pubkeymanager.py | 3 ++- onionr/onionrcrypto/encryption/__init__.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/onionr/keymanager.py b/onionr/keymanager.py index 55f1511f..3798b463 100755 --- a/onionr/keymanager.py +++ b/onionr/keymanager.py @@ -21,6 +21,7 @@ from onionrutils import bytesconverter from onionrcrypto import generate import os import filepaths + class KeyManager: def __init__(self): self.keyFile = filepaths.keys_file @@ -72,6 +73,6 @@ class KeyManager: with open(self.keyFile, "r") as keyFile: keyData = keyFile.read() for pair in keyData.split('\n'): - if pubKey in pair: + if pubKey in pair or pubKey.replace('=', '') in pair: privKey = pair.split(',')[1] return privKey \ No newline at end of file diff --git a/onionr/onionrcommands/pubkeymanager.py b/onionr/onionrcommands/pubkeymanager.py index b6ad4746..4c9ee77d 100755 --- a/onionr/onionrcommands/pubkeymanager.py +++ b/onionr/onionrcommands/pubkeymanager.py @@ -76,7 +76,8 @@ def change_ID(): logger.warn('Specify pubkey to use', terminal=True) else: if stringvalidators.validate_pub_key(key): - if key in key_manager.getPubkeyList(): + key_list = key_manager.getPubkeyList() + if key in key_list or key.replace('=', '') in key_list: config.set('general.public_key', key) config.save() logger.info('Set active key to: %s' % (key,), terminal=True) diff --git a/onionr/onionrcrypto/encryption/__init__.py b/onionr/onionrcrypto/encryption/__init__.py index f9d1664b..0bcdde6b 100644 --- a/onionr/onionrcrypto/encryption/__init__.py +++ b/onionr/onionrcrypto/encryption/__init__.py @@ -3,8 +3,8 @@ from .. import getourkeypair import unpaddedbase32 from onionrutils import bytesconverter, stringvalidators pair = getourkeypair.get_keypair() -our_pub_key = pair[0] -our_priv_key = pair[1] +our_pub_key = unpaddedbase32.repad(pair[0].encode()) +our_priv_key = unpaddedbase32.repad(pair[1].encode()) def pub_key_encrypt(data, pubkey, encodedData=False): '''Encrypt to a public key (Curve25519, taken from base32 Ed25519 pubkey)'''