moved to niceware from mnemonic

master
Kevin Froman 2019-09-29 20:55:59 -05:00
parent 86ae8327c3
commit 48e956c27c
7 changed files with 14 additions and 18 deletions

View File

@ -30,7 +30,7 @@ soft-reset:
reset: reset:
@echo "Hard-resetting Onionr..." @echo "Hard-resetting Onionr..."
rm -rf onionr/$(ONIONR_HOME)/ | true > /dev/null 2>&1 rm -rf $(ONIONR_HOME)/ | true > /dev/null 2>&1
cd onionr/static-data/www/ui/; rm -rf ./dist; python compile.py cd onionr/static-data/www/ui/; rm -rf ./dist; python compile.py
#@./onionr.sh version | grep -v "Failed" --color=always #@./onionr.sh version | grep -v "Failed" --color=always

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
ORIG_ONIONR_RUN_DIR=`pwd` ORIG_ONIONR_RUN_DIR=`pwd`
cd "$(dirname "$0")" cd "$(dirname "$0")"
cd onionr/ cd onionr
./__init__.py "$@" ./__init__.py "$@"

View File

@ -19,7 +19,7 @@
''' '''
import base64 import base64
import mnemonic import niceware
import unpaddedbase32 import unpaddedbase32
import onionrcrypto import onionrcrypto
@ -27,8 +27,6 @@ from etc import onionrvalues
DELIMITER = '-' DELIMITER = '-'
m = mnemonic.Mnemonic('english')
def get_human_readable_ID(pub=''): def get_human_readable_ID(pub=''):
'''gets a human readable ID from a public key''' '''gets a human readable ID from a public key'''
if pub == '': if pub == '':
@ -37,8 +35,9 @@ def get_human_readable_ID(pub=''):
if not len(pub) == onionrvalues.MAIN_PUBLIC_KEY_SIZE: if not len(pub) == onionrvalues.MAIN_PUBLIC_KEY_SIZE:
pub = base64.b32decode(pub) pub = base64.b32decode(pub)
return m.to_mnemonic(pub).replace(' ', DELIMITER) return DELIMITER.join(niceware.bytes_to_passphrase(pub))
#return niceware.bytes_to_passphrase(pub).replace(' ', DELIMITER)
def get_base32(words): def get_base32(words):
'''converts mnemonic to base32''' '''converts mnemonic to base32'''
return unpaddedbase32.b32encode(m.to_entropy(words.replace(DELIMITER, ' '))) return unpaddedbase32.b32encode(niceware.passphrase_to_bytes(words.replace(DELIMITER, ' ')))

View File

@ -21,7 +21,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import mnemonic import niceware
import nacl.signing, nacl.encoding import nacl.signing, nacl.encoding
import multiprocessing import multiprocessing
@ -29,8 +29,7 @@ from multiprocessing import Process, Pipe, Queue
import re, time import re, time
import threading import threading
m = mnemonic.Mnemonic("english") wordlist = niceware.WORD_LIST
wordlist = m.wordlist
def find_vanity_mnemonic(start_words: str, queue): def find_vanity_mnemonic(start_words: str, queue):
@ -41,7 +40,7 @@ def find_vanity_mnemonic(start_words: str, queue):
key = nacl.signing.SigningKey.generate() key = nacl.signing.SigningKey.generate()
key_pair[1] = key.encode(nacl.encoding.RawEncoder) key_pair[1] = key.encode(nacl.encoding.RawEncoder)
key_pair[0] = key.verify_key.encode(encoder=nacl.encoding.RawEncoder) key_pair[0] = key.verify_key.encode(encoder=nacl.encoding.RawEncoder)
vanity_key = m.to_mnemonic(key_pair[0]) vanity_key = niceware.bytes_to_passphrasec(key_pair[0])
check += 1 check += 1
else: else:
queue.put(key_pair) queue.put(key_pair)

View File

@ -10,4 +10,4 @@ unpaddedbase32==0.1.0
streamedrequests==1.0.0 streamedrequests==1.0.0
jinja2==2.10.1 jinja2==2.10.1
toomanyobjs==1.1.0 toomanyobjs==1.1.0
mnemonic==0.18 niceware==0.2.1

View File

@ -137,11 +137,9 @@ markupsafe==1.1.1 \
--hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \ --hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \
--hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \ --hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \
# via jinja2 # via jinja2
mnemonic==0.18 \ niceware==0.2.1 \
--hash=sha256:02a7306a792370f4a0c106c2cf1ce5a0c84b9dbd7e71c6792fdb9ad88a727f1d --hash=sha256:0f8b192f2a1e800e068474f6e208be9c7e2857664b33a96f4045340de4e5c69c \
pbkdf2==1.3 \ --hash=sha256:cf2dc0e1567d36d067c61b32fed0f1b9c4534ed511f9eeead4ba548d03b5c9eb
--hash=sha256:ac6397369f128212c43064a2b4878038dab78dab41875364554aaf2a684e6979 \
# via mnemonic
pycparser==2.19 \ pycparser==2.19 \
--hash=sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3 \ --hash=sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3 \
# via cffi # via cffi

View File

@ -51,7 +51,7 @@ class OnionrCryptoTests(unittest.TestCase):
def test_human_readable_length(self): def test_human_readable_length(self):
human = mnemonickeys.get_human_readable_ID() human = mnemonickeys.get_human_readable_ID()
self.assertTrue(len(human.split('-')) == 24) self.assertTrue(len(human.split('-')) == 16)
def test_safe_compare(self): def test_safe_compare(self):
self.assertTrue(crypto.cryptoutils.safe_compare('test', 'test')) self.assertTrue(crypto.cryptoutils.safe_compare('test', 'test'))