From 1e4cdab096210ac0b8ebef1547c6d850ccc00d26 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 2 Sep 2016 10:20:04 +0200 Subject: [PATCH] normalize passphrase --- gui/qt/installwizard.py | 1 - lib/bitcoin.py | 2 +- lib/mnemonic.py | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py index 199bb0fb0..4ba2c6b56 100644 --- a/gui/qt/installwizard.py +++ b/gui/qt/installwizard.py @@ -7,7 +7,6 @@ import PyQt4.QtCore as QtCore import electrum from electrum.wallet import Wallet -from electrum.mnemonic import prepare_seed from electrum.util import UserCancelled from electrum.base_wizard import BaseWizard from electrum.i18n import _ diff --git a/lib/bitcoin.py b/lib/bitcoin.py index 81875a6e3..44094da1e 100644 --- a/lib/bitcoin.py +++ b/lib/bitcoin.py @@ -160,7 +160,7 @@ hmac_sha_512 = lambda x,y: hmac.new(x, y, hashlib.sha512).digest() def is_new_seed(x, prefix=version.SEED_PREFIX): import mnemonic - x = mnemonic.prepare_seed(x) + x = mnemonic.normalize_text(x) s = hmac_sha_512("Seed version", x.encode('utf8')).encode('hex') return s.startswith(prefix) diff --git a/lib/mnemonic.py b/lib/mnemonic.py index 6ebc7870f..4ead59ba6 100644 --- a/lib/mnemonic.py +++ b/lib/mnemonic.py @@ -78,7 +78,7 @@ def is_CJK(c): return False -def prepare_seed(seed): +def normalize_text(seed): # normalize seed = unicodedata.normalize('NFKD', unicode(seed)) # lower @@ -126,7 +126,8 @@ class Mnemonic(object): @classmethod def mnemonic_to_seed(self, mnemonic, passphrase): PBKDF2_ROUNDS = 2048 - mnemonic = prepare_seed(mnemonic) + mnemonic = normalize_text(mnemonic) + passphrase = normalize_text(passphrase) return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64) def mnemonic_encode(self, i):