added vanity address support

This commit is contained in:
Kevin Froman 2019-09-09 03:52:40 -05:00
parent 866f0ce501
commit 382627426b
3 changed files with 6 additions and 4 deletions

View File

@ -21,6 +21,7 @@ from onionrutils import bytesconverter
from onionrcrypto import generate from onionrcrypto import generate
import os import os
import filepaths import filepaths
class KeyManager: class KeyManager:
def __init__(self): def __init__(self):
self.keyFile = filepaths.keys_file self.keyFile = filepaths.keys_file
@ -72,6 +73,6 @@ class KeyManager:
with open(self.keyFile, "r") as keyFile: with open(self.keyFile, "r") as keyFile:
keyData = keyFile.read() keyData = keyFile.read()
for pair in keyData.split('\n'): for pair in keyData.split('\n'):
if pubKey in pair: if pubKey in pair or pubKey.replace('=', '') in pair:
privKey = pair.split(',')[1] privKey = pair.split(',')[1]
return privKey return privKey

View File

@ -76,7 +76,8 @@ def change_ID():
logger.warn('Specify pubkey to use', terminal=True) logger.warn('Specify pubkey to use', terminal=True)
else: else:
if stringvalidators.validate_pub_key(key): 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.set('general.public_key', key)
config.save() config.save()
logger.info('Set active key to: %s' % (key,), terminal=True) logger.info('Set active key to: %s' % (key,), terminal=True)

View File

@ -3,8 +3,8 @@ from .. import getourkeypair
import unpaddedbase32 import unpaddedbase32
from onionrutils import bytesconverter, stringvalidators from onionrutils import bytesconverter, stringvalidators
pair = getourkeypair.get_keypair() pair = getourkeypair.get_keypair()
our_pub_key = pair[0] our_pub_key = unpaddedbase32.repad(pair[0].encode())
our_priv_key = pair[1] our_priv_key = unpaddedbase32.repad(pair[1].encode())
def pub_key_encrypt(data, pubkey, encodedData=False): def pub_key_encrypt(data, pubkey, encodedData=False):
'''Encrypt to a public key (Curve25519, taken from base32 Ed25519 pubkey)''' '''Encrypt to a public key (Curve25519, taken from base32 Ed25519 pubkey)'''