Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: GueurK on May 30, 2013, 11:24:37 AM



Title: Fair Randomization
Post by: GueurK on May 30, 2013, 11:24:37 AM
Hi there,

I'm building a new Bitcoin lottery (http://www.coinwin.net).
The rule is very simple :
_ At the end of the round one user is selected randomly to win the pot.

The question : I want to make a fair randomization, like in other gambling websites.

Can someone give me clues about it ?

Thank's a lot !!



Title: Re: Fair Randomization
Post by: GueurK on May 30, 2013, 02:59:12 PM
I feel alone ^^


Title: Re: Fair Randomization
Post by: deslok on May 30, 2013, 03:37:42 PM
you'd need a random number generator in hardware to be truly random, however without one of those a pseudo random number generator(easy enough in most programing languages) would be sufficient as long as the input was from a source you didn't directly control (something pulled from the blockchain such as the number of a randomly selected block in the past week would work well)


Title: Re: Fair Randomization
Post by: grue on May 30, 2013, 08:22:21 PM
Take a random number (generated using any choice you want), and publish its hash (maybe padded with additional data to prevent guessing). Keep the random number a secret. at the time of drawing, take the hash of the latest block, and concatenate that with your secret number and take the hash of that. Use that hash to seed whatever PRNG you want to use. To allow auditing, publish the exact PRNG implementation you used and your secret (plus padding if any). Any user should be able to re-create the results.


Title: Re: Fair Randomization
Post by: GueurK on May 31, 2013, 11:50:24 AM
Thank's for your answers !
I'm gonna have a try.
I don't want to be accused of scam.



Title: Re: Fair Randomization
Post by: Razick on May 31, 2013, 02:06:20 PM
Hi there,

I'm building a new Bitcoin lottery (http://www.coinwin.net).
The rule is very simple :
_ At the end of the round one user is selected randomly to win the pot.

The question : I want to make a fair randomization, like in other gambling websites.

Can someone give me clues about it ?

Thank's a lot !!



For something like that the built in psuedo-random number generator in your programming language should be fine. If you are using PHP just use $winner = rand(1,$numberOfEntries);

Or if you want to be provably fair, generate the random number in advance and publish a hash of it. You can then announce the winning number after the drawing and any user can compare the hashes.