Browse Source

remove double iteration of words

300
Daniel Cousens 8 years ago
parent
commit
3854893382
  1. 5
      index.js

5
index.js

@ -40,13 +40,12 @@ function mnemonicToEntropy (mnemonic, wordlist) {
var words = unorm.nfkd(mnemonic).split(' ')
if (words.length % 3 !== 0) throw new Error(INVALID_MNEMONIC)
if (words.some(function (word) {
return wordlist.indexOf(word) === -1
})) throw new Error(INVALID_MNEMONIC)
// convert word indices to 11 bit binary strings
var bits = words.map(function (word) {
var index = wordlist.indexOf(word)
if (index === -1) throw new Error(INVALID_MNEMONIC)
return lpad(index.toString(2), '0', 11)
}).join('')

Loading…
Cancel
Save