Merge pull request #6 from bip32JP/addmouse
Capture mouse movements for extra entropy
This commit is contained in:
commit
18b27cdb34
3 changed files with 30 additions and 2 deletions
|
@ -643,5 +643,6 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- qrcode modal -->
|
<!-- qrcode modal -->
|
||||||
|
|
||||||
|
<div class="hidden" id="entropybucket"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -54,9 +54,10 @@
|
||||||
var dateObj = new Date();
|
var dateObj = new Date();
|
||||||
x += dateObj.getTimezoneOffset();
|
x += dateObj.getTimezoneOffset();
|
||||||
x += coinjs.random(64);
|
x += coinjs.random(64);
|
||||||
|
x += $("#entropybucket").html();
|
||||||
x += x+''+x;
|
x += x+''+x;
|
||||||
var r = x;
|
var r = x;
|
||||||
for(i=0;i<(x).length/16;i++){
|
for(i=0;i<(x).length/25;i++){
|
||||||
r = Crypto.SHA256(r.concat(x));
|
r = Crypto.SHA256(r.concat(x));
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -813,4 +813,30 @@ $(document).ready(function() {
|
||||||
$("#newKeysBtn").click();
|
$("#newKeysBtn").click();
|
||||||
|
|
||||||
validateOutputAmount();
|
validateOutputAmount();
|
||||||
|
|
||||||
|
/* capture mouse movement to add entropy */
|
||||||
|
var IE = document.all?true:false // Boolean, is browser IE?
|
||||||
|
if (!IE) document.captureEvents(Event.MOUSEMOVE)
|
||||||
|
document.onmousemove = getMouseXY;
|
||||||
|
function getMouseXY(e) {
|
||||||
|
var tempX = 0;
|
||||||
|
var tempY = 0;
|
||||||
|
if (IE) { // If browser is IE
|
||||||
|
tempX = event.clientX + document.body.scrollLeft;
|
||||||
|
tempY = event.clientY + document.body.scrollTop;
|
||||||
|
} else {
|
||||||
|
tempX = e.pageX;
|
||||||
|
tempY = e.pageY;
|
||||||
|
};
|
||||||
|
if (tempX < 0){tempX = 0};
|
||||||
|
if (tempY < 0){tempY = 0};
|
||||||
|
var xEnt = Crypto.util.bytesToHex([tempX]);
|
||||||
|
var yEnt = Crypto.util.bytesToHex([tempY]);
|
||||||
|
var addEnt = xEnt.concat(yEnt);
|
||||||
|
if ($("#entropybucket").html().indexOf(xEnt) == -1 && $("#entropybucket").html().indexOf(yEnt) == -1) {
|
||||||
|
$("#entropybucket").html(addEnt + $("#entropybucket").html());
|
||||||
|
};
|
||||||
|
if ($("#entropybucket").html().length > 128) {$("#entropybucket").html($("#entropybucket").html().slice(0, 128))};
|
||||||
|
return true;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue