“Provably fair” mechanism of online gambling games

Tram Ho

For gambling games, players are always afraid that they will be cheated out of money. This is easy to understand because when playing online casino all results seem to be easily changed by technology. Because of such fundamental risks, the Bitcoin gambling community has a solution it called Provably fair. . Just like what Bitcoin solves, this method does not require a third party, it makes the game completely transparent by using advanced encryption methods to ensure that the game results are not compromised. fake . The easiest to use is the Provably fair verifiers tools that allow players to verify the results after each roll to ensure that they are not cheated during the game by entering the information provided by the website. and check the roll results section in short, this is a way that allows the player to check if a number was created really randomly or without being edited in any way. Recommended Verifiers pages

However, we still feel that something is wrong. To be sure, we should understand how the Provably fair works. This article I will try to explain the most obvious way how it works.

How does provably fair work?

Although there are several ways to implement the Provablu fair and I will try to explain the most common way. With this method, each roll-result will be calculated based on the following variables:

  • Serverseed: Provided by gambling site
  • Clientseed: Provided by the user’s browser or can be customized by the user
  • Nonce: A number that increases with every bet

The player will receive an encrypted hash of serverseed before the player starts gambling and therefore the site will not be able to change it. However, it is encrypted that the player cannot calculate the outcome of his roll. .

The player’s browser will generate a random clientseed or the player can fix it manually. In this way the site certainly would not know ng clientseed of play

Next is Nonce starting from 0 or 1 depending on the website and after each bet the Nonce number will increase by 1.

Calculation of roll result

Suppose we have

PrimeDice first uses HMAC hashes with values ​​according to the following formula:

We will use an online tool freeformatter.com/hmac-generator.html to calculate In a nutshell, we sign the clientseed + nonce with the serverseed key according to HMAC-SHA512

Result

Now select the first 5 characters (aa671) and convert from hex value to decimal. You can also use online tools like statman.info/conversions/hexadecimal.html to calculate.

If the result is a number> 999,999 then we will take the next 5 characters (aad5e) in our case, 697969 is satisfied. Now we’re going to take that module’s number for 10000 and divide it by 100

For the next bet the site will do the same so only the Nonce change increases with every roll and so the end result is random.

Verifying your roll results

Step 1

First check serverseed hashed to see if it is hashed from serverseed. We use another online tool to test ( xorbin.com/tools/sha256-hash-calculator ) to generate SHA256 from serverseed. You will compare this code with the server’s hashed code, if it is the same, then it is serverseed that was used for the roll result.

Step 2

Repeat the calculation and compare it with the returned roll server results

Use the probably fair tool

Because you can make tens, hundreds or even thousands of bets, it will be really hard every time we place a bet and then have to calculate it manually. So the Bitcoin Gambling community has supported a lot of tools so people can confirm their roll results to see if there’s really no change.

For example using Primedice you simply enter the required web page parameters

If the result is the same then we know that we don’t get cheated when playing gambling ? )))

Development

The theory stops here is then bh to practice.

Each result will be based on client-seed , server-seed and nonce

Generate random numbers

First we will randomly generate the client and server seed

Client seed:

We can easily get random values ​​from the above function for example:

Server seed This code is generated on the server side and we can use the encryption function

Combine all then calculated according to SHA-512 hash

Now we can send the results to the client

The article was translated from: https://dicesites.com/provably-fair

https://medium.com/@alexcambose/provably-fair-system-in-javascript-6457e028d2aa

Share the news now

Source : Viblo