# pokerproof 🃏
A provably fair Texas Hold'em poker engine with cryptographic verification.
[](https://crates.io/crates/pokerproof)
[](https://docs.rs/pokerproof)
[](https://opensource.org/licenses/MIT)
## Features
- **Provably Fair** — Cryptographic commitment scheme ensures no manipulation
- **Complete Texas Hold'em** — Full game logic including blinds, betting rounds, side pots
- **Deterministic** — Seeded RNG for reproducible games
- **No Dependencies on Runtime** — Pure Rust, works anywhere
- **Well Tested** — 140+ tests covering edge cases
## How Provably Fair Works
1. **Server commits** to a random seed hash before the hand
2. **Players can verify** the seed wasn't changed after seeing their cards
3. **Deck shuffle** is deterministic from the seed
4. **Anyone can verify** the shuffle was fair post-hand
```rust
use pokerproof::{Deck, verify_shuffle};
// Server generates seed and commits hash
let seed = [0u8; 32]; // In practice, use secure random
let commitment = sha256(&seed);
// After hand, players verify
assert!(verify_shuffle(&seed, &commitment, &dealt_cards));
```
## Quick Start
```toml
[dependencies]
pokerproof = "0.1"
```
```rust
use pokerproof::{Game, GameConfig, PlayerAction};
// Create a game
let config = GameConfig {
small_blind: 10,
big_blind: 20,
min_players: 2,
max_players: 9,
starting_chips: 1000,
..Default::default()
};
let mut game = Game::new(config);
// Add players
game.add_player("player1".into(), "Alice".into(), 1000)?;
game.add_player("player2".into(), "Bob".into(), 1000)?;
// Start the hand
game.start_hand()?;
// Players take actions
game.handle_action("player1", PlayerAction::Call)?;
game.handle_action("player2", PlayerAction::Check)?;
// Game state is always accessible
println!("Pot: {}", game.state.pot);
println!("Phase: {:?}", game.state.phase);
```
## Game Variants Supported
- ✅ No-Limit Texas Hold'em
- ✅ Pot-Limit Texas Hold'em
- ✅ Fixed-Limit Texas Hold'em
- ✅ Straddles (UTG, Button, Mississippi)
- ✅ Run It Twice
- ✅ Ante support
## Architecture
```
pokerproof/
├── card.rs # Card, Rank, Suit types
├── deck.rs # Provably fair deck with commitment scheme
├── hand.rs # Hand evaluation (ranking, comparison)
├── game/ # Game state machine
│ ├── mod.rs # Core game logic
│ ├── config.rs # Game configuration
│ ├── state.rs # Game state
│ └── actions.rs # Player actions
└── player.rs # Player state
```
## Testing
```bash
cargo test
```
Includes property-based tests with `proptest` for edge cases.
## Used By
- [DeHouse](https://dehouse.gg) — Free, no-rake online poker
## License
MIT — use it for anything, commercial or otherwise.
## Contributing
Issues and PRs welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).