logo on block and chain studios

Provably Fair

How our games are provably fair

Random Number Generation From Hash

Random numbers are generated from a hash string, so that by using the same hash string, the same resulting numbers will be generated in the same order. The hash strings will be retrieved from the block chain using a Halo Platform API call.

How a Hash Generates Numbers

A hash is a string of hexidecimal characters (0-f). By itself, each character is 4 bits of data (value 0-15), but combining characters can produce higher ranges of values. Two characters represent 8 bits (value 0-255), three characters represent 12 bits (0-4095), four characters represents 16 bits (0-65,535).

When a random number is requested we look at the range requested to determine how many bits of data we need to achieve that possible range.

For example, if 1-6 is requested, then we know the range is 6, which is 16 or less. That means we can use a single hex character to determine the returned value. If 1-20 is requested, then the range exceeds 16 but is less than or equal to 256, so we can use two hex characters to determine the return value.

Since the value of the hex characters may exceed the requested range, we use the modulus of the requested range to help in determining the return value. For example, 1-20 is requested, then the range is 20. If the hex value is 30, then the effective hex value is 10.

The output value is adjusted by the minimum requested value to get the final output value. For example, the hex value is always 0 through something, so if 1-20 is requested, then we will first generate 0-19 from the hex value (after modulus), then we add 1 to get a possible value of 1-20.

When the generator has reached the end of the hash string, it loops back around to the start of the same hash. Each time a loop happens, the character index interval is incremented by one, to prevent using the same values over and over in the same order.

For example, let's say we have a 64 character hash, and we're requesting numbers that require 2 hex characters per value. After the first 32 numbers are requested, the next number will be generated from character index 0 and 2 instead of 0 and 1. See the example hash below that marks each used hex digit with a ^ symbol.

Random Hash Sample

Latest News

Latest News icon
3.22.2019 Weekly Newsletter Draggin' Dragons Closed Beta Read More
2.8.2019 Weekly Newsletter Blockfight Update Read More
1.25.2019 Weekly Newsletter Read More

Subscribe Now

Subscribe to receive the latest news from Block & Chain Game Studios.