Comparing version 2.4.0 to 2.5.0
17
index.js
@@ -15,2 +15,3 @@ var Buffer = require('safe-buffer').Buffer | ||
var JAPANESE_WORDLIST = require('./wordlists/japanese.json') | ||
var KOREAN_WORDLIST = require('./wordlists/korean.json') | ||
var SPANISH_WORDLIST = require('./wordlists/spanish.json') | ||
@@ -93,13 +94,11 @@ var DEFAULT_WORDLIST = ENGLISH_WORDLIST | ||
function entropyToMnemonic (entropyHex, wordlist) { | ||
function entropyToMnemonic (entropy, wordlist) { | ||
if (!Buffer.isBuffer(entropy)) entropy = Buffer.from(entropy, 'hex') | ||
wordlist = wordlist || DEFAULT_WORDLIST | ||
// 128 <= ENT <= 256 | ||
if (entropyHex.length < 32) throw new TypeError(INVALID_ENTROPY) | ||
if (entropyHex.length > 64) throw new TypeError(INVALID_ENTROPY) | ||
if (entropy.length < 16) throw new TypeError(INVALID_ENTROPY) | ||
if (entropy.length > 32) throw new TypeError(INVALID_ENTROPY) | ||
if (entropy.length % 4 !== 0) throw new TypeError(INVALID_ENTROPY) | ||
// multiple of 4 | ||
if (entropyHex.length % 8 !== 0) throw new TypeError(INVALID_ENTROPY) | ||
var entropy = Buffer.from(entropyHex, 'hex') | ||
var entropyBits = bytesToBinary([].slice.call(entropy)) | ||
@@ -123,4 +122,3 @@ var checksumBits = deriveChecksumBits(entropy) | ||
var hex = rng(strength / 8).toString('hex') | ||
return entropyToMnemonic(hex, wordlist) | ||
return entropyToMnemonic(rng(strength / 8), wordlist) | ||
} | ||
@@ -155,4 +153,5 @@ | ||
japanese: JAPANESE_WORDLIST, | ||
korean: KOREAN_WORDLIST, | ||
spanish: SPANISH_WORDLIST | ||
} | ||
} |
{ | ||
"name": "bip39", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Bitcoin BIP39: Mnemonic code for generating deterministic keys", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -46,7 +46,7 @@ # BIP39 | ||
var mnemonic = bip39.entropyToMnemonic('00000000000000000000000000000000') | ||
// => zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong | ||
// => abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about | ||
// reversible | ||
bip39.mnemonicToEntropy(mnemonic) | ||
// => '133755ff' | ||
// => '00000000000000000000000000000000' | ||
``` |
@@ -13,3 +13,4 @@ var fetch = require('node-fetch') | ||
'japanese', | ||
'spanish' | ||
'spanish', | ||
'korean' | ||
] | ||
@@ -16,0 +17,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
288580
19030