From de94bf2247cc19712c90fe0798cf86d86b1bf75b Mon Sep 17 00:00:00 2001 From: mruddy Date: Thu, 9 Feb 2017 08:25:32 -0500 Subject: [PATCH] load_device_by_mnemonic: normalize mnemonic before validation (#95) --- trezorlib/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/trezorlib/client.py b/trezorlib/client.py index e14c98074..b89059d5b 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -859,16 +859,16 @@ class ProtocolMixin(object): @field('message') @expect(proto.Success) def load_device_by_mnemonic(self, mnemonic, pin, passphrase_protection, label, language, skip_checksum=False): - m = Mnemonic('english') - if not skip_checksum and not m.check(mnemonic): - raise Exception("Invalid mnemonic checksum") - # Convert mnemonic to UTF8 NKFD mnemonic = Mnemonic.normalize_string(mnemonic) # Convert mnemonic to ASCII stream mnemonic = normalize_nfc(mnemonic) + m = Mnemonic('english') + if not skip_checksum and not m.check(mnemonic): + raise Exception("Invalid mnemonic checksum") + if self.features.initialized: raise Exception("Device is initialized already. Call wipe_device() and try again.")