switch pubkeymanager and contactmanager over to niceware

master
Kevin Froman 2019-09-29 23:40:23 -05:00
parent 991c79b350
commit 37db4b514e
2 changed files with 8 additions and 7 deletions

View File

@ -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:

View File

@ -17,18 +17,20 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
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