From 98ff2ac316d86c8a291e4260d7bcc3034921dc75 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sat, 6 Sep 2014 00:49:28 +1000 Subject: [PATCH 1/2] index: use pbkdf2-compat instead of cryptojs --- index.js | 10 +++++++--- package.json | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index a742002..4c0da31 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,15 @@ var assert = require('assert') -var CryptoJS = require('crypto-js') var crypto = require('crypto') +var pbkdf2 = require('pbkdf2-compat') var DEFAULT_WORDLIST = require('./wordlists/en.json') +function mnemonicToSeed(mnemonic, password) { + return pbkdf2(mnemonic, salt(password), 2048, 64, 'sha512') +} + function mnemonicToSeedHex(mnemonic, password) { - var options = { iterations: 2048, hasher: CryptoJS.algo.SHA512, keySize: 512/32 } - return CryptoJS.PBKDF2(mnemonic, salt(password), options).toString(CryptoJS.enc.Hex) + return mnemonicToSeed(mnemonic, password).toString('hex') } function mnemonicToEntropy(mnemonic, wordlist) { @@ -113,6 +116,7 @@ function lpad(str, padString, length) { } module.exports = { + mnemonicToSeed: mnemonicToSeed, mnemonicToSeedHex: mnemonicToSeedHex, mnemonicToEntropy: mnemonicToEntropy, entropyToMnemonic: entropyToMnemonic, diff --git a/package.json b/package.json index 38c9ebd..d733547 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ }, "license": "ISC", "dependencies": { - "crypto-js": "^3.1.2-2", - "sinon": "^1.10.3" + "sinon": "^1.10.3", + "pbkdf2-compat": "^1.0.1" }, "devDependencies": { "browserify": "^5.9.1", From 46bc463637f20aae5b735e79b0e3d45c898bdcd1 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 22 Sep 2014 18:15:27 +1000 Subject: [PATCH 2/2] package: move sinon to dev dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d733547..6576857 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,11 @@ }, "license": "ISC", "dependencies": { - "sinon": "^1.10.3", "pbkdf2-compat": "^1.0.1" }, "devDependencies": { "browserify": "^5.9.1", - "mocha": "^1.17.1" + "mocha": "^1.17.1", + "sinon": "^1.10.3" } }