{"id":46040373,"url":"https://github.com/predatorray/mental-texas-holdem","last_synced_at":"2026-03-01T06:13:16.638Z","repository":{"id":242789384,"uuid":"810569629","full_name":"predatorray/mental-texas-holdem","owner":"predatorray","description":"A mental poker implementation of Texas Hold'em","archived":false,"fork":false,"pushed_at":"2026-01-12T05:18:30.000Z","size":9141,"stargazers_count":22,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-12T15:30:32.488Z","etag":null,"topics":["cryptography","game","poker-game","typescript","webrtc"],"latest_commit_sha":null,"homepage":"https://www.predatorray.me/mental-texas-holdem/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/predatorray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-05T00:33:58.000Z","updated_at":"2026-01-12T05:17:48.000Z","dependencies_parsed_at":"2024-06-29T04:36:57.432Z","dependency_job_id":"cdc25348-81cd-4410-998d-55d226ad2d71","html_url":"https://github.com/predatorray/mental-texas-holdem","commit_stats":null,"previous_names":["predatorray/mental-texas-holdem"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/predatorray/mental-texas-holdem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predatorray%2Fmental-texas-holdem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predatorray%2Fmental-texas-holdem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predatorray%2Fmental-texas-holdem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predatorray%2Fmental-texas-holdem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/predatorray","download_url":"https://codeload.github.com/predatorray/mental-texas-holdem/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predatorray%2Fmental-texas-holdem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29962005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T05:59:08.471Z","status":"ssl_error","status_checked_at":"2026-03-01T05:58:04.208Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","game","poker-game","typescript","webrtc"],"created_at":"2026-03-01T06:13:15.622Z","updated_at":"2026-03-01T06:13:16.618Z","avatar_url":"https://github.com/predatorray.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mental Texas Hold'em\n\n![License](https://img.shields.io/github/license/predatorray/mental-texas-holdem)\n![Build Status](https://img.shields.io/github/actions/workflow/status/predatorray/mental-texas-holdem/ci.yml?branch=master)\n[![codecov](https://codecov.io/github/predatorray/mental-texas-holdem/graph/badge.svg?token=WM14oj4huI)](https://codecov.io/github/predatorray/mental-texas-holdem)\n\n![screenshot](https://github.com/predatorray/mental-texas-holdem/blob/assets/screenshot.png?raw=true)\n\nMental Texas Hold'em is a **Peer-to-Peer**, **serverless** Texas Hold'em game that runs purely in browsers using WebRTC.\n\nPlay a live demo [here](https://www.predatorray.me/mental-texas-holdem/).\n\n## Highlights\n\n### Serverless\n\nThe game leverages a WebRTC framework called [PeerJS](https://peerjs.com),\nwhere no peer-to-peer data goes through the server once connections are established.\nTechnically, there is no \"Game Server\" running in the background.\nInstead, every player is involved in \"serving\" the game,\nincluding shuffling the deck and dealing cards.\nThe host, who creates the game, merely acts as a hub that proxies the data sent by those\nwho join the game later.\n\n![serverless](https://github.com/predatorray/mental-texas-holdem/blob/assets/serverless-diagram.png?raw=true)\n\n### Fairness\n\nYou may ask, *is it still a fair game*? Well, here is the most interesting part of this project.\n\nThe game ensures fairness using a cryptographic protocol called **Mental Poker**,\nwhich allows two or more players to play a fair game of poker without a trusted third party.\n\nFor a full explanation, you can check out the [Mental Poker Wikipedia](https://en.wikipedia.org/wiki/Mental_poker).\nHere’s a simplified overview:\n\n1. There are two players, Alice and Bob.\n2. Alice and Bob shuffle and encrypt the deck one after another using a commutative encryption algorithm.\n3. Then, they decrypt the deck using their private keys and encrypt each card individually using different keys.\n4. Finally, the deck is shuffled and double-encrypted by Alice and Bob.\n   No player can view the card values unless both players agree to share their private keys for a card.\n\nThe commutative encryption algorithm can be described as follows:\n\n$$\n\\begin{align*}c \u0026= \u0026f_{k_2}(f_{k_1}(m)) \u0026\\equiv\u0026 f_{k_1}(f_{k_2}(m))\\\\\\\\m \u0026= \u0026f_{k_2}^{-1}(f_{k_1}^{-1}(c)) \u0026\\equiv\u0026 f_{k_1}^{-1}(f_{k_2}^{-1}(c))\\end{align*}\n$$\n\nwhere,\n- $m$ is the plaintext (the Card),\n- $c$ is the double-encrypted ciphertext,\n- $k_1$ and $k_2$ are the keys of the players Alice and Bob,\n- $f_{k_n}$ and $f_{k_n}^{-1}$ are the encryption and decryption functions using key $k_n$,\n\nThis cryptographic protocol guarantees that no one can know the card values until they mutually decrypt the deck.\n\nThis protocol is implemented in the separate project: [mental-poker-toolkit](https://github.com/predatorray/mental-poker-toolkit),\nalso available on [NPM](https://www.npmjs.com/package/mental-poker-toolkit).\n\n## Limitations\n\n### Fault Tolerance\n\nCurrently, there is no fault tolerance implemented. If a peer disconnects or leaves the game,\nthe game will be interrupted, and no recovery mechanism is in place.\n\n### Performance\n\nThe game uses SRA, a variant of RSA, as the commutative encryption algorithm.\nThis encryption and decryption process can be CPU-intensive, particularly with large key sizes\n(e.g., greater than 128 bits).\n\nSince these cryptographic operations are run in the browser using JavaScript,\nperformance may be slower compared to native applications.\nAdditionally, the ciphertext size increases exponentially with key size,\npotentially causing network latency during deck shuffling if the key length is too large.\n\n## Support \u0026 Bug Report\n\nIf you find any bugs or have suggestions, please feel free to [open an issue](https://github.com/predatorray/mental-texas-holdem/issues/new).\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpredatorray%2Fmental-texas-holdem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpredatorray%2Fmental-texas-holdem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpredatorray%2Fmental-texas-holdem/lists"}