A lightweight, cryptographically secure Go library for building Provably Fair gaming systems (Casino, Roulette, Dice, Coinflip).
Designed to be simple, transparent, and impossible to manipulate.
- HMAC-SHA512 Determinism: Uses the industry-standard HMAC-SHA512 algorithm for generating results.
- Nonce Support: Ensures that the same seeds can produce a unique sequence of results.
- Range Control: Generate fair numbers within any
[min, max]range. - Easy Verification: Built-in methods to prove to users that the server didn't cheat.
go get github.com/mafineeeek/prove-meThe Provably Fair system ensures trust between the player and the house:
- Server Seed: The server generates a random string (secret).
- Server Hash: The server provides the SHA256 hash of the server seed to the player before the bet.
- Client Seed: The player provides their own random string.
- Nonce: A count of how many bets have been made with this seed pair (starts at 0).
- Roll: When the bet is placed, the result is calculated as:
HMAC_SHA512(ServerSeed, ClientSeed + ":" + Nonce) - Verification: After the bet, the server reveals the secret
ServerSeed. The player can then recalculate the hash and the roll result to verify fairness.
package main
import (
"fmt"
"github.com/mafineeeek/prove-me"
)
func main() {
// 1. Setup
serverSeed, _ := proveme.GenerateSeed()
clientSeed := "any-client-input"
nonce := uint64(0)
// 2. Roll (e.g., 1-100)
result, _ := proveme.Roll(serverSeed, clientSeed, nonce, 1, 100)
fmt.Printf("The roll result is: %d\n", result)
// 3. Verify
verification, _ := proveme.Verify(serverSeed, clientSeed, nonce, 1, 100)
fmt.Printf("Verified outcome: %d\n", verification.Roll)
}go test ./...MIT