Bitcoin Forum
November 11, 2024, 12:16:33 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How would I go about making a provably fair system?  (Read 719 times)
matt_boyd (OP)
Sr. Member
****
Offline Offline

Activity: 246
Merit: 250


View Profile
April 04, 2013, 08:46:29 PM
 #1

It would seem that I don't know that much about provably fair systems as this was my first attempt; "http://matt-boyd.co.uk/dice" If anyone would like to contribute / help me, that would be more than awesome for sure! Smiley

Also if anyone would actually be interested in playing a game like this, I have other games in mind with different odds, I just need to make sure that I get the fair mechanism and the payments ready, however I am struggling with both.

Additionally, if anyone could give me an estimate to the amount of BTCs the site would fetch when finished, that would be awesome.


Thanks, Matt.
JonnyBravo
Full Member
***
Offline Offline

Activity: 129
Merit: 100


Owlmeister


View Profile WWW
May 04, 2013, 08:28:50 PM
 #2

Give us a clue mate! Not immediately apparent from that what problem you're having. How are you deciding the result?

Operator of the L8 site family, featuring classic Roulette, Blackjack, Video Poker, Dice and more on your favourite altcoins (CLOAK, DOGE, LTC and more)
Kruncha
Sr. Member
****
Offline Offline

Activity: 644
Merit: 250



View Profile
May 04, 2013, 08:34:22 PM
 #3

Maybe have a look at this http://www.random.org/clients/http/

May be of some use to you.

Good luck Grin

K.
JonnyBravo
Full Member
***
Offline Offline

Activity: 129
Merit: 100


Owlmeister


View Profile WWW
May 04, 2013, 08:35:44 PM
 #4

heheh -- was just having a look at that myself Cheesy

I don't think I see a provably fair way to use that service, though do correct me if I'm missing something.

Even if they offered a hash my users could go and look up (and I don't see any functionality like that), there's no guarantee I didn't generate a few random numbers until I got one that gave my desired result.

Given that transaction IDs can be affected by the player, they're only suitable for raffle style situations. I really like the www.bitcoincrown.com solution:

Quote
Your winning odds are provably fair. After the confirmation of your payment, your transaction hash and the merkle root of the block containing it are used to create hmac_sha512(merkleroot,txhash). If the decimal of the first two bytes of this hash are less than 983 then you reset the Bitcoin Crown. This cannot be predicted and easily verified!

Anyone who knows of a simpler solution that is still provably fair, I'd love to hear about it Smiley Perhaps the OP found one?

Operator of the L8 site family, featuring classic Roulette, Blackjack, Video Poker, Dice and more on your favourite altcoins (CLOAK, DOGE, LTC and more)
matt_boyd (OP)
Sr. Member
****
Offline Offline

Activity: 246
Merit: 250


View Profile
May 04, 2013, 09:58:26 PM
 #5

heheh -- was just having a look at that myself Cheesy

I don't think I see a provably fair way to use that service, though do correct me if I'm missing something.

Even if they offered a hash my users could go and look up (and I don't see any functionality like that), there's no guarantee I didn't generate a few random numbers until I got one that gave my desired result.

Given that transaction IDs can be affected by the player, they're only suitable for raffle style situations. I really like the www.bitcoincrown.com solution:

Quote
Your winning odds are provably fair. After the confirmation of your payment, your transaction hash and the merkle root of the block containing it are used to create hmac_sha512(merkleroot,txhash). If the decimal of the first two bytes of this hash are less than 983 then you reset the Bitcoin Crown. This cannot be predicted and easily verified!

Anyone who knows of a simpler solution that is still provably fair, I'd love to hear about it Smiley Perhaps the OP found one?

OP is yet to find anything. The problem that I am having is that it shows the hash of the current result on the screen instead of the next one.

Here is an example of what I am working with.

Code:
$random= mt_rand(1,6); //Create a random number between 1 and 6.
$string = "TvG5hs3";
$output = hash('SHA256', $random); //Hashing the random number with SHA256
$salt = substr(str_replace('+', '.', base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(), mt_rand()))), 0, 22);
echo $salt. $random. $string .$output; //Outputting the hash.
JonnyBravo
Full Member
***
Offline Offline

Activity: 129
Merit: 100


Owlmeister


View Profile WWW
May 04, 2013, 10:41:37 PM
 #6

Matt,

Try something like this (PHP).

You would only roll the dice when a user deposits; so you'd probably have a cron job looking for new deposits, and then when one happens:

Code:
// Fire up a JSON client
$client = new jsonRPCClient($json_url);
// Get the transaction
$transactions=$client->listtransactions("account-name-of-account-user-deposited-into",1);
// Grab the block hash (can't be predicted by us or user) and transaction ID
$blockhash = $transactions[0]['blockhash'];
$txid = $transactions[0]['txid'];
// Hash the block hash with the transaction ID as a key
$hash = hash_hmac("sha512",$blockhash,$txid);
// Convert the first hex digit of the hash to an int
$diceRoll = hexdec(substr($hash,0,1));

Boom, $diceRoll now contains a provably fair number between 0 and 15 inclusive.

Operator of the L8 site family, featuring classic Roulette, Blackjack, Video Poker, Dice and more on your favourite altcoins (CLOAK, DOGE, LTC and more)
matt_boyd (OP)
Sr. Member
****
Offline Offline

Activity: 246
Merit: 250


View Profile
May 04, 2013, 10:54:51 PM
 #7

Okay, this is interesting, erm, would it be possible for you to hope on webchat.freenode.net, #matt_bitcointalk and guide me a little bit? Thanks, Matt.
JonnyBravo
Full Member
***
Offline Offline

Activity: 129
Merit: 100


Owlmeister


View Profile WWW
May 04, 2013, 11:24:01 PM
 #8

Sure Wink

Operator of the L8 site family, featuring classic Roulette, Blackjack, Video Poker, Dice and more on your favourite altcoins (CLOAK, DOGE, LTC and more)
matt_boyd (OP)
Sr. Member
****
Offline Offline

Activity: 246
Merit: 250


View Profile
May 05, 2013, 01:06:50 PM
 #9

Hey man, any chance you could hop on freenode #matt_server to explain what IRC you are on?
SRoulette
Sr. Member
****
Offline Offline

Activity: 364
Merit: 252



View Profile WWW
May 05, 2013, 01:26:05 PM
 #10

You are welcome to reuse our provably fair RNG.

Below is the bet verifier with is a command line application players can use to confirm results. It would be very simple to modify this to use a players txid + secret to generate any random number range you want.

More information is available in our FAQ: http://satoshiroulette.com/FAQ.php

Code:
#!/usr/bin/perl -w
# bet_verify.pl

use strict;
use warnings;

use Digest::SHA qw(hmac_sha512_hex);
use Math::Random::MT;

if(!$ARGV[0] || $ARGV[0] eq "--help" || $ARGV[0] eq "-h" || $ARGV[0] eq "/?")
{
        print "usage: confirm_bet.pl   \n";
        exit;
}
my $range=$ARGV[0];
my $secret=$ARGV[1];
my $tx=$ARGV[2];

my $seed = Digest::SHA::hmac_sha512_hex($tx, $secret);          # hash txid and secret
$seed =~ s/^(.{8}).*$/$1/;                                      # use 1st 8 characters of hash for secret
$seed = hex($seed) + 0;                                         # convert hex to number
my $gen = Math::Random::MT->new($seed);                         # seed MT

my $number = int($gen->rand($range)+1);                         # generate random result inside game range using seeded MT

print "Result: $number\n";
exit;

matt_boyd (OP)
Sr. Member
****
Offline Offline

Activity: 246
Merit: 250


View Profile
May 05, 2013, 01:31:44 PM
 #11

Thanks very much Sroulette, I remember talking to you on Reddit! Smiley


I shall have a look into it later, much appreciated,

Matt!
SRoulette
Sr. Member
****
Offline Offline

Activity: 364
Merit: 252



View Profile WWW
May 05, 2013, 03:45:10 PM
 #12

Thanks very much Sroulette, I remember talking to you on Reddit! Smiley


I shall have a look into it later, much appreciated,

Matt!

glad to see you are still at it Smiley

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!