Browse Source

normalize passphrase

283
ThomasV 8 years ago
parent
commit
1e4cdab096
  1. 1
      gui/qt/installwizard.py
  2. 2
      lib/bitcoin.py
  3. 5
      lib/mnemonic.py

1
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 _

2
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)

5
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):

Loading…
Cancel
Save