normalize passphrase
This commit is contained in:
parent
cba9a2dc2c
commit
1e4cdab096
|
@ -7,7 +7,6 @@ import PyQt4.QtCore as QtCore
|
||||||
|
|
||||||
import electrum
|
import electrum
|
||||||
from electrum.wallet import Wallet
|
from electrum.wallet import Wallet
|
||||||
from electrum.mnemonic import prepare_seed
|
|
||||||
from electrum.util import UserCancelled
|
from electrum.util import UserCancelled
|
||||||
from electrum.base_wizard import BaseWizard
|
from electrum.base_wizard import BaseWizard
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
|
|
|
@ -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):
|
def is_new_seed(x, prefix=version.SEED_PREFIX):
|
||||||
import mnemonic
|
import mnemonic
|
||||||
x = mnemonic.prepare_seed(x)
|
x = mnemonic.normalize_text(x)
|
||||||
s = hmac_sha_512("Seed version", x.encode('utf8')).encode('hex')
|
s = hmac_sha_512("Seed version", x.encode('utf8')).encode('hex')
|
||||||
return s.startswith(prefix)
|
return s.startswith(prefix)
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ def is_CJK(c):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def prepare_seed(seed):
|
def normalize_text(seed):
|
||||||
# normalize
|
# normalize
|
||||||
seed = unicodedata.normalize('NFKD', unicode(seed))
|
seed = unicodedata.normalize('NFKD', unicode(seed))
|
||||||
# lower
|
# lower
|
||||||
|
@ -126,7 +126,8 @@ class Mnemonic(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def mnemonic_to_seed(self, mnemonic, passphrase):
|
def mnemonic_to_seed(self, mnemonic, passphrase):
|
||||||
PBKDF2_ROUNDS = 2048
|
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)
|
return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
|
||||||
|
|
||||||
def mnemonic_encode(self, i):
|
def mnemonic_encode(self, i):
|
||||||
|
|
Loading…
Reference in New Issue