Random numbers, hashes and SHA-256
To read provably fair, three ideas are enough: where a number comes from, what a hash does, and why HMAC can bind a secret key to a message.
8

Randomness and the hash
A random number in a game is a value you cannot confidently name in advance from earlier results. A truly random source takes noise from a physical process. A pseudorandom generator unfolds a short starting value, the seed, into a long sequence by a formula. The sequence looks unordered, but the same inputs repeat it.
A cryptographic hash function turns a string of any length into a fingerprint of fixed length. For SHA-256 that is 256 bits, usually 64 hexadecimal characters. Even a small edit to the input changes the fingerprint completely. Teaching example: the SHA-256 of hello is 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824. The SHA-256 of hellp is fdd7585e08c4e2afd71dcabdb4636c89d557a3f42db9e2040c8bbd1708aa4ce7. Only the length matches, not the contents.
A hash cannot simply be decrypted back into the original data. It is not a cipher with a key. It is a one-way fingerprint. That is why a casino can show the hash of the server seed in advance and keep the seed itself hidden until the end of the cycle. Later the player hashes the revealed value and compares it with the published one. If the game uses a different algorithm, for example HMAC-SHA256, the check is different. Do not assume that every casino uses the same scheme.
HMAC
HMAC is a way to hash a message together with a secret key. In the teaching scheme of this course the key is the Server Seed, and the message is the string clientSeed:nonce. Someone who does not know the key cannot build the same HMAC. Someone who receives the key after the reveal can repeat the calculation.
The tool below computes SHA-256 in the browser. The string you enter is not sent anywhere. The button changes the last character and shows a second hash beside the first.
What to watch: a long hex string of the same shape does not make two hashes equal. Compare them character by character.
Remember
- A pseudorandom sequence repeats when the inputs are the same.
- SHA-256 gives a fingerprint that cannot be read backwards.
- One changed character changes the whole hash.
- HMAC binds a message to a key. A particular game's algorithm may be different.
Check yourself
This lesson is marked complete in this browser.
