Can zero-knowledge proofs improve user experience by reducing the number of interactions between the full-chain game and the blockchain?

CN
4 hours ago

What are the suitable applications of ZKP in the gaming field?

Written by: Yooma

Image source: https://unsplash.com/photos/people-inside-library-1mwPOXbpB8_

Problems Encountered

PopCraft is a fully on-chain elimination game, with each game lasting 4 minutes. Players eliminate all elements on the board within the specified time to earn token rewards.

Due to its fully on-chain nature, every action a player takes during the game requires interaction with the blockchain. The block time on Ethereum Layer 2 is typically 2 seconds, resulting in players needing to wait at least 2 seconds for each action in the game, which far exceeds the wait times in similar Web2 games, leading to a poor gaming experience in PopCraft.

PopCraft game main interface


Proposed Solution

We propose to utilize zero-knowledge proof technology (hereinafter referred to as ZKP) in PopCraft to reduce the number of interactions players have with the blockchain during the game.

The expected approach is: the game process will not be on-chain, but there will be mechanisms to ensure no cheating risks. Each action a player takes in the game will generate a ZKP, with the ZKP for the next action based on the previous action's ZKP, thus forming a self-contained ZKP similar to a blockchain structure. At the end of the game, the ZKP for the last action will be sent on-chain for verification by a smart contract.

Research and Derivation of the Solution

1. Anti-cheating for Game Process and Results: Generating ZKP only for the game results is insufficient, as there is also a possibility of cheating during the game process. Therefore, ZKP must be generated for both the game results and the game process.

2. Technical Challenges in Gradually Generating ZKP: To prevent cheating, ZKP must be generated for every action a player takes in the game, with the last ZKP being verified on-chain at the end of the game. In this process, each ZKP will depend on the previous ZKP until the game concludes.

However, the difficulties are:

1> The generation of new ZKP relies on the previous ZKP, complicating the verification process and creating uncertainty about its feasibility. Additionally, ZKP verification is done through smart contracts (on-chain), raising the question of how to verify the correctness of the previous ZKP when generating the next ZKP.

2> When verifying each ZKP's correctness through smart contracts, ensuring the coherence of each ZKP with the previous one is uncertain, and it is unclear if there is a solution to this problem.

3. The Issue of Public Game Data: The game data of PopCraft is public, so using ZKP for information hiding is unnecessary. If the above verification steps can be implemented, the next step is to consider storing game data on the contract side. However, the nature of ZKP cannot reveal specific game data, and one cannot directly trust the game result data sent from the client to the smart contract, meaning the smart contract cannot directly store this data.

4. The Issue of Consuming Game Items (Token Consumption) in PopCraft: When the game process involves using game items to eliminate isolated elements, it essentially corresponds to token consumption, requiring the transfer of the corresponding tokens from the user's wallet. How to handle the generation and verification of ZKP for this step is also a problem.

1> One possible solution is: Continue generating ZKP for this step as per the previous process, verifying the number of tokens consumed and ultimately sending it to the smart contract. However, since the smart contract cannot obtain specific game data through ZKP, it cannot determine the number of tokens that should be transferred.

Additionally, if a player has 3 Token A but attempts to consume 4 Token A in the game, this error will only be discovered at the end of the game, not in real-time during user operations.

2> Another possible solution is: When using tokens to eliminate isolated elements, directly interact with the smart contract to complete the elimination and then update the player's token balance. The generated ZKP will only serve to prove the game operation and state at that moment.

Therefore, after successfully transferring tokens, ZKP must continue to be generated as in previous operations. If not generated, there will be an additional interaction step with the smart contract between the ZKP generated for the token transfer operation and the next ZKP, leading to a conflict in the game state within the ZKP. This raises the question of whether the ZKP generated at the end of the game is valid.

5. The Data Hiding Issue of ZKP: For a scenario like PopCraft, where game data does not need to be hidden, using ZKP for data hiding is redundant and increases the difficulty of obtaining game data and the uncertainty of engineering implementation. PopCraft only needs to ensure that there is no risk of cheating in the game process and results, without needing to hide game process data.

Conclusion

In games like PopCraft, where game data does not need to be hidden, using ZKP for information hiding is unnecessary. To enhance the gaming experience by shortening response times, one could consider keeping the game process off-chain and only putting the final results on-chain. The key is to find a method that ensures there is no possibility of cheating from the first step of playing the game to the last step, and then to verify the correct result on-chain.

If information hiding is pursued through ZKP, it would instead increase the difficulty of engineering implementation. Secondly, ensuring that the game process is free from cheating risks is crucial; while ZKP can ensure that individual game operations are free from cheating risks, to reduce the number of interactions with the blockchain, one cannot submit a ZKP for every single action. Thus, how to ensure there is no cheating risk throughout the entire process from the first action to the end of the game remains a problem that ZKP currently cannot solve.

From our research, ZKP is suitable for two types of applications in the gaming field:

  1. Information hiding in non-complete information games, such as: Dark Forest, Texas Hold'em, Werewolf, Hearthstone, etc.
  2. Single-step game result proof, such as: lotteries, guessing numbers, rock-paper-scissors, dice games, etc.

Due to our limited expertise in zero-knowledge proof technology, there may be factual errors or unreasonable engineering assumptions in this article. We welcome criticism and guidance from experts with rich experience in the field of zero-knowledge proofs.

免责声明:本文章仅代表作者个人观点,不代表本平台的立场和观点。本文章仅供信息分享,不构成对任何人的任何投资建议。用户与作者之间的任何争议,与本平台无关。如网页中刊载的文章或图片涉及侵权,请提供相关的权利证明和身份证明发送邮件到support@aicoin.com,本平台相关工作人员将会进行核查。

Share To
APP

X

Telegram

Facebook

Reddit

CopyLink