1 of 9

Zero-Knowledge Blackjack

A ZKP Application on Soroban

Team Members: Jay Geng, Hidenori Shinohara

Proposer: Leigh McCulloch

2 of 9

Zero Knowledge Proof — Proving Something Without Revealing It

3 of 9

Zero-Knowledge Blackjack

  • Game Description:
    • Start with 3 random cards, each with a number between 1 and 14
    • Goal: get their sum as close to 21 points without exceeding it
  • Two Actions:
    • STAND: do nothing
    • HIT: ask for another card, with the risk of going over 21
  • The Key Rule:
    • if the current sum is already > 21, you shall not draw another card (action must be "STAND")
  • Question: how can anyone verify you haven't broken the rule without revealing your cards?

4 of 9

Demo

5 of 9

Technical Details — Setup

Soroban Host

Dealer Contract

Player Contract

1. Setup public parameters → pub_params

2. Compile the circuit → prover_key, verifier_data

Define the circuit and the constraints with Soroban

6 of 9

Technical Details — The Player

Soroban Host

Dealer Contract

Player Contract

  • draw_cards() → [u32; 3]
  • decide(u32) → Proof

generate_proof(Cards, Decision) → Proof

Plonk::prove(pub_params, prover_key, secret_inputs, pub_inputs) → Proof

7 of 9

Technical Details — The Dealer

Soroban Host

Dealer Contract

Player Contract

verify_proof(Proof, Decision) → bool

  1. get_proof() → Proof
  2. get_decision() → Decision

Plonk::verify (pub_params, verifier_data, Proof, pub_inputs) → bool

  • verify(ContractID) → bool

8 of 9

Conclusion

Key Takeaways:

  • Zero-knowledge: No secret information is exchanged between the prover and the verifier
  • The proof is succinct: its size around 1KB
  • Non-interactive: no back-and-forth needed between the prover and verifier
  • Fast to verify: sub-linear verification time wrt the circuit size

Opens door for new applications on blockchain

  • Anonymous applications:
    • Anonymous transactions or "mixers"
    • Anonymous verifiable voting
    • Anonymous loans
    • Etc.
  • Scaling solutions: Zk-rollup

9 of 9

Links and Resources

Source code:

- zk-blackjack

These are forked from the main Soroban repos:

- rs-soroban-env

- rs-soroban-sdk

- soroban-tools

Further resources

- dusk-network/plonk