Skip to content
Snippets Groups Projects
Commit 67adf338 authored by Ben Adida's avatar Ben Adida
Browse files

Merge pull request #131 from aleksessex/master

Fix bias in voting booth random number generator
parents 8e023ee8 c8bde318
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment