diff options
author | Ian Coleman <ian@iancoleman.io> | 2019-11-11 10:31:14 +1100 |
---|---|---|
committer | Ian Coleman <ian@iancoleman.io> | 2019-11-11 10:31:14 +1100 |
commit | 700294714c39cb6e8226b960671a33dc93362edc (patch) | |
tree | ccd935208aed75efa1de3798d3a83e68157139e7 /src | |
parent | d93f2ba9f074464f5e20f9711563ff08e3eb19a6 (diff) | |
download | BIP39-700294714c39cb6e8226b960671a33dc93362edc.tar.gz BIP39-700294714c39cb6e8226b960671a33dc93362edc.tar.zst BIP39-700294714c39cb6e8226b960671a33dc93362edc.zip |
Raw entropy is interpreted as binary
For example, using abandon abandon ability becomes 8 zeros but how does
the entropy field know it's hex and not binary? It assumes the
worst-case scenario of binary, so entropy should be shown in binary.
Perhaps if entropy type is explicitly selected in the future this can be
changed back to using hex. But while magical assumptions exist, binary
it must be.
Diffstat (limited to 'src')
-rw-r--r-- | src/js/index.js | 2 | ||||
-rw-r--r-- | src/js/jsbip39.js | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/js/index.js b/src/js/index.js index 472d392..8caa0ed 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -240,7 +240,7 @@ | |||
240 | } | 240 | } |
241 | phraseChangeTimeoutEvent = setTimeout(function() { | 241 | phraseChangeTimeoutEvent = setTimeout(function() { |
242 | phraseChanged(); | 242 | phraseChanged(); |
243 | var entropy = mnemonic.toRawEntropyHex(DOM.phrase.val()); | 243 | var entropy = mnemonic.toRawEntropyBin(DOM.phrase.val()); |
244 | if (entropy !== null) { | 244 | if (entropy !== null) { |
245 | DOM.entropyMnemonicLength.val("raw"); | 245 | DOM.entropyMnemonicLength.val("raw"); |
246 | DOM.entropy.val(entropy); | 246 | DOM.entropy.val(entropy); |
diff --git a/src/js/jsbip39.js b/src/js/jsbip39.js index 9a6e7ec..1e52d9d 100644 --- a/src/js/jsbip39.js +++ b/src/js/jsbip39.js | |||
@@ -130,6 +130,12 @@ var Mnemonic = function(language) { | |||
130 | return h; | 130 | return h; |
131 | } | 131 | } |
132 | 132 | ||
133 | self.toRawEntropyBin = function(mnemonic) { | ||
134 | var b = mnemonicToBinaryString(mnemonic); | ||
135 | var d = b.substring(0, b.length / 33 * 32); | ||
136 | return d; | ||
137 | } | ||
138 | |||
133 | self.toSeed = function(mnemonic, passphrase) { | 139 | self.toSeed = function(mnemonic, passphrase) { |
134 | passphrase = passphrase || ''; | 140 | passphrase = passphrase || ''; |
135 | mnemonic = self.joinWords(self.splitWords(mnemonic)); // removes duplicate blanks | 141 | mnemonic = self.joinWords(self.splitWords(mnemonic)); // removes duplicate blanks |