I'm working on coin toss game for new a new gambling website (coinalot.net) and I am trying to make a provably fair gambling algorithm.
I would like your opinion if the following method would work and if it would be fair and secure.
The Game
The game is simply a coin toss. You pick heads or tails. If you guess correctly you get 2x your bet, otherwise you lose your bet.
There is a ~1% chance that the coin "lands on the edge". In this case you lose no matter what your pick was (this is the house edge).
Method:
1.) Server secretly generates a random nonce (about 30 characters, letters and digits) and a random whole number 0-98.
2.) Server calculates a hash (sha224, 100 iterations) from all this to present to the player on the web page in the next step.
3.) The page is presented to the player with the hash as calculated above, two buttons ("heads" and "tails"), an inputbox to enter his bet amount and another inputbox to enter a number (already filled with a default number 0-98 using javascript). The last inputbox is for the client seed.
4.) The player then clicks on one of the two buttons and the bet is sent to the server. The data sent to the server is "heads/tails" choice, the bet amount, and the number from the second inputbox (client seed).
5.) The result is calculated as follows: (server number + client seed) divided by 99 with rest.
If this resulting number is 1-49 this means "heads", if 50-98 it means "tails" and a 0 means "edge". If the player picked correctly the payout is made.
Note that a page with a certain hash will timeout after 3 minutes (to avoid giving a long time to calculates hashes).
What do you think?
Is this fair?
2.) What is the point of doing 100 iterations here ? Why did you decide to use sha224 ? Just to be different ?
3.) You forgot to mention exactly how the input to the hashing function is constructed.
5.) So a client seed of 0 doesn't change the result, this is wrong just because any client seed is supposed to completely change the outcome.
I think you are just trying to make up yet another method.
2.)
I'm using sha224 so that sha256 ASICs and programs cannot be used to crack the hash. I could also use sha512 but the hash is very long and I prefer to keep it short.
I'm using 100 iterations just to make it slightly more difficult to crack the hash.
3.)
The input to the hashing function is the nonce concated with ther server number (as a two-digit number).
5.)
Not every client seed has to change the result. It is the (client seed + server seed) div 98 that determines the result.
The player might suspect that the server seed already has the best result rolled for the player in that case he can send a 0 to leave it unchanged. That must be possible, too.
My aim is to make a relatively simple and transparent method. One that a player could easily calculate (except for the hash function).