diff --git a/content/SUMMARY.md b/content/SUMMARY.md index 2541870..031f410 100644 --- a/content/SUMMARY.md +++ b/content/SUMMARY.md @@ -11,9 +11,7 @@ - [๐Ÿชง Verifiable Games Using RISC Zero](./risc-zero/zypher-buildathon/presentation.md) - [๐Ÿ‘ท ZK Chess Checkmate](./risc-zero/zypher-buildathon/workshop.md) ---- - -- [๐Ÿ™‹ Guide](./contribute/index.md) +- [๐Ÿ™‹ Contribute](./contribute/index.md) - [๐ŸŒ€ Topic Template](./contribute/template/page.md) - [๐Ÿ“‹ Copy & Paste Slides](./contribute/copy-paste-slides/page.md) diff --git a/content/risc-zero/zypher-buildathon/img/bevy-alien-cake-addict.gif b/content/risc-zero/zypher-buildathon/img/bevy-alien-cake-addict.gif new file mode 100644 index 0000000..7f51e2f Binary files /dev/null and b/content/risc-zero/zypher-buildathon/img/bevy-alien-cake-addict.gif differ diff --git a/content/risc-zero/zypher-buildathon/img/risc0-ethereum-bonsai.png b/content/risc-zero/zypher-buildathon/img/risc0-ethereum-bonsai.png new file mode 100644 index 0000000..607a0ec Binary files /dev/null and b/content/risc-zero/zypher-buildathon/img/risc0-ethereum-bonsai.png differ diff --git a/content/risc-zero/zypher-buildathon/img/zkVM-diagram-black.png b/content/risc-zero/zypher-buildathon/img/zkVM-diagram-black.png new file mode 100644 index 0000000..dccab16 Binary files /dev/null and b/content/risc-zero/zypher-buildathon/img/zkVM-diagram-black.png differ diff --git a/content/risc-zero/zypher-buildathon/materials.md b/content/risc-zero/zypher-buildathon/materials.md index 3474cb4..8ad0a55 100644 --- a/content/risc-zero/zypher-buildathon/materials.md +++ b/content/risc-zero/zypher-buildathon/materials.md @@ -40,8 +40,8 @@ Here are a few key game specific ones: -โ˜๏ธ A fantastic verteran review of their work and showcases fundementally new type of game that web3 makes possible: build base infrastructure for others **to build on top of _permissionlessly_**. -Shared infra -> purality of ways to interact with a wider community on the same base layer opens up novel MMO games _**built by and for players**_! +โ˜๏ธ A fantastic veteran review of their work and showcases fundamentally new type of game that web3 makes possible: build base infrastructure for others **to build on top of _permissionless_**. +Shared infra -> plurality of ways to interact with a wider community on the same base layer opens up novel MMO games _**built by and for players**_! Although today zkVMs help devs avoid needing to write most of the game in some contract language or (zk)DSL, like is enabled in RISC Zero with the bevy game engine. And it's very likely to be far more cost effective to run too! diff --git a/content/risc-zero/zypher-buildathon/slides.md b/content/risc-zero/zypher-buildathon/slides.md index 6ed6f4f..6398a27 100644 --- a/content/risc-zero/zypher-buildathon/slides.md +++ b/content/risc-zero/zypher-buildathon/slides.md @@ -1,5 +1,5 @@ --- -title: Verifiale Games Using RISC Zero +title: Verifiable Games Using RISC Zero tags: RISC Zero, Talk, Presentation, Workshop, zkVM, zkGames, Zypher, Hackathon, Buildathon, Zero Knowledge Proof, Applied Cryptography, Rust, Zypher duration: 60 minuets description: RISC Zero Workshop for the Zypher Provable Games Buildathon - June 2024 @@ -37,9 +37,9 @@ revealOptions: -**_On-chain_ $~~~$ ๐Ÿ‘‰ $ZK$ ๐Ÿ‘ˆ $~~~$ _Off-chain_** +**_On-chain_ $~~~$ ๐Ÿ‘‰ $ZK$ ๐Ÿ‘ˆ $~~~$ _Off-chain_** -Workshop Materials โ†—๏ธ +Event Materials โ†—๏ธ --- @@ -60,20 +60,31 @@ Notes: ## What problems can ZK address for games? -On-chain (coprocessor): + + + +### On-chain & Web3 - calldata limits restrict complexity -- gas costs are prohibitive -- public blockchains donโ€™t support incomplete information games -- Zypherโ€™s bullet points for challenges of on-chain gaming +- prohibitive gas costs +- most blockchains lack privacy + + + -Off-chain (TODO): +### Off-chain & Web2 - Cheating through manipulation of official game logic -- Private game aspects without any 3rd party / admin to adjudicate. +- 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) @@ -85,7 +96,6 @@ Notes: - 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. -- todo Mention alternatives? Why we are a good or the best choice? (privacy possible, not solidity or DSL specific) - 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! --- @@ -100,22 +110,34 @@ Developers are encouraged to implement game designs that can verify player actio --- -## Definitions & Lingo +## RISC Zero 101 -- TODO diagram of host that encapsulates guest w/ input & output -- see https://www.youtube.com/watch?v=DzOWh3Ht0_Q & get diagrams + + +> Read Getting Started and/or watch the playlist. Notes: - deeper understanding as exercise for views of this presentation. - See the official docs & youtube for great deep - 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 -> :warning: _Do not copy&paste submissions_ :pray: +##### โš ๏ธ -- Do not copy ๐Ÿ -- ๐Ÿ™ Notes: @@ -126,25 +148,27 @@ Building on them to something significantly enhancements _**may**_ be considered ## ZK Checkmate Demo - + -Join in following the [Hands-on instructions โ†—๏ธ](./checkmate-chess-example.md) +Join in following the [Hands-on instructions โ†—๏ธ](./workshop.md) Notes: -- Chess demo for verifying a winning move (checkmate) without revealing what the move is. - Contrived example a bit, but highlights: - - use crates without modification - no need to rewrite in circuits or zkDSL! - - Use standard patterns like `println!` & `fmt!` normally for basic experiments. - - 10s on lines of code overall -> useful proof, easily extensible! -- Original [deep dive video](https://www.youtube.com/watch?v=vxqxRiTXGBI&list=PLcPzhUaCxlCgig7ofeARMPwQ8vbuD6hC5&index=10) ([slides](https://drive.google.com/file/d/1Bum4x50qatqBUlQyNVkt90nnA2SEOHNO/view)) +- See the recording there to follow along for an overview. +- I encourage you to experiment yourself! --- -## Bevy (R0 v0.21) +## Bevy (R0 v1.0.1) + +- **Serious** Rust game engine +- Great base to start hackin' ๐Ÿค  +- Start with shared `core` logic + +Notes: -- Serious Rust game engine for ZK games -- BEST place to start to see if you can compile & run this without modification on your machine. +- Core logic can be used in the host & the guest for Bevy games +- Design guest to be _minimal_ as proofs are costly! --- @@ -152,7 +176,7 @@ Notes: -> https://github.com/0xAndoroid/zkSnake +#### zkSnake Source โ†—๏ธ Notes: @@ -163,12 +187,13 @@ Notes: ## 3D ZK Games?! -## โ–ถ๏ธ Bevy Wasm webGPL/webGPU example + -๐Ÿคฏ Zypher Real-time Multiplayer Games Track featured demo! +#### ๐ŸŽฎ Play the Demo ๐ŸŽฎ +- Real-time Multiplayer Games Track featured demo! - Rendered web game + wallet connect -- Original Bevy docs source to generate the playable browser example +- Demo tooling to generate browser example --- @@ -176,7 +201,7 @@ Notes: - developer productivity (@ hackathons & beyond) - Top 1000 [crates.io](https://crates.io/) tested ~nightly: [reports.risczero.com](https://reports.risczero.com/) -- todo: key features that are HARD in zkDLS +- todo: key features that are HARD in zkDSL - proof continuation - execution separate from proof (realtime exec & prove in parallel / after / remote) - foundry template & steel & mainnet verifiers @@ -193,8 +218,22 @@ Notes: --- +## ๐ŸŽจ 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 +- can 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?) + +--- + ## ๐Ÿ“ Key Takeaways +- as a game dev: what does zk do and not do for me? - IMPORTANT: match version of `cargo risczero` & examples / templates / examples - keep guest minimal - extra cycles are VERY expensive (but this is a hackathon, don't over optimize) - USE DEV MODE! @@ -206,46 +245,6 @@ Notes: --- -## TODO - -- You emphasized that the proofs are โ€œverrrryโ€ expensive to build โ€” I think we can dial that back. As a itโ€™s something like 100k-1M times more expensive than native compute. -- Not sure what we can offer re malware/viruses โ€” that felt a bit confusing to me -- Jumping around windows was disorienting โ€” would suggest figuring out the specific ordering of which windows you want to open and try to use more words to flag whatโ€™s about to happen. perhaps even grabbing the relevant screenshots and importing things into the slides rather than doing a live-tour -- Make text bigger pretty much everywhere, but especially in terminal windows -- FEN is a format for notation chess games and chess positions https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation -- Nice job highlighting the idea that you don't have to do everything inside the zkvm -- Would be nice to synthesize the design patterns. i.e., things we can do are: - - Prove transcript of game for verifiable high scores - - Prove state update based on complex game logic. - - Prove validity of player moves while concealing -- Question about pulling something out into core library. -- Typo on last slide re: zkDSL (it says zkDLS) - -youtube description workshop instructions? - -see discord ref page for moving to book - -missing: - -- synthesis of design patterns used in games - - play & prove latter (snake game) - - proof for each hidden move, perhaps in a tx on chain - - can run only core game logic in zkVM - GUI and other non-security/privacy/fairness aspects can live outside the proven core logic (diagram) -- recap - - as a game dev: what does zk do and not do for me? -- randomness - - cannot do within guest - only fake & deterministic random for replay of moves perhaps (who gets to know seed? Choose? VRF maybe?) -- video or screen shots instead of live code -- more diagrams especially wrt games - - how the proof works in game context (seq. diagrams with actors IDed (player, execution, prover)) -- what do we not know about web3 games... more on chain that we know of as a team? -- bigger text (for term especially) -- More about web3 integrations specifically? Does foundry worth with zypher? - - scale solidity games off-chain with Zeth... but should rewrite in rust! - - - ---- - # Further Reading & Resources -- Event Materials โ†—๏ธ +## Event Materials โ†—๏ธ diff --git a/content/risc-zero/zypher-buildathon/workshop.md b/content/risc-zero/zypher-buildathon/workshop.md index b94d6df..98a95b2 100644 --- a/content/risc-zero/zypher-buildathon/workshop.md +++ b/content/risc-zero/zypher-buildathon/workshop.md @@ -1,8 +1,10 @@ ## ZK Checkmate (R0 v1.0) Let's experiment with a ZK chess game for verifying a winning move (a checkmate) is possible next turn without revealing what the move is to anyone. +We extend the example by proving we know a set of moves that arrives at that final board state. -1. Watch this playlist to learn the basics +1. (Optional) Watch a primer on FEN and SAN notation for chess. +1. Watch this playlist to learn the basics of RISC Zero 1. Use `rzup` to setup your development environment based on the **correct version of the RISC Zero Getting Started Docs** for you. ```sh # Get rzup @@ -10,23 +12,25 @@ Let's experiment with a ZK chess game for verifying a winning move (a checkmate) # Follow command instructions to use rzup # ... This will take a while first time! ``` -1. Clone and run the chess example with: +1. Generate a new repo from the template for this chess example: ```sh - git clone --branch v1.0.1 --depth=1 https://github.com/risc0/risc0 - cd risc0 - cd examples/chess + # Clone direct, or your new repo fom this template: + git clone https://github.com//risc0-v1-chess + # **OR** Clone the template direct: + git clone https://github.com/nuke-web3/risc0-v1-chess + cd risc0-v1-chess cargo r -r # ... This will take a while first time! # If you get errors, see step one to get setup! ``` -1. Take a look at the structure of the code: +1. Take a look at the structure of the code and key files: ```sh - risc0/examples/chess + risc0/examples/risc0-v1-chess โ”œโ”€โ”€ Cargo.toml โ”œโ”€โ”€ core โ”‚ โ”œโ”€โ”€ Cargo.toml โ”‚ โ””โ”€โ”€ src - โ”‚ โ””โ”€โ”€ lib.rs # SHARED logic (host & guest) + โ”‚ โ””โ”€โ”€ lib.rs # ๐ŸŒ Shared = Host โ†”๏ธ Guest โ”œโ”€โ”€ methods โ”‚ โ”œโ”€โ”€ build.rs โ”‚ โ”œโ”€โ”€ Cargo.toml @@ -34,16 +38,16 @@ Let's experiment with a ZK chess game for verifying a winning move (a checkmate) โ”‚ โ”‚ โ”œโ”€โ”€ Cargo.lock โ”‚ โ”‚ โ”œโ”€โ”€ Cargo.toml โ”‚ โ”‚ โ””โ”€โ”€ src - โ”‚ โ”‚ โ””โ”€โ”€ main.rs # ๐ŸŒŸ Guest = Game Logic to be proven + โ”‚ โ”‚ โ””โ”€โ”€ main.rs # ๐Ÿงฐ Guest = Game Logic to be proven ๐ŸŒŸ โ”‚ โ””โ”€โ”€ src โ”‚ โ””โ”€โ”€ lib.rs โ”œโ”€โ”€ README.md โ””โ”€โ”€ src - โ””โ”€โ”€ main.rs # Host = Execution of guest & GUI & more unproven + โ””โ”€โ”€ main.rs # ๐Ÿƒ Host = Execution of guest & GUI & more unproven ``` 1. Make some changes to: 1. `src/main.rs` to change the FEN game state and see if a non-mate move is detected. - 1. `methods/guest/src/main.rs` to change what is proven about the game. + 1. `methods/guest/src/main.rs` to change what is proven about the game: Perhaps add something to `core/src/lib.rs` around player ID that could be proven? ## ๐Ÿ“ Key Takeaways @@ -55,4 +59,14 @@ This example is a bit contrived as it's a single move that should be easy to spo - 10s on lines of code overall -> useful proof, easily extensible! - Incomplete information games are possible on-chain! Hidden data/moves for players are proven, never revealed to _anyone_! +## ๐Ÿค“ Taking it Further + +Here are some ideas to keep extending this example to learn more: + +- Make the game multiplayer with turns between untrusting parties + - Perhaps using moves signed by players in a state channel type construction, latter proven to arrive at a final winner (only?) in the receipt. +- Integrate with the Foundry Template + - Game with stake or pot to play? + - Verify a winner and dispence funds accordingly. + > Original deep dive video & slides & source - a great reference to supliment, but outdated using R0 v0.12 . diff --git a/tools/styles/base-theme.css b/tools/styles/base-theme.css index 5460be7..d9a76d6 100644 --- a/tools/styles/base-theme.css +++ b/tools/styles/base-theme.css @@ -30,7 +30,7 @@ --r-heading4-size: 1.5em; --r-code-font: monospace; /* custom var */ - --r-code-font-size: 0.75em; + --r-code-font-size: 0.85em; --r-link-color: #cdd06f; --r-link-color-decoration: #fbff96; --r-color-controls: #fbff96;