https://github.com/mrtimu139/non-transitive-dice-game-hmac
A console-based implementation of a Generalized Non-Transitive Dice Game with HMAC verification. Supports configurable dice, fairness in random number generation, and enhanced usability features like detailed help tables.
https://github.com/mrtimu139/non-transitive-dice-game-hmac
cryptography cryptography-library dice-probability game-theory hmac javascript non-transitive-dice secure-random-number-generation verification
Last synced: 3 months ago
JSON representation
A console-based implementation of a Generalized Non-Transitive Dice Game with HMAC verification. Supports configurable dice, fairness in random number generation, and enhanced usability features like detailed help tables.
- Host: GitHub
- URL: https://github.com/mrtimu139/non-transitive-dice-game-hmac
- Owner: Mrtimu139
- Created: 2025-01-20T11:43:51.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-01-20T12:09:21.000Z (4 months ago)
- Last Synced: 2025-01-20T12:35:35.061Z (4 months ago)
- Topics: cryptography, cryptography-library, dice-probability, game-theory, hmac, javascript, non-transitive-dice, secure-random-number-generation, verification
- Language: JavaScript
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# non-transitive-dice-game-hmac
A console-based implementation of a Generalized Non-Transitive Dice Game with HMAC verification. Supports configurable dice, fairness in random number generation, and enhanced usability features like detailed help tables.# Non-Transitive Dice Game with HMAC Verification
A console-based implementation of a Generalized Non-Transitive Dice Game with HMAC verification. This application ensures fairness and transparency in gameplay using secure random number generation and cryptographic HMAC verification.
## Features
- **Configurable Dice**: Specify custom dice face values in any order.
- **HMAC Verification**: Ensures that the computer's move is securely generated and verifiable.
- **Probability Help Table**: Displays probabilities of user wins with color-highlighted headers for improved usability.
- **Secure Random Generation**: Uses cryptographic libraries to generate keys and random values.
- **Dynamic Handling**: Supports any number of dice configurations with varying face values.## Requirements
- Node.js (v14 or higher)
- Install required dependencies:
```bash
npm install chalk cli-table3## Run the Game
- Launch the game with custom dice configurations:
```bash
node game2.js
# Examples
- Valid Configurations:
```bash
node game2.js 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6
node game2.js 2,2,4,4,9,9 1,1,6,6,8,8 3,3,5,5,7,7
- Invalid Configurations:
- No dice provided
```bash
node game2.js
- Less than 3 dice
```bash
node game2.js 1,2
- Non-integer values
```bash
node game2.js 1,2,3,a,b
- Negative values
```bash
node game2.js 1,2,3,4,-5,6## Gameplay
- The computer generates a random value (x) and a secret key.
- The computer displays the HMAC of its value to ensure fairness.
- The user selects a number (y).
- The computer reveals:
- Its original random value (x).
- The secret key.
- The sum modulo range: (x + y) % range.
- The user can verify the HMAC independently using the provided key and value.## Error Handling
- The program handles invalid inputs gracefully:
- Provides informative error messages for invalid configurations.
- Prevents invalid moves and allows users to retry.