1
0

Passphrase-related fixes

Move normalize code to one place on the wallet
Passphrases don't have password strength meter
This commit is contained in:
Neil Booth
2016-01-03 09:03:07 +09:00
parent 4fe01cb8d3
commit f3e6bf0280
4 changed files with 16 additions and 12 deletions

View File

@@ -1738,13 +1738,17 @@ class BIP44_Wallet(BIP32_HD_Wallet):
acc_id, (change, address_index) = self.get_address_index(address)
return self.address_derivation(acc_id, change, address_index)
@staticmethod
def normalize_passphrase(passphrase):
return normalize('NFKD', unicode(passphrase or ''))
@staticmethod
def mnemonic_to_seed(mnemonic, passphrase):
# See BIP39
import pbkdf2, hashlib, hmac
PBKDF2_ROUNDS = 2048
mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
passphrase = normalize('NFKD', passphrase)
passphrase = BIP44_Wallet.normalize_passphrase(passphrase)
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase,
iterations = PBKDF2_ROUNDS, macmodule = hmac,
digestmodule = hashlib.sha512).read(64)