Provably Fair Shuffling Through Cryptography (2012)
techblog.bitzino.com
techblog.bitzino.com
MT is really, really bad. We don't see it too much in the real world, but it's so easy to attack that we have several attacks on it in our crypto challenges.
seed = SHA256(client_seed + server_seed) % 2 ^ 32
I _think_ to attack this you would need to do two seemingly difficult things. 1) come up with a seed which generates a sequence from the prng which allows a shuffle to create a favourable-to-you deck - this might be doable given my very quick reading of MT's weaknesses. But then you need to do 2) create a server_seed such that PRNGseed = SHA256(client_seed + server_seed) % 2 ^ 32. I suspect that's "hard". (I don't know if SHA256 is vulnerable to extension attacks the way MD5 is - I don't _thin_ so, but even if it were, some simple "plausibility checks" on the alleged server_seed would protect against that.)
I guess there's a problem if the client_seed ad server_seed ever get re-used - but that's a common crypto in-use issure, right? Just don't do that...
I still think this works though. Unless there is a way for them to chose a server_seed such that:
SHA256(server_seed + client_seed) % 2 ^ 32 = PRNG_seed(favourable to them)
without my choice of client_seed messing up their desired PRNG_seed.
They note they're actually reshuffling, not just cutting the deck, but even then there are only 2^32 possible seeds and thus 2^32 possible reshuffles. What's stopping them from pregenerating server seeds that are biased in their favor? Maybe using MT makes that even easier.
https://github.com/ryancdotorg/libtprpg (do note the disclaimer in the README)
It's particularly good for blackjack using multiple decks (that implementation should be able to generate all possible permutations of up to four decks, not that the universe will exist long enough to do it) because it requires no computation ahead of time, only when cards are dealt.
I got the idea from this article:
http://blog.notdot.net/2007/9/Damn-Cool-Algorithms-Part-2-Se...
see also
which i guess is fair enough, but i was expecting some kind of homomorphic solution and/or a zero knowledge proof.
anyone have a solution that meets my finicky expectations?
However this seems to be an impractical as this requires an astronomical amount of effort - the server would need to run through all 2^32 shuffles from the deck they pick just to see if that deck was favourable. This would be exceedingly rare, so a vast number of shuffles must be tested in this manner.
The game is "Black or red," where the top card of the deck is revealed. If it is black (clubs or spades), you win. If it is red (hearts or diamonds), the casino wins. The casino can cheat as follows: It generates all 2^32 possible Mersenne "cuts" of the deck. Then it finds those card positions which, through random chance, are shuffled to the top slightly more often by the Mersenne cut process. Then it chooses a deck to reveal as the "shuffled" deck at the beginning with a disproportionately large number of red cards in those locations. Since they will get cut to the top more than 50% of the time, the casino can do more than break even.
The law of large numbers and the fact that MT19937 is a decent PRNG that passes an awful lot of randomness tests says that the chance of each position being "cut" to the top is almost exactly 1/52. So the casino isn't going to do much better than 50% on this game. But the Mersenne twister isn't cryptographically secure at all, you can imagine a casino coming up with a better game that does better than this one at taking advantage of MT-generated permutations.