mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-27 12:50:42 +00:00
Multiple decks of cards are possible
but also a needless oversupply of entropy
This commit is contained in:
+7
-3
@@ -846,9 +846,13 @@
|
||||
// eg the second last card can be only one of two, not one of fifty two
|
||||
// so the added entropy for that card is only one bit at most
|
||||
if (entropy.base.asInt == 52) {
|
||||
var totalCombos = factorial(52);
|
||||
var remainingCards = 52 - entropy.base.parts.length;
|
||||
var remainingCombos = factorial(remainingCards);
|
||||
var totalDecks = Math.ceil(entropy.base.parts.length / 52);
|
||||
var totalCards = totalDecks * 52;
|
||||
var totalCombos = factorial(52).pow(totalDecks);
|
||||
var totalRemainingCards = totalCards - entropy.base.parts.length;
|
||||
var remainingDecks = Math.floor(totalRemainingCards / 52);
|
||||
var remainingCards = totalRemainingCards % 52;
|
||||
var remainingCombos = factorial(52).pow(remainingDecks) * factorial(remainingCards);
|
||||
var currentCombos = totalCombos.divide(remainingCombos);
|
||||
bitsStr = currentCombos.toString(2).length.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user