Metadata-Version: 2.5
Name: provably-fair-verifier
Version: 1.0.0
Summary: Dependency-free provably fair verifier (Dice, Limbo, Crash) using HMAC-SHA256
Project-URL: Homepage, https://cryptoplay.guide/tools/provably-fair-verifier/
Project-URL: Source, https://github.com/cryptoplayguide/provably-fair-verifier
Project-URL: Mirror, https://gitlab.com/cryptoplay-guide/provably-fair-verifier
Project-URL: Demo, https://huggingface.co/spaces/cryptoplayguide/provably-fair-verifier
Author-email: CryptoPlay Guide <support@cryptoplay.guide>
License-Expression: MIT
License-File: LICENSE
Keywords: crash,dice,hmac-sha256,limbo,provably-fair,verifier
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# provably-fair-verifier (Python)

Dependency-free Python port of the [provably-fair-verifier](https://github.com/cryptoplayguide/provably-fair-verifier) JavaScript reference. It recomputes HMAC-SHA256 based results for Dice, Limbo and Crash so you can independently check a revealed server seed against its published commitment. For adults 18+ only; this is a verification and education tool.

- Web tool: https://cryptoplay.guide/tools/provably-fair-verifier/
- Live demo: https://huggingface.co/spaces/cryptoplayguide/provably-fair-verifier

## Install

```bash
pip install provably-fair-verifier
```

Python 3.8+, standard library only.

## Algorithm

- Commitment: `sha256(server_seed)` (UTF-8) must equal the hash published before play.
- Dice / Limbo: `HMAC-SHA256(key=server_seed, msg="{client_seed}:{nonce}:0")`; the first 4 bytes become a float `f = Σ b[i] / 256^(i+1)`.
  - Dice: `floor(f * 10001) / 100` (0.00–100.00)
  - Limbo: `max(floor(1e8 / (f * 1e8) * 0.99 * 100) / 100, 1)`
- Crash: `HMAC-SHA256(key=salt, msg=bytes(game_hash))`; the first 13 hex chars / 2^52 give `f`, result `max(1, floor(99 / (1 - f)) / 100)`. The game hash's SHA-256 must equal the previous game's hash.

## Python API

```python
from provably_fair_verifier import verify_server_seed, dice, limbo, crash

server = "e3f1b5c2a9d84f6e7b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f60718293a4b5c6"
commit = "1c7bc4411405303e0f84ab57dea9691c6376ee6891b289a65edac408519e6009"
verify_server_seed(server, commit)          # True
dice(server, "example-client-seed", 3)      # 42.62
limbo(server, "example-client-seed", 3)     # 2.32
```

Invalid input raises `ValueError` (`invalid_hash`, `invalid_nonce`, `invalid_input`).

## CLI

```bash
provably-fair-verifier dice --server-seed e3f1...b5c6 --hash 1c7b...6009 \
  --client-seed example-client-seed --nonce 3
# hash matches: yes
# result: 42.62
```

Add `--json` for machine-readable output. Exit code is 0 when the commitment matches, 1 when it does not, 2 on invalid input.

## Tests

`pytest` checks the reference vectors and cross-checks 300 random inputs against the Node.js implementation when `node` is available.

## License

MIT
