Argh, what an awful moment to get an "Keypool ran out, please call keypoolrefill first" error, just when this thread receives a free bump!
![Cheesy](https://bitcointalk.org/Smileys/default/cheesy.gif)
. The immediate internet search turned an answer
here. Man, you're useful!
I just increased the box size from 35 to 40, which should be more than enough.
That's funny. I'm the #1 google search result for all your problems.
![Wink](https://bitcointalk.org/Smileys/default/wink.gif)
The box still isn't big enough for my address (showing that I see '40' in the source, but the address still doesn't fit):
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FphylitE.png&t=665&c=nfT9qBWoOJ9TWw)
Also, I keep winning. I played 9 times today (6 cards, A-A) and won every time!
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FxKxzQnU.png&t=665&c=chn0GUFLKeKCvw)
I wrote a little Perl script that checks the provable-fairness, and that's working just fine:
$ ./flipside.pl 3034b72d15372924cae59e98246b51e2317b9b642098a800f5e717d40ccda133b5c6cdec18e3799 ec45e1f5cd7396dcc alfalfa a7452eb9e658a373 d7e4f97a
AS>KC AD>KS AH>KC AC>QH AH>JC AC>9D WIN
$ ./flipside.pl c79ffa2cad920454aa51b8d7dd5068639df15c93102f88538de1953c0c4ddc5f411f8a9db957b98 add061b0000bc6037 clover 0a3b638c167c5759 754d67aa
AC>JD AC>JS AD>7H AC>TC AD>8S AC>JS WIN
$ ./flipside.pl 807c2dd88c4ca17e590536e793eeaa058e79796248dc3375fb7eabf6027d07f2210bc9cc764f96c 9aa333263f6edff0a dlkfjj2 3c9c725fd154f748 704e1ce3
AD>JC AD>JD AS>QD AS>KH AD=AD AC>9S WIN
$ ./flipside.pl 61eaba331654114d9ac4c50e68efa2a10e6e2c3013d8aba6e8d11140a7dd58139b9c48af590895f deeef8fab100b988e ludicr2 08dc4f54e1a72263 b9b63aed
AS>TC AH>7D AH>7H AH>8H AS>8C AS>TH WIN
$ ./flipside.pl c6d9c0ca63bcd4c9e808e51dbeeb7c0194b82a7aed279e4a00f4335878e3ca05bc4029a392b4489 662975f6ec57cb3ec game1of5 afe9f5476316bec4 2ac62a0b
AH>8C AH>AD AS>7D AS>8D AC>8H AS>TS WIN
$ ./flipside.pl 6a33e186d1463a354fcf3ed54012cb54e7dc0cd63088672cb1bbf78eefea749b809b5bec666a6dd 13621d76ea2034e79 game2of5 9af52677ad635a78 2ac62a0b
AS>7S AH>KH AH>9H AC=AC AD>7S AD>JS WIN
$ ./flipside.pl 90b1c7b05a34243ef14c2191973e9b1801125ab099d2eda203a1b22bd916deb23832ab05142d71f 8433b75210315d7c0 game3of5 8926654fd3e814d8 c48ea4c5
AH>9S AD>QH AD>TD AH>TC AC>7C AH>AD WIN
$ ./flipside.pl 8e43ef657fd42b5bed18ce21015a4943b36053208360222ff19284c835a8493547eeac2d810033a 10db6e9cc378fc8f3 game4of5 14130a1f2df82ffd c48ea4c5
AH>QC AD>QS AC>TD AH>7H AH>KD AC>KC WIN
$ ./flipside.pl f8b69620ddeae0e1d155be8ebdbee2e5e8b2a211a6717e513824f7cd11a073379025ee89c731353 8aec0c3553237b96e game5of5 13aae71f33fc991d c48ea4c5
AD>KS AC>QS AH>8C AH>TS AH>TH AS>KC WIN
The script is pretty bad - I've forgotten most of the Perl I ever knew, so I'm using backticks to invoke subshells, etc. But it does the job:
#!/usr/bin/perl
use Math::Random::ISAAC;
die "usage: flipside.ph <hash> <client> <secret> <block>" if @ARGV != 4;
sub card {
my ($n) = @_;
my $ranks = '789TJQKA';
my $suits = 'CDHS';
my $rank = substr($ranks, int($n / 4), 1);
my $suit = substr($suits, $n % 4, 1);
return "$rank$suit";
}
($hash, $client, $secret, $block) = @ARGV;
die "hashes don't match\n" if `echo -n $secret | sha384sum | cut -d' ' -f1` ne "$hash\n";
$block = eval("0x" . substr($block, -8));
$concat = $secret . $client;
$secret = eval("0x" . substr($secret, -8));
$xor = ($block ^ $secret) & (0x3fffffff);
# print "concat: $concat\n";
$seed = '0x' . `echo -n $concat | sha384sum | cut -c1-8`;
# print "seed: $seed\n";
$seed = eval $seed;
my $rng = Math::Random::ISAAC->new($seed);
$count = 0;
$result = 'WIN';
while (1) {
$r = ($rng->irand()) & 31;
if ($r > 27) {
$mine = $r;
$his = ($xor >> 5*5) & 31;
print card($mine);
if ($his > $mine) {
$result = 'LOSE';
print '<';
} elsif ($his == $mine) {
print '=';
} else {
print '>';
}
print card($his) . " ";
$xor *= 32;
$count++;
last if $count == 6;
}
}
print " $result\n";