]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - bip39-standalone.html
Phrase is normalized before checking for errors
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / bip39-standalone.html
index 41634c25763135747fbdf0295d455c6da315dbcc..6125ce3d1849bb3c83d42d39ec00d90715817f32 100644 (file)
@@ -22432,14 +22432,14 @@ var Mnemonic = function(language) {
 
     self.toSeed = function(mnemonic, passphrase) {
         passphrase = passphrase || '';
-        mnemonic = normalizeString(mnemonic)
-        passphrase = normalizeString(passphrase)
+        mnemonic = self.normalizeString(mnemonic)
+        passphrase = self.normalizeString(passphrase)
         passphrase = "mnemonic" + passphrase;
         //return PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations=PBKDF2_ROUNDS, macmodule=hmac, digestmodule=hashlib.sha512).read(64)
         return asmCrypto.PBKDF2_HMAC_SHA512.hex(mnemonic, passphrase, PBKDF2_ROUNDS, 512/8);
     }
 
-    function normalizeString(str) {
+    self.normalizeString = function(str) {
         if (typeof str.normalize == "function") {
             return str.normalize("NFKD");
         }
@@ -22900,6 +22900,7 @@ WORDLISTS = {
     function findPhraseErrors(phrase) {
         // TODO make this right
         // Preprocess the words
+        phrase = mnemonic.normalizeString(phrase);
         var parts = phrase.split(" ");
         var proper = [];
         for (var i=0; i<parts.length; i++) {