Skip to content

akshaydhayal/Shield-Poker

Repository files navigation

🛡️ Shield Poker: Privacy-Preserving Poker with On-Chain Social Identity

Live Project Link: https://shield-poker.vercel.app/

Shield Poker is a decentralized, P2P Texas Hold'em game built on Solana. It solves the "on-chain leakage" problem using MagicBlock's Ephemeral Rollups (TEE) for private gameplay and Tapestry Protocol for a persistent, decentralized social layer.


🎮 Key Features

1. Cryptographic Privacy (Powered by MagicBlock)

  • Zero-Leaking Hands: Player hole cards are processed within a Trusted Execution Environment (TEE) using Intel TDX. Cards are never visible on L1 Explorers.
  • Lightning Speed: Experience ~50ms execution for betting, checking, and folding—eliminating L1 latency.
  • Trustless Settlement: Funds are held in an L1 Vault and only dispersed after the TEE securely settles the game outcome.

2. Social & Reputation Layer (Powered by Tapestry)

  • Persistent Player Profiles: Every player has a unique Tapestry identity with a username, bio, and avatar.
  • Career Stats Tracking: Performance is recorded on-chain. Profiles keep a permanent record of total_games_played, games_won, and games_lost, updated automatically upon game resolution.
  • Decentralized In-Game Chat: A real-time chat system built on Tapestry's social graph. Each game creates a "Content" thread where player messages are pushed as "Comments," ensuring a censorship-resistant table banter.

📺 Project Demo

🎥 Presentation Video

Watch the Demo

📸 Product Screenshots

1. Poker HomePage

Lobby

Browse live games and completed games.

2. Private Gameplay & Chat

Game Page

Joined players can chat and take actions such as fold, check, call or bet amount.

3. Game Result/Showdown Phase

Execute Payroll

See which player won and how much

4. Player Profile Page

Execute Payroll

View your tapestry Player Profile Stats

5. Create Player Profile Modal

Execute Payroll

Create a Player Profile first to host or play a poker game


🎯 The Problem

On standard blockchains, all state is public. For games like Poker, this is a non-starter:

  1. Card Privacy: If your hand is on-chain, anyone can see it.
  2. Latency: Waiting 400ms - 2s for every bet kills the game flow.
  3. Cost: Transaction fees for every "Check" or "Small Bet" add up quickly.

🏗️ The Solution: MagicBlock PER

Shield Poker moves the sensitive game logic into a hardware-secured Trusted Execution Environment (TEE) using Intel TDX.

Technical Deep Dive

1. Real-Time Privacy (Intel TDX TEE)

The game logic runs within a TEE validator. This ensures that even the validator operator cannot peek at the memory where player hands are processed. We use the #[ephemeral] attribute to mark accounts that should exist primarily in the TEE for speed.

2. Protocol-Level Access Control (ACL)

Instead of just client-side encryption, Shield Poker uses MagicBlock's Permission Program (ACL):

  • Public Accounts: The Game account (pot, community cards) has a public ACL.
  • Private Accounts: Each PlayerState (holding the hole cards) is protected by a restricted ACL. Only the specific player holding the corresponding TEE authorization token can read their own state.

3. Fast State Settlement

By delegating accounts to the TEE, we achieve ~50ms execution. Once the "Showdown" occurs, the commit_game instruction triggers a state settlement:

  • Final winner is determined in the TEE.
  • The state is "committed" and "undelegated" back to Solana L1.
  • Funds are distributed from the L1 Vault.

🏗️ Technical Architecture

MagicBlock PER (Private Ephemeral Rollups)

Shield Poker uses the #[ephemeral] attribute to mark sensitive game accounts.

  • Access Control: Each PlayerState is protected by a restricted ACL. Only the authorized player can read their own hole cards within the TEE.
  • Two-Phase Commit:
    1. TEE Phase: Cards are dealt, and betting occurs at high speed.
    2. L1 Phase: Once the game concludes, the TEE settles the state back to Solana L1 for fund distribution.

Architecture Diagram

sequenceDiagram
    participant P1 as Player 1 (Dealer)
    participant P2 as Player 2
    participant TEE as MagicBlock TEE (Intel TDX)
    participant L1 as Solana L1

    P1->>L1: Initialize Game & Vault
    P2->>L1: Join Game
    Note over P1, P2: Setup Delegation & ACLs
    P1->>TEE: Shuffle & Deal (Private)
    Note right of TEE: Cards stay in TEE memory
    P1->>TEE: Action: Bet (50ms)
    P2->>TEE: Action: Call (50ms)
    Note over TEE: Phase Advance (Flop/Turn/River)
    TEE->>L1: #[commit] Settle Final State
    L1->>P1/P2: Distribute Pot
Loading

Tapestry Social Graph

  • Idempotent Stats: Game results are pushed to Tapestry using a secure RESTful API, ensuring career stats are updated exactly once per game resolution.
  • Chat Workaround: Tapestry "Content" represents the Game Table, and "Comments" represent the real-time messages, creating a fully on-chain chatroom without a dedicated chat protocol.

🚀 Getting Started

Prerequisites

  • Solana CLI & Anchor 0.32.1
  • MagicBlock TEE Authorized Wallet
  • Tapestry API Credentials

Installation

  1. Clone the repo
  2. Setup Program:
    anchor build
    anchor deploy
  3. Frontend Configuration: Create a .env.local in app/:
    NEXT_PUBLIC_TAPESTRY_API_KEY=your_key
    NEXT_PUBLIC_TAPESTRY_API_URL=https://api.tapestry.com
    RPC_URL=your_rpc
  4. Launch:
    cd app
    npm install
    npm run dev

🏆 Hackathon Submission

This project is submitted for the following tracks:

  • MagicBlock Track: For pioneering TEE-based private gaming on Solana.
  • Tapestry Track: For building a comprehensive on-chain social layer including profiles, career stats, and decentralized chat.

Key Innovations

  • The "Invisible" Hand: First poker game where cards are cryptographically hidden but execution is instant.
  • Persistent Professionalism: Tapestry integration ensures players carry their reputation from table to table.
  • Consolidated UX: A unified workflow that handles TEE authorization and game mechanics in a single, intuitive interface.

📄 License

MIT © 2026 Shield Poker Team

About

Shield Poker brings private, real-time Texas Hold'em to Solana. It uses Magicblock Private ERs to process private hands off-chain securely in TEE and Tapestry Protocol for a decentralized social layer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages