From 37db4b514e0d55f1c9942edce90c9b15ea7aa6ec Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 29 Sep 2019 23:40:23 -0500 Subject: [PATCH] switch pubkeymanager and contactmanager over to niceware --- onionr/onionrcommands/pubkeymanager.py | 7 +++---- onionr/onionrusers/contactmanager.py | 8 +++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/onionr/onionrcommands/pubkeymanager.py b/onionr/onionrcommands/pubkeymanager.py index 5fcf2871..e301ccc8 100755 --- a/onionr/onionrcommands/pubkeymanager.py +++ b/onionr/onionrcommands/pubkeymanager.py @@ -21,9 +21,9 @@ import sys, getpass import unpaddedbase32 -import vanityonionr -import mnemonic +import niceware +import vanityonionr import logger, onionrexceptions from onionrutils import stringvalidators, bytesconverter from onionrusers import onionrusers, contactmanager @@ -95,7 +95,6 @@ def add_vanity(): key_manager = keymanager.KeyManager() tell = lambda tell: logger.info(tell, terminal=True) words = '' - m = mnemonic.Mnemonic('english') length = len(sys.argv) - 2 if length == 0: return for i in range(2, len(sys.argv)): @@ -112,7 +111,7 @@ def add_vanity(): logger.warn('Vanity words must be valid english bip39', terminal=True) else: b32_pub = unpaddedbase32.b32encode(vanity[0]) - tell('Found vanity address:\n' + m.to_mnemonic(vanity[0])) + tell('Found vanity address:\n' + niceware.bytes_to_passphrase(vanity[0])) tell('Base32 Public key: %s' % (b32_pub.decode(),)) key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1])) except KeyboardInterrupt: diff --git a/onionr/onionrusers/contactmanager.py b/onionr/onionrusers/contactmanager.py index ea86b435..25343efb 100755 --- a/onionr/onionrusers/contactmanager.py +++ b/onionr/onionrusers/contactmanager.py @@ -17,18 +17,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' -import os, json, onionrexceptions +import os, json import unpaddedbase32 +import niceware + +import onionrexceptions from onionrusers import onionrusers from onionrutils import bytesconverter, epoch from utils import identifyhome from onionrutils import mnemonickeys -import mnemonic class ContactManager(onionrusers.OnionrUser): def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5): try: if mnemonickeys.DELIMITER in publicKey: - publicKey = mnemonic.Mnemonic('english').to_entropy(publicKey.split(mnemonickeys.DELIMITER)) + publicKey = mnemonickeys.get_base32(publicKey.split(mnemonickeys.DELIMITER)) publicKey = unpaddedbase32.b32encode(bytesconverter.str_to_bytes(publicKey)) except ValueError: pass