Skip to main content

Keno PF

Written by Birate

terms used

client seed: a string chosen by the player (or automatically generated if you don't choose one)

server seed: 64-hex string generated using crypto.randombytes32 and hashed with SHA-256, used as 'key' for HMAC

nonce: the number of round you're on, increases by 1 for every round

cursor: internal number representing a nonce within the round, in keno – it increments for every shuffle. with a 40-number grid, the shuffle needs 39 steps, so cursor starts at 0 and goes up to 38

HMAC: cryptographic function that mixes unhashed server seed, client seed, nonce and cursor to produce a result

here's a 3rd party HMAC tool to verify each step for yourself: https://cryptii.com/pipes/hmac - (or any other one you prefer)


basics

Keno uses a reversed "Fisher-Yates" shuffling method to shuffle numbers from 0-39, each corresponding to a tile on the keno table.

these are shuffled one by one for every round, with the "cursor" increasing for each shuffle

the final outcome is a result of your server & client seed combination – meaning there's no possible way for us to influence your odds


how HMAC is used to determine shuffles, example round to demonstrate

unhashed server seed: 72fd40e4d9866aa8d0894461f8f3a23ead87d2e165bc4dc6212719c7f7da83fb

client seed: 4nAG7A714SPliuM2

nonce: 2459

cursor: 0 (starts at 0 for each round, ends at 38)

here's what the HMAC "message" looks like for calculating the first shuffle <clientSeed:nonce:cursor> = 4nAG7A714SPliuM2:2459:0 (second shuffle would be 4nAG7A714SPliuM2:2459:1)

the "key" part is your unhashed server seed

if you're using the 3rd party site above to follow along it would look like this:


these values result in the following hexadecimal string: 4fb2d44e40f2fa9973a483670fe2f4fd981b5888e0103e4aebed8646f31234a7

each string is sampled 4 bytes (8 hex) at a time, in this case the first 4 bytes would be "4fb2d44e"

this is then converted from hexadecimal → decimal (4fb2d44e 1337119822)


how does number = result

the decimal value is compared to the maximum accepted fairness range - which excludes 21 of the possible 4,294,967,296 results to eliminate an astronomically low bias towards tiles 0-20

since 1337119822 < 4,294,967,275; that number is used for for calculating the first shuffle - which looks like:

1337119822 % 40 = 22 (meaning 'if you divide x by 40, what number is left over')

the grid sequence looks like this before shuffling:

wat shuffling

shuffling works by swapping a number from a specific position in the sequence with the last number which hasn't been swapped yet, in this case it'd be swapping 22 (23rd number in the sequence) with 39 (40th number in the sequence)
the last number is now locked in as 22, and won't change anymore

grid sequence after first shuffle:

next shuffle uses 4nAG7A714SPliuM2:2459:1 as the "message" part, which gives 561472829 as the decimal number

since the 40th slot is already decided, the calculation is 561472829 % 39 = 8 (next one would be x % 38 etc.)

grid sequence after second shuffle:

this is then done 37 more times, which results in the final sequence:

after shuffling, the first 10 entries are drawn and +1 is added to each

(the grid used for shuffling is 0-39, final result is represented as 1-40)
result: 11, 6, 5, 10, 30, 38, 28, 26, 34, 3


how this could be cheated and how you'd notice

since you're actively contributing to what the outcome of each round is (selecting tiles), there's very little the casino could do in terms of rigging your game. the only way would be to bypass the provably fair system entirely and have the game automatically select tiles that you haven't picked

if this was the case, you'd notice immediately as you tried to verify one of your rounds.
once you've committed to a client+server seed combination - your future rounds are locked in place.

you can try this on our verify page, where the "nonce" can be increased for all client & server seed combinations to see what the results of your future rounds would've been (this can only be done after rotating the seed)


TL;DR

• keno provably fair works by combining your client seed, server seed, nonce and cursor with HMAC to shuffle numbers corresponding to the grid in a random and unpredictable way

• final positions are already determined before you select any tiles

• "Fisher-Yates" shuffling method is used for the final positions - meaning that for each round, the grid is shuffled 39 times, and the resulting sequence of numbers dictates where the winning tiles are

• as long as you're able to set a client seed (after the hashed server seed is revealed), there's nothing the casino can do to skew the odds without players immediately noticing

• every individual shuffle can be verified through 3rd party tools, no need to sheepishly trust Duel

Did this answer your question?