---
# System prepended metadata

title: Untitled

---

## Inspiration
We are a blockchain team with a lot of experience in solidity and the EVM ecosystem. Currently, we are focusing our resources on zero-knowledge technology and its applications. In which the problem with shuffle on-chain for porker and blackjack is what we are focusing on researching.

We set two main goals for our product:

- Become a completely transparent virtual casino
- Build a common consensus (which we call proof of shuffle) for casino games integrated with zoker

From there, we realized that Theta network with Theta Video API and Metachain could be the missing piece to complete our product:

 - Theta Video API: We can easily allow our users to livestream when they participate in our virtual casino games. Their fans can also interact with the casino through tasks such as donate, betting, etc.
- Metachain: It is easy to scale casino games when you already own a subchain, reuse shuffle functions.
## What it does
Within the competition, we want to show a complete product that can be ready for launching, so we will focus on building a complete blackjack game entirely on-chain.

Thanks to the use of circom and the unit matrix, we ensure that the shuffle of the deck is always fair and there is no interference from the dealer.

Hands will not depend on trust in a dealer like traditional game servers.

Players can also livestream their games with their fan community.
## How we built it

The logic part is built on EVM-based smart contract, with the zero knowledge part created from the circom framework.

To be able to shuffle on-chain, we will use the following formulas:

In each hand and dealer, the cards will be shuffled by multiplying with the permutations matrix and then encrypted with ElGamal.

shuffle with permutations matrix:
$$
\left(\begin{array}{cc} 
c _ { 1 } & .... & c _ { 52 }\\
\end{array}\right)
\left(\begin{array}{cc} 
0 & .... & 1\\
.... & .... & ....\\
1 & .... & 0
\end{array}\right)
$$ 

**Encrypt each element in cards array**
Encrypts a $c_ { i }$ to next hand (or dealer) under his public key (G,q,g,h) as follows:

1. Choose an integer y randomly in {${1, ..., q - 1}$}
2. Compute s = $h^y$ - shared secret
3. $b_{1}$ = $g^y$
4. $b_{2}$ = $m . s$

**Decrypt**:
From private key(x) and $b_{1} , b_{2}$  to $c_ { i }$
1. Compute s = $b_{1}^x$. Since $b_{1}$ = $g^y$ => $b_{1}^x$ = $g^{xy}$ = $h^y$ => shared secret
2. Compute $s^{-1}$, the inverse s in the group G. This can be computed in one of several ways. If G is a subgroup of a multiplicative group of intergers modulo n, where n is prime, the modular multiplicative inverse can be computed using the extended Eucliedean algo. An alt is to compute $s^{-1}$ as $b_{1}^{q-x}$. This is the inverse of $s$, since $s . b_{1}^{q-x}$ = $g^{xy} . g^{(q-x)y}$ = $(g^q)^y$ = $e^y$ = $e$.
3. Compute $m_{i}$ = $b_{2} . s^{-1}$ . Because $b_{2}$ = $m_{i} * s$ => $b2 . s^{-1} = (m . s) . s^{-1} = m . e = m$
4. Map $m_{i}$ back to $c_{i}$ 

Ref: 
Elgamal formula: https://en.wikipedia.org/wiki/ElGamal_encryption
Mental Porker: https://en.wikipedia.org/wiki/Mental_poker

## Challenges we ran into
Build my own formula to ensure the integrity of the deck after each shuffle of the hands and dealers.

## Accomplishments that we're proud of
Time management to be able to submit the product in the most complete way.

## What we learned

We have found the missing pieces that our project needs that Theta can provide. For a blockchain product to truly be adopted, we cannot focus solely on technology; we need to address the issues that users are facing.

Zoker has addressed the issue of trust between hand and dealer through zero-knowledge technology.

Thanks to Theta, Zoker can reach different types of users:

- Theta Livestream API: Access to traditional retailers, they can easily participate in casinos by watching livestreams from their idols.
- Metachain: Build a chain for developers of casino games to freely design.

## What's next for Zoker

As mentioned above, Zoker will focus on 2 main tasks:

- Become a completely transparent virtual casino
- Build a common consensus (which we call proof of shuffle) for casino games integrated with Zoker
- 
These are the macro tasks that we have set out. During development, we will rely on market trends to continuously grow users into the ecosystem of Zoker in particular and Theta in general. Currently, these are new micro ideas emerging in my mind:

Open Zoker’s casinos in the metaverse being built on the Theta network.