diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2016-11-30 19:38:14 +1100 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2016-11-30 19:43:14 +1100 |
commit | fc7c248fafef4ba2aecf9dcf4718b3d4c91d94b0 (patch) | |
tree | c510a9cc73a4161d5b8feaf872bcbdfe41c272ea /src | |
parent | 94959756408aa60be4118ab1dceff4e71c6afdbf (diff) | |
download | BIP39-fc7c248fafef4ba2aecf9dcf4718b3d4c91d94b0.tar.gz BIP39-fc7c248fafef4ba2aecf9dcf4718b3d4c91d94b0.tar.zst BIP39-fc7c248fafef4ba2aecf9dcf4718b3d4c91d94b0.zip |
Entropy with more than 4 decks can be calculated
Diffstat (limited to 'src')
-rw-r--r-- | src/js/entropy.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/js/entropy.js b/src/js/entropy.js index b7274bb..24fc21a 100644 --- a/src/js/entropy.js +++ b/src/js/entropy.js | |||
@@ -263,7 +263,12 @@ window.Entropy = new (function() { | |||
263 | } | 263 | } |
264 | // Work out the total number of bits for this many decks | 264 | // Work out the total number of bits for this many decks |
265 | // See http://crypto.stackexchange.com/q/41886 | 265 | // See http://crypto.stackexchange.com/q/41886 |
266 | var gainedBits = Math.log2(factorial(52 * numberOfDecks)); | 266 | var gainedBits = 0; |
267 | // Equivalent of Math.log2(factorial(52*numberOfDecks)) | ||
268 | // which becomes infinity for numberOfDecks > 4 | ||
269 | for (var i=1; i<=52*numberOfDecks; i++) { | ||
270 | gainedBits = gainedBits + Math.log2(i); | ||
271 | } | ||
267 | var lostBits = 52 * Math.log2(factorial(numberOfDecks)); | 272 | var lostBits = 52 * Math.log2(factorial(numberOfDecks)); |
268 | var maxBits = gainedBits - lostBits; | 273 | var maxBits = gainedBits - lostBits; |
269 | // Convert the drawn cards to a binary representation. | 274 | // Convert the drawn cards to a binary representation. |