<p>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.</p>

CC BY-SA 3.0
2013-04-03T21:25:37.420Z
2013-04-03T21:25:37.420Z
lurf jurv
<p>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.</p>

<p>What most of them basically achieve: <strong>Convert a block hash or a transaction hash to a number in a certain range.</strong></p>

<p>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.</p>

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

<p>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?</p>

<p><em>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.</em></p>

<blockchain><gambling><hash>
How to use block and transaction hashes for generating simple stochastic chances?
Steven Roose
# How to use block and transaction hashes for generating simple stochastic chances?

(Asked by: username_0 on 2013-04-03)

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.*

**Tags:** blockchain, gambling, hash


---

## 1 answers

### Answer by username_1 on 2013-04-03. Score: 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.


---

