Many online Bitcoin gambling websites use the block chain info to prove fairness. Most of them use rather complex algorithms for this with pre-published secrets.

What most of them basically achieve: Convert a block hash or a transaction hash to a number in a certain range.

What is the simplest way to do this in a fair way, verifiable by everyone? I would like to focus mostly on using block hashes, which are the least manipulable.

With a simple way I'm looking for either a very simple mathematic way to do so or either a library which can do it for you.

I understand that predefined secrets are required when transaction information is used, because these are easy for users to manipulate. Block information, on the other hand, is far less easy manipulable. If you want to generate a block with a hash that would make you win in the game, you would make the standard block generation problem even more difficult and you will have to do solo mining which is already quite hard when doing regular mining. So, are these secrets also required when using block information?

Note that I am an engineering student myself so I will probably understand much cryptographic and mathematical terms, but the purpose of this question is of course to receive an answer that everyone can understand.

1 Answer 1


Here's the way SatoshiDICE does it: SatoshiDICE has "secret keys" for each day which they pre generated for the next 10 years. They published the hashes of those keys so you can verify they didn't change them. When a transaction comes in, they hash the transaction hash and the secret key for that day, then take the first two bytes of that. Then, a few days later, they publish the secret keys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.