Provably Fair Explained - COW-CHING SLOTS

This page explains how you can verify that every spin in the COW-CHING SLOTS game is fair, unpredictable, and not manipulated by anyone. We use a combination of SHA-512 hashing and the Fisher–Yates shuffle to make each outcome verifiable and cryptographically random.

1. What Does "Provably Fair" Mean?

In gaming and gambling, a provably fair system allows users to verify the fairness of every outcome. It's built on cryptographic techniques and ensures that the result is determined before any player interaction. COW-CHING SLOTS implements this using:

2. How SHA-512 Is Used

SHA-512 is a cryptographic hashing function. It takes a string (e.g., a timestamp) and returns a 128-character hexadecimal string. We use this hash as the random seed for the shuffle algorithm.

Example:

Input: 1727472012953
SHA-512: 3e35d1bc5f... (128 hex chars)

Visual Diagram: SHA-512

SHA-512 process

This hash is then used to shuffle the item array.

3. Fisher–Yates Shuffle Explained

Once the hash is generated, it is used in a modified Fisher–Yates shuffle algorithm to produce a fair and unpredictable order of items.

The algorithm works as follows:

  1. Start with an array of items: [item1, item2, item3, item4]
  2. Use part of the SHA-512 hash to choose a random index
  3. Swap the selected index with the current index
  4. Hash again and repeat until array is fully shuffled

Code Snippet:

function getShuffledItems(seed) {
  const arr = [...items];
  let m = arr.length, i;
  while (m) {
    i = parseInt(seed.slice(0, 8), 16) % m--;
    [arr[m], arr[i]] = [arr[i], arr[m]];
    seed = sha512(seed);
  }
  return arr;
}
  

Visual Diagram: Fisher–Yates

Fisher Yates Shuffle

4. How to Verify a Spin

Every time you spin, the server returns:

Steps to Verify:

  1. Take the provided hash (e.g., 3e35d1bc5f...)
  2. Use it to run the getShuffledItems() function
  3. Take the first 3 elements of the shuffled result
  4. They should match what the server gave you

Complete Verification Script:

const crypto = require('crypto');
const items = ['item1', 'item2', 'item3', 'item4'];

function sha512(str) {
  return crypto.createHash('sha512').update(str).digest('hex');
}

function getShuffledItems(seed) {
  const arr = [...items];
  let m = arr.length, i;
  while (m) {
    i = parseInt(seed.slice(0, 8), 16) % m--;
    [arr[m], arr[i]] = [arr[i], arr[m]];
    seed = sha512(seed);
  }
  return arr;
}

const hash = 'your_hash_here';
console.log(getShuffledItems(hash).slice(0, 3));
  

5. Full Example

Spin Time: 1727472012953

Hash: 3e35d1bc5f9c03f2bc43b2c22...

Shuffled Items: [item3, item1, item2, item4]

Spin Result: [item3, item1, item2]

Since the result matches the first 3 of the shuffled array, the spin is proven to be fair.

Important Notes:

If you want to check a real spin, go to the leaderboard and click any hash link to get started!