# Provable Fairness

## What is Provably Fair?

Provably fair is a cryptographic method that allows players to verify that lottery results are genuinely random and have not been manipulated by the Goated or any other third party. Unlike traditional lotteries where you must trust the organizer, our provably fair system provides mathematical proof that results are fair.

***

## How Goated's Provably Fair Lottery Works

Our lottery uses a three-component system to ensure complete transparency and fairness:

1. ### Server Seed 🎲
   1. Generated: Before the lottery closes
   2. Commitment: We publish the SHA256 hash of this seed immediately. This is shows as Server Seed (Hashed) in the provably fair modal of that lottery
   3. Reveal: The actual seed is revealed only after the lottery closes
   4. Purpose: Proves we committed to randomness before knowing the outcome
2. ### **Bitcoin Block Hash ⛓️**
   1. Source: The first Bitcoin block mined after lottery closure (4PM UTC on a Thursday)
   2. External: Completely outside Goated's control
   3. Unpredictable: Impossible to manipulate or predict
   4. Purpose: Provides external randomness that no one can influence
3. ### **Lottery Entry CSV 📄**
   1. Complete Record: Every ticket submitted with exact numbers
   2. Chronological Order: Sorted by submission timestamp
   3. SHA256 Hash: Cryptographic fingerprint of all entries
   4. Public Access: Downloadable from our servers for verification after the lottery closes

***

## The Winning Number Generation Process

1. Server Seed: "abc123..." (revealed after lottery closes)
2. Bitcoin Block Hash: "000000000000..." (from blockchain <https://bitaps.com/>)
3. Combined: HMAC-SHA256(server\_seed, btc\_block\_hash)
4. Algorithm: Fisher-Yates shuffle using the combined hash
5. Result: 5 primary numbers (1-55) + 1 power number (1-18)

***

## Step-by-Step Verification Guide

### For Technical Users

Requirements: Basic programming knowledge, access to SHA256 and HMAC functions

#### Step 1: Verify Server Seed Commitment

1. Check that SHA256 (revealed server seed) matches the pre-committed hash
2. Confirm the hash was published before lottery closure

#### Step 2: Verify Bitcoin Block

1. Confirm the block timestamp is after lottery closure time
2. Verify it's the first qualifying block (closest after closure)
3. Check the block exists on the Bitcoin mainnet

#### Step 3: Verify CSV Data

1. Download the lottery CSV file
2. Calculate SHA256(csv\_content)
3. Compare with the stored csv\_hash

#### Step 4: Reproduce Winning Numbers&#x20;

```
import * as crypto from "crypto";

const fisherYatesShuffle = (array: number[], hash: Buffer): number[] => {
  const result = [...array];
  let hashOffset = 0;
  for (let i = result.length - 1; i > 0; i--) {
    const value = hash.readUInt32BE(hashOffset % (hash.length - 3));
    hashOffset += 4;
    const j = value % (i + 1);
    [result[i], result[j]] = [result[j], result[i]];
  }
  return result;
};

export const generateLotteryResults = (
  seed: string,
  blockHash: string
): number[] => {
  const hash = crypto.createHmac("sha256", seed).update(blockHash).digest();
  const shuffledPrimaryBalls = fisherYatesShuffle(
    Array.from({length: 55}, (_, i) => i + 1),
    hash,
  );
  const shuffledPowerBalls = fisherYatesShuffle(
    Array.from({length: 18}, (_, i) => i + 1),
    hash,
  );
  return [...shuffledPrimaryBalls.slice(0, 5), shuffledPowerBalls[0]];
};
```

### For Non-Technical Users

What You Can Verify:

1. #### Timeline Verification&#x20;
   1. Server seed hash was published before lottery closed ✓&#x20;
   2. Bitcoin block was mined after lottery closed ✓&#x20;
   3. Results were calculated using these inputs ✓
2. #### Data Integrity
   1. All lottery entries are publicly available ✓
   2. Entry data hasn't been modified (CSV hash verification) ✓
   3. External randomness from Bitcoin blockchain ✓
3. #### Third-Party Verification
   1. Independent developers can verify our algorithm ✓
   2. Bitcoin block data is publicly verifiable ✓
   3. Anyone can download and check the CSV data ✓

***

## Mathematical Guarantees

#### Randomness Sources

* Internal: Server seed (unknown until revealed)
* External: Bitcoin blockchain (unpredictable, public)
* Combined: HMAC-SHA256 cryptographic combination

#### Security Properties

* Pre-commitment: Server seed committed before outcome known
* External entropy: Bitcoin provides unbiased randomness
* Deterministic: Same inputs always produce same outputs
* Verifiable: Anyone can reproduce the calculation

#### Impossibility of Manipulation

1. Server cannot cheat: Seed is committed before knowing Bitcoin block
2. Players cannot cheat: Cannot influence Bitcoin block hash
3. Transparent process: All data is public and verifiable

Example Verification

`Server Seed: "9ce6aba907aef57ee5b3c6ca4d9779e07f9680a377e23eacc8f10241a2f6d22f"`&#x20;

`Bitcoin Block: "000000000000000000016509c12c16c3fe13516debb77f5488a6465e91141e93"`

`Winning Numbers: [38, 22, 5, 29, 9, 1]`&#x20;

#### Verification

✓ Server seed hash matches pre-commitment\
✓ Bitcoin block mined after lottery closure\
✓ CSV hash matches downloaded file\
✓ Winning numbers can be reproduced using the algorithm

For any further questions about our provably fair system, reach out to our development team at <support@goated.com>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://litepaper.goated.com/goated-token/the-goated-lottery/provable-fairness.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
