Author

Topic: FlipSide - Prizes almost 5 million times your bet! (Read 5036 times)

legendary
Activity: 1578
Merit: 1000
May the coin be with you..
What a great game!

Had two goes at it. 1 win and 1 Loss but fun nethertheless. Congrats on making such a fun game and best of luck hope it takes off for you
sr. member
Activity: 294
Merit: 250
This looks pretty cool. I haven't tried it out myself but I see this being a really fun game.

Good luck on it. I plan to try this out shortly. Keep developing games! Don't stop.
hero member
Activity: 640
Merit: 771
BTC⇆⚡⇄BTC
I just won a game but wasn't paid out.  The payment transaction is "oops..." Smiley

Hey this provable fairness stuff isn't actually fair! I was expected to earn coins with this, not lose them! Cheesy

Code:
$ bitcoind getbalance
0.34425772

I'm sending some funds to the wallet as I type this.

Edit: done!

Nice original game!

BTW, would you mind adding a table with the odds involved in the game on that site?

Cheers!
legendary
Activity: 1974
Merit: 1029
Thanks for the reports, I wasn't aware. It's up again now.
donator
Activity: 3228
Merit: 1226
★Bitvest.io★ Play Plinko or Invest!
Are you aware that the FlipSide web page is down?

I get a "HTTP/1.1 503 Service Temporarily Unavailable" error.

I get *Internal server error*.
legendary
Activity: 2940
Merit: 1333
Are you aware that the FlipSide web page is down?

I get a "HTTP/1.1 503 Service Temporarily Unavailable" error.
legendary
Activity: 2940
Merit: 1333
Hey this provable fairness stuff isn't actually fair! I was expected to earn coins with this, not lose them! Cheesy

It doesn't make the games fair, it just stops cheating.  You could offer 30x payout for any single number on roulette and make it "provably fair", but it wouldn't be fair - the players would end up losing.  All it would prove is that you were spinning the wheel fairly.

I'm sending some funds to the wallet as I type this.

Received, thanks.
legendary
Activity: 1974
Merit: 1029
I just won a game but wasn't paid out.  The payment transaction is "oops..." Smiley

Hey this provable fairness stuff isn't actually fair! I was expected to earn coins with this, not lose them! Cheesy

Code:
$ bitcoind getbalance
0.34425772

I'm sending some funds to the wallet as I type this.

Edit: done!
legendary
Activity: 2940
Merit: 1333
I just won a game but wasn't paid out.  The payment transaction is "oops..." Smiley



I increased the size of the address box to 50 chars.

That's fine now.  There's room to spare, but I guess that depends on the address:



I'm using Chromium "Version 25.0.1364.160 Ubuntu 12.10 (25.0.1364.160-0ubuntu0.12.10.1)" if you care.
legendary
Activity: 1974
Merit: 1029
I increased the size of the address box to 50 chars.

The bet limits are calculated when a game is created and are attached to that specific game, so if you:

  • Create a game, leave it in the background.
  • Play some other games, altering the wallet's balance.
  • Return to the backgrounded game and reload it.
The limits of that game shouldn't have changed.

The worst case scenario is that by playing many winning games in between, the wallet balance could decrease up to a point that when the original game is also won, there could be not enough balance left. I would have to manually fund it in this case.
legendary
Activity: 2940
Merit: 1333
Sorry to keep bumping your thread, but it just occurred to me:

a) There seems to be no limit to the number of games I can have 'in progress' at a time.  Earlier I played 30 games in a single transaction, sending bets to 30 different addresses that your site sent me.

b) It looks like you adjust the max bets according to how your wallet balance is doing.

Do a) and b) conflict with each other?  Do you adjust the max bet after each game, even if you already told the player a different max bet?  I guess you can't, really, or it's an avenue for you to cheat the player.  "Sorry, you would have won, but it turns out your bet was over the maximum bet because we just reduced it".  Although I believe that's what SatoshiDice does - they change their max bet with no notice.
legendary
Activity: 2940
Merit: 1333
The 7-7 game shows a minimum bet of zero:

legendary
Activity: 2940
Merit: 1333
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. 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

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):



Also, I keep winning.  I played 9 times today (6 cards, A-A) and won every time!



I wrote a little Perl script that checks the provable-fairness, and that's working just fine:

Quote
$ ./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:

Quote
#!/usr/bin/perl

use Math::Random::ISAAC;

die "usage: flipside.ph " 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";
legendary
Activity: 2940
Merit: 1333
5 million times your bet?? Bloody hell lol! You couldn't help feel sorry for ya if you lost one of those bets haha.

Well with the upcoming limitation of small outputs I guess betting to those games will become somewhat difficult—unless I fill the hot wallet with 300 coins Smiley.

Note that you don't have to have enough coins in the hot wallet to be able to pay out all winning bets.  If someone wins 5 million times their bet I'm sure they'll be happy to wait 24 hours for you to get their winnings online.

Check out bitmillions.com for instance.  They keep their two biggest prize pools offline since they are very rarely won.  So long as your code can handle the case of your hot wallet having insufficient funds, you'll be OK.
legendary
Activity: 1974
Merit: 1029
5 million times your bet?? Bloody hell lol! You couldn't help feel sorry for ya if you lost one of those bets haha.

Well with the upcoming limitation of small outputs I guess betting to those games will become somewhat difficult—unless I fill the hot wallet with 300 coins Smiley.


Your game looks cool though. I'll give it a whirl when I get home

Best of luck! Wink
hero member
Activity: 504
Merit: 500
5 million times your bet?? Bloody hell lol! You couldn't help feel sorry for ya if you lost one of those bets haha.

Your game looks cool though. I'll give it a whirl when I get home
legendary
Activity: 1974
Merit: 1029
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. 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.
legendary
Activity: 2940
Merit: 1333
A slightly less important bug:

The "Payout address:" box isn't wide enough for me to see the whole address.  I tend to check the first few and last few characters to see that the address is right, but can't see the last few very easily.
legendary
Activity: 2940
Merit: 1333
I PM'ed the game's owner with the following a few days ago.  Since he's fixed the issues now I figured I'd post it here to show how you have to be careful when implementing 'provable fairness'.

Please get yourself a pizza for both your help here and this stackexchange post that was useful for my coin control utility Smiley.

Hey thanks!  I was wondering where that 0.1 BTC came from.  Smiley  I somehow missed your post here.  The forum's "watchlist" feature is a little buggy I think.

A few comments on your new provably fair system:

1) You only publish the first 4 bytes of the server secret's hash.  You could have pre-selected a bunch of server secrets with known collisions in their first 4 bytes.  That's not hard to find.  Then when you see the client secret and the block hash you can pick which of the pair (or more) of server secrets is best for you.  It would be better if you published the whole hash of the server secret to remove this as a way of you cheating.

2) The server secret is only 4 bytes long.  There are only 4 billion possible server secrets.  It wouldn't take very long with decent hardware for me to brute force it.  If I'm lucky there's only one server secret that hashes to the right value.  I can test it against multiple client secrets until I find one with 6 of the best card, and pick those 6.  You should use longer server secrets so players can't brute force them.  I don't know how slow sha386 is compared to sha256, but people regularly run 1Ghash/s when mining.  That would mean they can find your secrets in 4 seconds.  You don't need to use the whole secret in the concatenation that seeds ISAAC - you can safely use just the first 4 bytes - but tack some random junk on the end to make it impossible to discover up front.

3) I wasn't able to figure out how to seed the C version of the ISAAC RNG you linked to.  But package libmath-random-isaac-perl in ubuntu worked fine, and reproduces your numbers.

Chris.
legendary
Activity: 1974
Merit: 1029
1. show hash of server secret to user
2. allow user to select their secret
3. shuffle cards using server secret and client secret

Thanks dooglus for your input. I've made the necessary changes and put the new code online. This is a finished game with the improved provability. I entered a user secret containing the Euro symbol to show that there's an issue with the encoding; however, the sha384sum is correct. Help has been updated accordingly too.

Another example shows that when the RNG generates out-of-range cards they are skipped (lower than J-clubs in this case). It still amazes me that betting 0.73 BTC is now a whopping 80 euro…

Please get yourself a pizza for both your help here and this stackexchange post that was useful for my coin control utility Smiley.
legendary
Activity: 2940
Merit: 1333
I decided to make a better usage of the screen real state and upped it to 50.

That reminds me.  If I don't have the browser window full-width then the 'flip side' text down the left hand edge of the screen goes underneath the 50 face down cards, but when I try to click on the cards in the first column, it thinks I'm clicking on the 'flip side' text, and takes me to a new page, rather than toggling the selection state of the card I clicked on.  Took me a while to figure out what was wrong, but until I did it was very confusing.

Thanks for this insight. The client secret could perfectly be the game ID (randomly generated but trivially editable by the user). The server side has to be the pre-generated secret I alluded to.

Just make sure that it goes in this order:

1. show hash of server secret to user
2. allow user to select their secret
3. shuffle cards using server secret and client secret

If you do 2. before 1. then you could be selecting a server secret that makes the client secret bad for the user.  Doing 1 before 2 is required if we're to know the game is fair.  When you do it that way, we don't care how you pick the server secret, and so there's no need to pre-generate anything.  Just pick a pseudorandom server secret, show us its hash, allow us to pick our own secret, then use both as the seed for all in-game randomness.

You don't even need to use external sources of randomness like the block hash then.  We don't know the server secret, so can't cheat.  And you don't know what secret the client is going to pick, so you can't cheat either.

Neat, huh?
legendary
Activity: 1974
Merit: 1029
Later when the game is complete I would publish the seed

Ah, when the game is complete and the server secret is no longer valid, of course!
legendary
Activity: 1974
Merit: 1029
What's $MAX_CARDS? 6?  So you're selecting the 50 cards from 6 decks of 32 cards?

Yes. Initially 32 cards were shown but at some later point I decided to make a better usage of the screen real state and upped it to 50. (And earlier than that, my original plan was to always show all cards between 7-clubs to ace-spaces once, like when using a real deck).


The way this is usually done is to shuffle the decks using a seed derived by combining the site secret and the client secret (the block hash, in this case).  So you can prove that you had no control over the selection of the 50 cards.

Thanks for this insight. The client secret could perfectly be the game ID (randomly generated but trivially editable by the user). The server side has to be the pre-generated secret I alluded to.


Even if you pre-generate the sets of 50 cards, you still can't prove that they were fairly selected.  You could still pick more 7's than Aces.

I can use a known PRNG (e.g. ISAAC, which has a readily available Perl implementation) with a given seed to generate the cards, and publish a hash of the seed. The seed would be created from the client and server secrets. Later when the game is complete I would publish the seed and give the details of the card generation.
hero member
Activity: 756
Merit: 522
So if I can afford to bet twenty bitcoin you can afford to pay out 10x the BTC M3?

Seriously dude, you're a smart guy, but why do you ask questions like this? Do you really think the developer didn't consider the math before determining bet limits?

I am a gal, and I was making a point.
legendary
Activity: 2940
Merit: 1333
Ah, this detailed escaped me. They are randomly chosen using the "shuffle" method from the builtin Perl module:

Code:
my @deck;
do {
    push @deck, grep { $_->{'value'} >= $min_bits and $_->{'value'} <= $max_bits } (@btc_deck)x$MAX_CARDS;
} while @deck < $CARDS_TO_DISPLAY;
my @ret = shuffle @deck;

But this post doesn't prove anything, of course. I'll have to figure something out. Seems I'll have to resort to the (IMO) inelegant list of pre-generated secrets…

What's $MAX_CARDS? 6?  So you're selecting the 50 cards from 6 decks of 32 cards?

The way this is usually done is to shuffle the decks using a seed derived by combining the site secret and the client secret (the block hash, in this case).  So you can prove that you had no control over the selection of the 50 cards.

Even if you pre-generate the sets of 50 cards, you still can't prove that they were fairly selected.  You could still pick more 7's than Aces.

Edit: $MAX_CARDS can't be 6, or you would only have 24 sevens, and you wouldn't be able to deal 50 sevens for the jackpot game...

Edit2: Oh, but you're running the grep in a loop until you have enough, so that's OK.
sr. member
Activity: 252
Merit: 250
Coinlancer.io ICO | Oct 14th
If all of the user's cards are equal or higher, she wins.
really want to play this buy I have a penis
hero member
Activity: 563
Merit: 501
betwithbtc.com
So if I can afford to bet twenty bitcoin you can afford to pay out 10x the BTC M3?

Seriously dude, you're a smart guy, but why do you ask questions like this? Do you really think the developer didn't consider the math before determining bet limits?
legendary
Activity: 1288
Merit: 1227
Away on an extended break
So if I can afford to bet twenty bitcoin you can afford to pay out 10x the BTC M3?

Code:
Minimum bet: 0.00000000 BTC.
Maximum bet: 0.00000025 BTC.
Prize: 4890000x.

hero member
Activity: 756
Merit: 522
So if I can afford to bet twenty bitcoin you can afford to pay out 10x the BTC M3?
legendary
Activity: 1974
Merit: 1029
Hello! Interesting game! If there is a tie in the cards, isn't the player supposed to win?

Thanks for trying! As dooglus noted, that wasn't actually a tie since the kings were of different suit.


How is the set of cards selected?  From a 'provable fairness' point of view can you prove that the card selection isn't skewed towards the lower cards?

Ah, this detailed escaped me. They are randomly chosen using the "shuffle" method from the builtin Perl module:

Code:
my @deck;
do {
    push @deck, grep { $_->{'value'} >= $min_bits and $_->{'value'} <= $max_bits } (@btc_deck)x$MAX_CARDS;
} while @deck < $CARDS_TO_DISPLAY;
my @ret = shuffle @deck;

But this post doesn't prove anything, of course. I'll have to figure something out. Seems I'll have to resort to the (IMO) inelegant list of pre-generated secrets…
legendary
Activity: 2940
Merit: 1333
In a nutshell, users are shown a set of cards and are invited to pick some of them

How is the set of cards selected?  From a 'provable fairness' point of view can you prove that the card selection isn't skewed towards the lower cards?
legendary
Activity: 2940
Merit: 1333
Hello! Interesting game! If there is a tie in the cards, isn't the player supposed to win?

I think so, but:

The order of suits is clubs < diamonds < hearts < spades.
sr. member
Activity: 424
Merit: 250
Hello! Interesting game! If there is a tie in the cards, isn't the player supposed to win?

This was the game I played:

https://dserrano5.es/btc/flipside/game_id/87b0bae4c86baa59
legendary
Activity: 1974
Merit: 1029
Last year I was on medical leave and coded a little bitcoin game (just for fun, won't be big and professional like sd). When development was almost complete I began to work again and the code remained collecting dust in the server.  I just cleaned it up and tested it, and I think it's ready for public usage Tongue.

In a nutshell, users are shown a set of cards and are invited to pick some of them, then place a bet. When the bet transaction is included in a block, some other cards are derived from the block hash and compared with the ones picked by the user. If all of the user's cards are equal or higher, she wins. The help within the game gives all the details.

This is an example of a completed game, which shows the user-chosen cards as well as the ones derived from the block hash. There's a tie in one of the cards (an ace of diamonds). The user won this game.

A SHA386 hash can also be seen above the set of cards. This can be used to prove that the game doesn't cheat.

If the design is awful, sorry, I'm not a web designer Smiley.

You can give it a try at https://dserrano5.es/btc/flipside (HTTPS only).
Jump to: