Bitcoin Forum
May 12, 2024, 11:05:14 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: New Admins Tips - generating fair results, avoiding scams etc  (Read 1086 times)
mem (OP)
Hero Member
*****
Offline Offline

Activity: 644
Merit: 501


Herp Derp PTY LTD


View Profile
June 27, 2012, 01:35:32 PM
Last edit: July 12, 2012, 07:27:57 AM by mem
 #1

I get some new site owners contact me in regards to improving their sites and making it more attractive.
This proof of not cheating that are used by sites such as:
bitcoindarts
probiwon
bitjack21
bitlotto
satoshidice

- have really impressed gamers and as a result draws gamers in (often like myself with their dreams of making a gambling system finally work).

Bitlotto and satoshidice arguably have the most impressive systems as they use a hash from the bitcoin network (txid for satoshidice and BitLotto will use the first block with a timestamp after 00:00:00).

So the general question is, how do I apply this to my game/raffle fairly and prove I am not cheating.

The basic concept is (in my crappy pseudo code):

(be prepared for multiple edits here)
Code:
$player_hash = players TX id / address / hash of block containing tx;
$player_number = sha256($player_hash, $secret);
show player his hash, tell him to keep it and demonstrate how to generate number once secret is known.

$game_hash = verifiable string from event (eg lotto numbers/ block hash after set time);
$game_result = sha256($game_hash, $secret);
reveal the secret post game so players can confirm themselves.
Using public verifiable strings (ie lotto numbers) means the players can confirm before the website updates (depending how quickly it updates of course).
You could also use a public verifiable string as the games secret (instead of supplying your own).
Using your own secret is fine if you provide the hashes, but players will trust the game more if you do not have any control over the results (gamers and their voodoo).

and tada, you have a very attractive FAIR game system.

Here is a quick example section from my perl clone of satoshidice (dont worry guys, Im not getting into the business I just like new projects and yours was inspiring).
Code:
our $number_lucky       = 31456.8; # the number that their result must be lower than to win
$tx_bet_result = &get_lucky_number($main::tmptxid);
# WIN
elsif($tx_bet_result < $main::number_lucky)
{
$payout = $txbet * $reward_win;
$txprofit = $txbet - $payout;
$win = 1;
print "winning bet: $txbet, number: $tx_bet_result, paid: $payout, profit: $txprofit\n";
}
# LOSE
else
{
#$payout = $txbet * $reward_lose;
$payout = $txbet * $reward_lose;
$txprofit = $txbet - $payout;
$win = 0;
print "losing bet: $txbet, number: $tx_bet_result, paid: $payout, profit: $txprofit\n";
}

sub get_lucky_number
{
        my $tx = shift;
        my $hash = hmac_sha512_hex($tx, $main::secret);
        #print "hash: $hash\n";

        my $number = $hash;
        $number =~ s/^.*(.{4})\s*$/$1/;
        $number = hex($number);
        print "lucky number: $number\n";

        return $number;
}


Its perl, it works well enough but required more testing and simulations.
For instance, Id like to do more testing on picking a section of the hash like I do, (I take the last 4 digits and convert it to hex).

Every time a block is mined, a certain amount of BTC (called the subsidy) is created out of thin air and given to the miner. The subsidy halves every four years and will reach 0 in about 130 years.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715511914
Hero Member
*
Offline Offline

Posts: 1715511914

View Profile Personal Message (Offline)

Ignore
1715511914
Reply with quote  #2

1715511914
Report to moderator
1715511914
Hero Member
*
Offline Offline

Posts: 1715511914

View Profile Personal Message (Offline)

Ignore
1715511914
Reply with quote  #2

1715511914
Report to moderator
mem (OP)
Hero Member
*****
Offline Offline

Activity: 644
Merit: 501


Herp Derp PTY LTD


View Profile
June 27, 2012, 03:35:37 PM
Last edit: June 29, 2012, 05:11:31 AM by mem
 #2

Quote
Subbed.  I like verifiable results.

I think you have a typo here
$player_number = sha256($player_hash, $secret);
$game_result    = sha256($player_hash, $secret);

Fixed Wink

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!