Skip to content

Commit

Permalink
Merge pull request #131 from aleksessex/master
Browse files Browse the repository at this point in the history
Fix bias in voting booth random number generator
  • Loading branch information
benadida committed May 16, 2016
2 parents 8e023ee + c8bde31 commit 67adf33
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion heliosbooth/js/jscrypto/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Random.getRandomInteger = function(max) {
var bit_length = max.bitLength();
Random.setupGenerator();
var random;
random = sjcl.random.randomWords(bit_length / 32, 0);
random = sjcl.random.randomWords(Math.ceil(bit_length / 32)+2, 0);
// we get a bit array instead of a BigInteger in this case
var rand_bi = new BigInt(sjcl.codec.hex.fromBits(random), 16);
return rand_bi.mod(max);
Expand Down

0 comments on commit 67adf33

Please sign in to comment.