Understanding hashing: examples and full guide 🧮

Information

A provably fair game is far more trustworthy than a regular black box type because of the way the hidden information is kept and then delivered to gamers. In a black box algorithm game, gamblers will never know if the way a casinogame is played fair and random. There’s no way for them to verify a black box algorithm.

What does a hash do?

With the provably fair games, the algorithm comes up with the final results of the games that are about to be played, puts them in a secret code named a hash, and then lets the players see the hash before the start of the game. As soon as the game ends, the hash can be deciphered and so the players can verify the fairness of each of the hands they played.

To better understand how the provably fair algorithm can pull this off, we must better understand the internal workings of a hash. Also named a seed, the hash is nothing more than a line of numbers and letters, a cryptographic code, which tells the story of the hands that are about to be played from before the game starts. This makes a game that has a provably fair algorithm not only the most fair it can be, but also verifiable, thus excluding all chances of the game being rigged or mingled with in any way.

What is provably fair?

The principle behind the provably fair algorithm is that it eliminates the doubts gamblers have towards the operators of the game that they’re playing, the house or the online casino. The singular, most trusted way in which this is achievable is by predetermining the results of the game. Any other way of doing this will result in defiance and untrust, as there’s always a possibility from the operator to interfere with a real-time game and change its outcome.

The very first step in ensuring a verifiable game outcome is generating the hash chain. When the hash is generated, as in, when the outcome of the game is known and has been hidden with a cryptographic code, the game will generate a client seed and also a server seed. This is the end of the hash chain, so when the client and the server seed are generated, the final hash of the game also becomes available.

Full explanation on provably fair →

Fairness is chronological

For the game to ensure the fairness aspect of things, it is crucial that the hash chain is being dealt with in chronological order. The hash chain has to be generated before every game, and also the last element of it, the hash itself, has to be made public for the game to be fair and to receive the green light for it to happen. Also, the client seed has to be announced, but it remains unknown to both the gamblers and the operator. This is how, at the end of the game, players will be able to verify the fairness of the game.

When the game is over and the player wants to see just how fair the entire experience was, all he has to do is to hash the current game’s server seed and find the previous game’s server seed. By applying a formula on these and hashing the server seeds in a specific way, the player can verify that throughout the game, the operator was indeed using the hash chain that he said he will, calculating the game results correctly every time. By following the hash chain in the correct order, the casino reveals the fact that he didn’t generate more hash chains at once and used the one most favourable to him in the detriment of the players.

SHA, the verifier of hashes

The final step in making sure a hash has been correctly generated and implemented throughout the game is to verify it. At the end of the game, you can use the SHA256, or the Secure Hash Algorithm, to make sure the player and the house were both fair during the gameplay. The SHA allows you to verify the integrity of all data that has been used during the game. When you hash a file, you get an output generated instantly. When you compare the hash with previous hashes of the same file, you can spot differences if the file has been altered with.

To make sure that the hash algorithms are intact and true, you need to make sure that two different inputs are in no way able to generate the same output. When this happens, there is a collision taking place, a key element in the science of cryptography.

Collisions

A collision happens when two different inputs are generating the same output. This is the only thing that can compromise an encryption algorithm such as the SHA256. Still, even if this is an element that could compromise the integrity of a provably fair game, the trustworthiness of it and the fairness of the played hands, this can only happen extremely rarely. It can happen so rare, it’s not even taken seriously. Tests have revealed that it would take up to 5 billion years and all the power of the blockchain to generate a situation like this.

Cryptography in provably fair games

Two important issues are getting solved in provably fair games and their security when cryptography is being involved, with the help of SHA256 algorithms. First of all, you will never be able to generate collisions in the hash chain. When this statement is true, nobody will be able to ever predict the outcome of a game, no matter how strong their computer is. They simply cannot reproduce the hash chain and therefore protect the misbehaving operator.

Number two, if the casino would take its chance to alter the game in any way, by doing so it would never be able to get continuity in the hash chain. In this way, players are protected against manipulative moves against themselves.

Hashing explained

When you hash a text, the outcome of the hash is a code that can’t be broken unless you brute force everything, which is impossible. The word “hello” in the SHA256 language is “2cf24dba5fb0a30e[..]”. Even if you were to change the word by a single space at the end, you’ll get a completely different hash generated for it, “5e3235a8346e5a4585f8c5[..]”. The second hash has nothing to do with the first, in terms of size, shape, letters and numbers used and so on, although the word that has been hashed is the same and the only new element is the space, not even a letter or a number.

Hashes are working only one way, and are extremely unpredictable. If you are given a hash of a very long string of numbers, like a 20-digit one, you will never be able to say which are the numbers from the hash unless you are trying every single number from 0 to 999999,99 which is impossible. Also, hashes are unchangeable, as in, every combination of numbers and words has a different combination in a hash. This means, in a game that has a provably fair algorithm, there is no way to find a result with the same hash, therefore changing it.


Alex Thompson

As a blockchain enthousiast, I can't help getting excited about a more fair online gaming world. I hope I can inform you about the possibilities and provide useful insights.

Leave a Reply

Your email address will not be published. Required fields are marked *