mirror of
https://github.com/status-im/bip39.git
synced 2025-02-11 03:56:39 +00:00
remove double iteration of words
This commit is contained in:
parent
dcf3c1be98
commit
3854893382
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…
x
Reference in New Issue
Block a user