From 31c370426489fa8fc0fc0d29975ce4c8c72af471 Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Tue, 12 Jan 2016 18:29:05 -0800 Subject: [PATCH] IT WORKS! --- index.js | 18 +++++++++++++----- package.json | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 7019860..d79c57b 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ var sjclRandom = new sjcl.prng(10); var explicitReq = require; var RNRandomBytes = explicitReq('react-native').NativeModules.RNRandomBytes; -module.exports.randomBytes = function(length, cb) { +var randomBytes = function(length, cb) { if (!cb) { var size = length; @@ -30,7 +30,15 @@ module.exports.randomBytes = function(length, cb) { }; -module.exports.randomBytes(4096, function(err, buffer) { - var hexString = buffer.toString('hex'); - sjclRandom.addEntropy(hexString, 10, 'csprng'); -}); +var seedStanford = function(){ + randomBytes(4096, function(err, buffer){ + var hexString = buffer.toString('hex'); + var stanfordSeed = sjcl.codec.hex.toBits(hexString); + sjclRandom.addEntropy(stanfordSeed); + }); +}; + +module.exports = { + randomBytes: randomBytes, + seedStanford: seedStanford +}; diff --git a/package.json b/package.json index 7913213..687d0ff 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "babelify": "mkdir -p browser && ./node_modules/.bin/browserify --exclude react-native -t [ babelify --presets [ react es2015 ] ] ./index.js | sed -e 's/require/bitgoReq/g' | sed -e 's/explicitReq(/require(/g' > ./browser/react_index.js" + "babelify": "mkdir -p browser && ./node_modules/.bin/browserify --exclude react-native -t [ babelify --presets [ react es2015 ] ] -s BitGoRandomBytes ./index.js | sed -e 's/require/bitgoReq/g' | sed -e 's/explicitReq(/require(/g' > ./browser/react_index.js" }, "keywords": [ "react-component",