♠️
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
  • Purpose of DecryptionCache
  • Accessing Revealed Information
  1. RACE Protocol
  2. Game Development
  3. Race JS SDK
  4. Key Components

Decryption Cache

Purpose of DecryptionCache

In games with asymmetric information, certain elements of the game state may be hidden from some players until specific conditions are met. When the game handler decides to reveal this hidden knowledge, it shares the necessary secret keys with the players, allowing them to decrypt the information.

The DecryptionCache class in the RACE JS SDK serves as a client-side cache for storing this revealed hidden knowledge. It maintains a mapping between randomness IDs and the corresponding decrypted values. This allows the client application to efficiently access and display the revealed information without needing to perform decryption again.

Accessing Revealed Information

To access revealed information from the DecryptionCache, you can use the getRevealed function of the AppClient or SubClient. This function takes the randomness ID as an argument and returns a map containing the decrypted values associated with that randomness.

Here's an example of accessing revealed information:

// Assuming client is an initialized AppClient or SubClient instance

const randomId = 1; // Replace with your randomness ID

const revealed = await client.getRevealed(randomId);

// Use the revealed information to update the game UI

This code snippet demonstrates how the DecryptionCache allows the client application to efficiently retrieve and utilize revealed hidden knowledge, ensuring that players have access to the complete game state when necessary.

By using the DecryptionCache, developers can improve the performance and responsiveness of their game frontends, as they don't need to perform decryption every time the game state is updated with revealed information.

PreviousGame ContextNextAdvanced Features

Last updated 1 year ago

🎲