Skip to content

Commit

Permalink
v2.7.6 increase seed pool size. show seed pool while moving mouse. ad…
Browse files Browse the repository at this point in the history
…d textbox for keyboard entropy. do not generate address without human added entropy. browser fingerprint entropy added to seed pool starting in a random position. whole seed pool initialized with getRandomValues.
  • Loading branch information
pointbiz committed Jan 10, 2014
1 parent b100c39 commit 76704bf
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 57 deletions.
56 changes: 28 additions & 28 deletions bitaddress.org.html

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/bitaddress-ui.html

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions src/ninja.misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ ninja.seeder = {
// seed function exists to wait for mouse movement to add more entropy before generating an address
seed: function (evt) {
if (!evt) var evt = window.event;

// seed a bunch (minimum seedLimit) of times based on mouse moves
// seed a bunch (minimum seedLimit) of times
SecureRandom.seedTime();
// seed key press character
if (evt.which) {
SecureRandom.seedInt8(evt.which);
}
// seed mouse position X and Y
if (evt) SecureRandom.seedInt16((evt.clientX * evt.clientY));
else if (evt) {
SecureRandom.seedInt16((evt.clientX * evt.clientY));
}

ninja.seeder.seedCount++;
// seeding is over now we generate and display the address
Expand All @@ -24,23 +29,18 @@ ninja.seeder = {
document.getElementById("generate").style.display = "none";
document.getElementById("menu").style.visibility = "visible";
}
var poolHex;
if (SecureRandom.poolCopyOnInit != null) {
var poolHex = Crypto.util.bytesToHex(SecureRandom.poolCopyOnInit);
document.getElementById("seedpool").innerHTML = Crypto.util.bytesToHex(SecureRandom.poolCopyOnInit);
document.getElementById("seedpooldisplay").innerHTML = poolHex;
}
else {
document.getElementById("seedpool").innerHTML = Crypto.util.bytesToHex(SecureRandom.pool);
}
},

// If user has not moved the mouse or if they are on a mobile device
// we will force the generation after a random period of time.
forceGenerate: function () {
// if the mouse has not moved enough
if (ninja.seeder.seedCount < ninja.seeder.seedLimit) {
SecureRandom.seedTime();
ninja.seeder.seedCount = ninja.seeder.seedLimit - 1;
ninja.seeder.seed();
var poolHex = Crypto.util.bytesToHex(SecureRandom.pool);
document.getElementById("seedpool").innerHTML = poolHex;
document.getElementById("seedpooldisplay").innerHTML = poolHex;
}
document.getElementById("mousemovelimit").innerHTML = (ninja.seeder.seedLimit - ninja.seeder.seedCount);
}
};

Expand Down
5 changes: 1 addition & 4 deletions src/ninja.onload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,4 @@ if (ninja.getQueryString()["testnet"] == "true" || ninja.getQueryString()["testn
}
if (ninja.getQueryString()["showseedpool"] == "true" || ninja.getQueryString()["showseedpool"] == "1") {
document.getElementById("seedpoolarea").style.display = "block";

}
// if users does not move mouse after random amount of time then generate the key anyway.
setTimeout(ninja.seeder.forceGenerate, ninja.seeder.seedLimit * 100);
}
8 changes: 4 additions & 4 deletions src/securerandom.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// Pool size must be a multiple of 4 and greater than 32.
// An array of bytes the size of the pool will be passed to init()
sr.poolSize = 256;
sr.poolSize = 512;


// --- object methods ---
Expand Down Expand Up @@ -133,12 +133,12 @@
sr.pool = new Array();
sr.pptr = 0;
var t;
if (window.crypto && window.crypto.getRandomValues) {
if (window.crypto && window.crypto.getRandomValues && window.Uint8Array) {
try {
// Use webcrypto if available
var ua = new Uint8Array(32);
var ua = new Uint8Array(sr.poolSize);
window.crypto.getRandomValues(ua);
for (t = 0; t < 32; ++t)
for (t = 0; t < sr.poolSize; ++t)
sr.pool[sr.pptr++] = ua[t];
} catch (e) { alert(e); }
}
Expand Down

0 comments on commit 76704bf

Please sign in to comment.