On-Chain Games
Last updated
Last updated
The primary benefit of FHE is its ability to improve application privacy, which can significantly increase the appeal of certain gaming scenarios.
The combination of zkFHE with games can enhance gaming experiences by either enabling the necessary privacy measures for simulating the desktop games on-chain, or creating "fog-of-war" versions, adding an element of surprise and excitement to games with variants and different rules, thereby increasing the overall enjoyment and engagement for players. Below, highlight a common example of such variations.
Most Poker games can be built on-chain if we take appropriate measures like FHE to provide privacy as in offline games.
Blackjack, also known as 21, is a popular casino card game. The basic rules are straightforward. The goal is to beat the dealer by either:
Having a hand value that is closer to 21 than the dealer's hand without going over 21, or
The dealer's hand going over 21 (busting) while your hand does not.
The card rules are quite simple. Number cards (2-10) are worth their face value. Face cards (Jack, Queen, King) are worth 10 points each. Aces (A) can be worth either 1 or 11 points, depending on which value helps the hand more without exceeding 21.
Each round of the game has some flexible rules, including double down, surrendering, splitting cards, etc., which are beyond the scope of this example.
We explain the (zk)FHE integrated process.
The Blackjack dApp integrates with zkFHE network and requests a shared public key PK from a certain zkFHE working group. Note here we suggest using a threshold-FHE algorithm to provide the card value privacy.
Like in the plain game, each player including the dealer is allocated two cards via the dApp service. The first card (called the "hole") of the dealer's will be dealt face down by encrypting with the shared public key PK and then distributing it.
Each player will be allocated a new card if he wants until he feels the hand value is enough close to 21. If the hand value is over 21, the play busts and loses this round.
If the dealer's hand value is a blackjack, i.e., a combination of A and J/Q/K/10, he shall reveal it immediately and win the round before moving to the next round. Note this can be achieved by homomorphically comparing the first card value with the "J/Q/K/10" or "Ace" depending on the other card value, and then revealing it publicly by threshold decrypting the card.