From 631510f4fe850344084e06f1cacac8cc1dc9e636 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sat, 28 Sep 2019 20:22:39 -0500 Subject: [PATCH] moved vanityonionr into onionr repo --- onionr/vanityonionr/__init__.py | 92 +++++++++++++++++++++++++++++++++ requirements.in | 1 - requirements.txt | 2 - 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 onionr/vanityonionr/__init__.py diff --git a/onionr/vanityonionr/__init__.py b/onionr/vanityonionr/__init__.py new file mode 100644 index 00000000..72038e35 --- /dev/null +++ b/onionr/vanityonionr/__init__.py @@ -0,0 +1,92 @@ +""" +Onionr Vanity address generator + +Library to generate vanity ed25519 addresses in various encodings +""" +""" +Onionr Vanity Address Generator +Copyright (C) 2019 Kevin Froman + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +import mnemonic +import nacl.signing, nacl.encoding + +import multiprocessing +from multiprocessing import Process, Pipe, Queue +import re, time +import threading + +m = mnemonic.Mnemonic("english") +wordlist = m.wordlist + +def find_vanity_mnemonic(start_words: str, queue): + + key_pair = [b"", b""] + vanity_key = "" + check = 0 + while not vanity_key.startswith(start_words): + key = nacl.signing.SigningKey.generate() + key_pair[1] = key.encode(nacl.encoding.RawEncoder) + key_pair[0] = key.verify_key.encode(encoder=nacl.encoding.RawEncoder) + vanity_key = m.to_mnemonic(key_pair[0]) + check += 1 + else: + queue.put(key_pair) + #print("DONE", check, key_pair) + return key_pair + +def _start(start_words, obj): + done = False + q = Queue() + p = Process(target=find_vanity_mnemonic, args=[start_words, q]) + p.daemon = True + p.start() + rec = None + while not done: + try: + if rec == None: + rec = q.get(True, 1) + except: + rec = None + if rec != None or obj.done: + done = True + obj.done = True + obj.result = rec + return rec + +def handler(start_words: str): + obj = lambda test: None + obj.done = False + for x in range(multiprocessing.cpu_count()): + threading.Thread(target=_start, args=[start_words, obj]).start() + while not obj.done: + time.sleep(1) + return obj.result + + +def find_multiprocess(start_words: str): + start_words = start_words.strip() + start_words = re.sub(' +', ' ', start_words) + test_words = str(start_words) + + for word in test_words.split(' '): + for validword in wordlist: + if word == validword: + break + else: + raise ValueError('%s not in english bip39 wordlist' % (word,)) + return handler(start_words) + diff --git a/requirements.in b/requirements.in index 199b6c56..7bbb9f7a 100644 --- a/requirements.in +++ b/requirements.in @@ -11,4 +11,3 @@ streamedrequests==1.0.0 jinja2==2.10.1 toomanyobjs==1.1.0 mnemonic==0.18 -vanityonionr==0.0.0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6e42f8e8..ca9ed0a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -185,8 +185,6 @@ unpaddedbase32==0.1.0 \ urllib3==1.24.2 \ --hash=sha256:4c291ca23bbb55c76518905869ef34bdd5f0e46af7afe6861e8375643ffee1a0 \ --hash=sha256:9a247273df709c4fedb38c711e44292304f73f39ab01beda9f6b9fc375669ac3 -vanityonionr==0.0.0 \ - --hash=sha256:a61976c62363f05cc9f92e57c2c2deaad7753abc9e5d3ee9ad5745330b8d942e werkzeug==0.15.5 \ --hash=sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4 \ --hash=sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6 \