♠️
RACE Protocol
NFT PresaleDiscord
  • ❤️Official Docs & Links
  • ⏳Progress Overview
  • RACE Protocol
    • 🏗️System Architecture
      • Components
      • On-chain Accounts
      • Synchronization
      • Randomization
      • Payment
    • 🎲Game Development
      • Game Handler
      • Effect
      • Event Handling
      • Race API
        • Arweave Integration
      • Race JS SDK
        • Installation and Setup
        • Key Components
          • AppClient
          • SubClient
          • Events
          • Game Context
          • Decryption Cache
        • Advanced Features
          • Getting Revealed Knowledge
          • Exiting and Detaching
          • Submitting Messages
          • Sub-game Interaction
        • Best Practices
        • API Reference
        • Troubleshooting
    • 🧪Testing
      • Race Test Kit
      • Unit Testing
      • Integration Testing
      • Additional Considerations
    • 🧱Modules & Features
      • Encryption Methods
      • Command-line Tools
      • Configuration Options
      • Blockchain Transport Implementations
    • 📃Smart Contract
      • Solana Program
    • 🔦Examples and Use Cases
      • Draw Card Game
      • Raffle Game
      • Other Examples
  • RACE Games
    • ♠️RACE Poker app
      • 🎮Start playing in minutes
        • 💰Cash and sit-n-go
        • 🏆Tournaments
      • 🎨Workshop
        • 🏆Create cash games
        • 🏨Create tourneys
      • 💡Concept introduction
      • 🏗️System architecture
      • 👾Game Flow
      • 🎲Cards shuffling
      • ☎️Communication
      • 🔐Key sharing/decryption
      • 💱Cash flow structure
    • ⚡Solfast
      • 🎲Game modes
  • RACE RESEARCH
    • 👾No-Code Development
      • Brainstorming
      • Implementation Approach
      • Project Status
    • 0️⃣Zero-Knowledge Proofs
      • Brainstorming
      • Integration steps
        • Verifiable Randomness Generation
        • Private Game State Updates
        • Verifiable Settlements
        • Private Player Actions
      • Project Status
    • 🛡️Security Audit Report
      • Executive summary
        • Introduction to Race Protocol
        • Audit Methodology
      • Findings
        • Smart Contract Security
        • WebAssembly Security
        • Client-side Security (Race SDK)
        • Server-side Security
        • Randomization and Encryption
        • On-chain Account Management
        • Synchronization Mechanisms
        • Payment Handling
      • Recommendations
      • Conclusion
  • RACE DAO
    • 😎About
    • 🫂Community
    • 🖼️NFT Collection [!]
Powered by GitBook
On this page
  • Shuffling procedure
  • Final result
  1. RACE Games
  2. RACE Poker app

Cards shuffling

RACE Poker's decentralized shuffling

PreviousGame FlowNextCommunication

Last updated 2 years ago

Algorithm described here can be applied for any number of players. For simplicity, we consider a situation when 2 players are in the game: Alice & Bob.

Shuffling procedure

Synchronous stream cipher is used for encryption that satisfies:

encrypt(k2,encrypt(k1,x))≡encrypt(k1,encrypt(k2,x))encrypt(k2,encrypt(k1,x))≡encrypt(k1,encrypt(k2,x))encrypt(k2,encrypt(k1,x))≡encrypt(k1,encrypt(k2,x))encryptpartial(k)∘decryptpartial(k)≡identityencryptpartial(k)∘decryptpartial(k)≡identityencryptpartial(k)∘decryptpartial(k)≡identity

C stands for the collection of 52 cards:

C=(c1,c2,...,c52)C=(c1,c2, ..., c52)C=(c1,c2,...,c52) The whole collection is encrypted with a single key

Cencrypted=encrypt(k,C)=(encrypt(k,c1),…,encrypt(k,c52))Cencrypted=encrypt(k,C)=(encrypt(k,c1),…,encrypt(k,c52))Cencrypted=encrypt(k,C)=(encrypt(k,c1),…,encrypt(k,c52))

In this step Alice & Bob encrypt & shuffle collection of 52 cards each with own single key

In these steps Alice & Bob encrypt each card with an independent key:

K=(k1,k2,…,k52)K=(k1,k2,…,k52)K=(k1,k2,…,k52)Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))

K=(k1,k2,…,k52)K=(k1,k2,…,k52)K=(k1,k2,…,k52)K=(k1,k2,…,k52)Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))

The final encryption with 52 keys

The whole encryption procedure made by all clients:

That means both Alice & Bob don't know what card is in what position now.

To reveal cards Alice & Bob need to share cards' individual keys with each other.

Until Alice shares a certain key, Bob and server doesn't know what card it is.

Alice & Bob can now play the game and share the keys according to the game logic.

Players, server need to run the same encryption/decryption process for game to go.

Alice & Bob have to reach consensus on the game progress, and transactor to verify it.

Final result

The whole shuffle procedure made by all clients:

♠️
🎲
Encrypted communication
Key sharing & decryption