Rock Paper Scissors on Nostr with commit-reveal.
1. CREATE: Player A creates game, gets game ID
2. JOIN: Player B joins with game ID
3. COMMIT: Both players commit hash(move + salt)
4. REVEAL: Both players reveal move + salt
5. VERIFY: Hashes verified, winner determined
No cheating possible - you commit before you see opponent's move.
npm install
npm start
# Open http://localhost:3000Or just open index.html directly.
{
"kind": 30334,
"tags": [["d", "rps:abc123"], ["t", "rps"]],
"content": {"type": "create", "creator": "<pubkey>"}
}Commit:
{
"kind": 30335,
"tags": [["g", "rps:abc123"], ["t", "rps-move"]],
"content": {"type": "commit", "hash": "sha256(move:salt)"}
}Reveal:
{
"kind": 30335,
"tags": [["g", "rps:abc123"], ["t", "rps-move"]],
"content": {"type": "reveal", "move": "rock", "salt": "x7k2..."}
}If you just broadcast your move, opponent sees it and picks the winning counter.
With commit-reveal:
- You commit
hash("rock" + "randomsalt") - Opponent commits their hash
- Neither can change (hash is published)
- Both reveal - hashes verified
- Fair game!