Verifiable Games Using RISC Zero

Slides


How to use the slides - Full screen (new tab)
Slides Content
--- title: Verifiable Games Using RISC Zero tags: RISC Zero, Talk, Presentation, Workshop, zkVM, zkGames, Hackathon, Buildathon, Zero Knowledge Proof, Applied Cryptography, Rust, Zypher duration: 60 minuets description: RISC Zero Workshop for the Zypher Provable Games Buildathon - June 2024 date: 2024-06-01 # # RevealJS Settings # # Add custom css files for your slides here, comma separated: separator: "\r?\n---\r?\n" verticalSeparator: "\r?\n---v\r?\n" # Below can be any of these: https://revealjs.com/config/ revealOptions: transition: "convex" # animation between slides = none/fade/slide/convex/concave/zoom backgroundTransition: "none" # background swap between slides = none/fade/slide/convex/concave/zoom slideNumber: true controls: true progress: true ---

RISC Zero
Verifiable Games

On-chain $~~~$ ๐Ÿ‘‰ $ZK$ ๐Ÿ‘ˆ $~~~$ Off-chain

Event Materials โ†—๏ธ


Why RISC Zero?

  • Verifiable Computation: outsource-able
  • Highly Scalable: low-cost verification
  • Tunable Privacy: robust & universal*

Notes:

  • you can verify that a computation of a specific program ran exactly as it should, even if done by untrusted executor!
  • Prover that runs program & produces receipt reveals as little as nothing to everything about execution to verifier.
  • Verification is significantly cheaper than running computation yourself... at the cost of prover doing significantly more work to run the zkVM
  • * Privacy is from everyone outside the prover, if you are the prover, no one but you has secret data.

What problems can ZK address for games?

On-chain & Web3

  • calldata limits restrict complexity
  • prohibitive gas costs
  • most blockchains lack privacy

Off-chain & Web2

  • Cheating through manipulation of official game logic
  • Private game aspects without any 3rd party / admin to adjudicate

See Zypher's supporting content for more.

Notes:

  • ZK coprocessor - run verifiable program logic in zkVM by 3rd party or yourself to untrusting parties

  • Added security and fairness and privacy that zero-knowledge proofs can provide, as they involve complex decision-making and competitive interactions.

  • Commonly turn based, but can simply be tick based (STF analogy -> blocks)

  • Privacy is optional, fully transparent games with ZKPs can provided added guarantees around many things other than that (if carefully designed)

    • cheating specifically in being able to go around rules of game logic, especially in cases with hidden player data/logic. (Don't trust. verify!)
  • Private:

    • moves of known players
    • cards in your hand / hidden from all deck shuffle
    • hidden ID / anonymous interactions in multiplayer
    • Enabling incomplete information games (e.g. โ€œfog of warโ€ mechanics)
  • Can prove final score without revealing anything about the game that resulted in it! Proof of Exploit CTF.

  • Off-chain: CFT game where you prove you got a flag without revealing it (because that needs to remain secret) no 3rd party to check, use a proof!


RISC Zero Track Objective

Develop games using RISC Zero to ensure privacy and fairness.

Notes:

Developers are encouraged to implement game designs that can verify player actions without disclosing specific game data. This approach allows for the exploration of new gaming models that operate off-chain but utilize on-chain verification to ensure transparency and fairness.


RISC Zero 101

Read Getting Started and/or watch the playlist.

Notes:

  • deeper understanding as exercise for views of this presentation.
  • very happy to answer questions on our discord!

RISC Zero On-chain

Read about Blockchain Integration and watch the Foundry Template playlist.

Notes:

  • TODO diagram how the proof works in game context (seq. diagrams with actors IDed (player, execution, prover))

โœจ Inspiration

โš ๏ธ -- Do not copy ๐Ÿ -- ๐Ÿ™

Notes:

Plagiarism, missing attribution and violating licenses will disqualify you! Building on them to something significantly enhancements may be considered - please let us know what you are planning :grin:


ZK Checkmate Demo

Join in following the Hands-on instructions โ†—๏ธ

Notes:

  • See the recording there to follow along for an overview.
  • I encourage you to experiment yourself!

Bevy (R0 v1.0.1)

  • Serious Rust game engine
  • Great base to start hackin' ๐Ÿค 
  • Start with shared core logic

Notes:

  • Core logic can be used in the host & the guest for Bevy games
  • Design guest to be minimal as proofs are costly!

zkSnake (R0 v0.20)

zkSnake Source โ†—๏ธ

Notes:

  • Winner of RISC Zero Coprocessor Bounty at ETHDenver 2024 and did well in community quadratic voting too!
  • Idea: take it further and make a bevy app in wasm w/ webGPU with shared core logic identical on web & "re-player" zkVM

3D ZK Games?!

๐ŸŽฎ Play the Demo ๐ŸŽฎ


๐ŸŽจ ZK Game Design Patterns

  • Prove transcript of game for verifiable high scores
  • Prove state update based on complex game logic
  • Prove validity of player moves while concealing
  • Play & prove latter (snake game)
  • Proof for each hidden move, perhaps in a tx on chain
  • Able to run only core game logic in zkVM - GUI and other non-security/privacy/fairness aspects can live outside the proven core logic (diagram)
  • Randomness
    • cannot do within guest - only fake & deterministic random for replay of moves perhaps (who gets to know seed? Choose? VRF maybe?)

๐ŸŽ‡ What is special about RISC Zero? (1)

  • Developer productivity (@ hackathons & beyond)
    ย  Top 1000 crates.io tested nightly,
    ย  benchmarks and more: reports.risczero.com
  • Hard in zkDSL, easy in zkVM:
    ย  Loops & branching
    ย  Design ๐Ÿกบ Implementation ๐Ÿกบ Auditing

Notes:

  • Lots of ZKP options, why use R0?
    • zkDSL could be more performant, but time to market is very high, small set of humans can implement them at all.
    • Why use us over other zkVMs? First, arguably best devex, v1.0 release stability and prover performance milestones!

๐ŸŽ‡ What is special about RISC Zero? (2)

  • Proof continuation
    ย  Unbounded guest programs
  • Proof composition
    ย  "Proof-ception"
    ย  Hybrid Client side {๐Ÿ•ต๏ธprivacy} & server {๐Ÿฆพpower}
  • Execution separate from proof generation

Notes:

  • Proof-ception = efficient verification of proofs within a guest.
    • Privacy for small client side proofs and the bulk of proof computational overhead outsourced to an untrusted prover.
    • Reuse of existing proofs included in new proof using their journal
    • Batching/compression of many proofs
    • Proof transposition for compatibility of specific verifiers.
  • Execution is near zero overhead, proving is high overhead.
    • Realtime exec & prove in parallel / after / remote is possible
  • What killer features does R0 provide?

๐ŸŽ‡ What is special about RISC Zero? (3)

โ›“๏ธ EVM Support

Notes:

  • Zeth could run existing solidity games off chain, optionally unbounded computation per block (gasless). Zeth deep dive
  • mention: 256 view call limit - could you do inclusion proof checkpoints? contract state is simply recursive proof of minimal thing needed (maybe block header / hash?) updated by anyone to use for deep archival view calls? prove "this state was in block X that is a child of recent block {younger than 256}"

๐ŸŽ‡ What is special about RISC Zero? (4)

โœจZypher Support

poker0 โ†—๏ธ

A poker game leveraging RISC Zero and PLONK for off-chain proof of game processes, with on-chain validation, built on the Z4 engine.

Notes:

Take heed: This perhaps is a rather complex starting point from without any experience with RISC Zero or PLONK, we suggest experimenting with the more basic RISC Zero examples first to get a feel for things first!


๐Ÿคฟ Before you dive deep...

  • You must match versions of cargo risczero and your Cargo.toml deps
    ย  Some examples / templates may not be the version you need!
    ย  Bonsai (proving service) is 0.21, updating mid-July 2024 to 1.0
  • Keep guest minimal - extra cycles are expensive
    ย  ...But this is a hackathon, don't stress too much!
  • When experimenting, always use DEV_MODE!
    ย  Execution only with mocked proving (fast!)
  • Bonsai API key priority & support
    ย  Apply: bonsai.xyz/
  • ๐Ÿง  You are designing a cryptographic system, not just a game!
  • Discord #๐Ÿ’ป|support-forum channel for help
    ย  Join: discord.gg/risczero

Further Reading & Resources

Nuke ๐ŸŒ„'s Book โ†—๏ธ

  • ๐Ÿ—ƒ๏ธ More details and research links
  • ๐Ÿชง These slides (fuzzy-searchable!)
  • ๐Ÿ‘ท ZK Chess Checkmate Workshop (+videos)