Skip to content

Commit

Permalink
montreal add workshop details
Browse files Browse the repository at this point in the history
  • Loading branch information
nuke-web3 committed Aug 6, 2024
1 parent 60852fe commit aed69e7
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 20 deletions.
4 changes: 2 additions & 2 deletions content/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
- [🪧 Verifiable Games Using RISC Zero](./risc-zero/zypher-buildathon/presentation.md)
- [👷 ZK Chess Checkmate](./risc-zero/zypher-buildathon/workshop.md)
- [🗃️ ZK Hack - Montreal - August 2024](./risc-zero/zk-hack-montreal/materials.md)
- [🪧 No Circuits Required - Building ZK Proof Systems in Pure Rust](./risc-zero/zk-hack-montreal/presentation.md)
- [👷 ZK ERC20 Balance of EDCSA Verified Account](./risc-zero/zk-hack-montreal/workshop.md)
- [🪧 Boundless On-chain Execution Using Proven Off-chain Coprocessing](./risc-zero/zk-hack-montreal/presentation.md)
- [👷 Prove ERC20 Balance of ECDSA Verified Account Owner](./risc-zero/zk-hack-montreal/workshop.md)

- [🙋 Contribute](./contribute/index.md)
- [🌀 Topic Template](./contribute/template/page.md)
Expand Down
2 changes: 1 addition & 1 deletion content/risc-zero/zk-hack-montreal/presentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# No Circuits Required - Building ZK Proof Systems in Pure Rust
# Boundless On-chain Execution Using Proven Off-chain Coprocessing

<!-- markdown-link-check-disable -->
<center>
Expand Down
28 changes: 20 additions & 8 deletions content/risc-zero/zk-hack-montreal/slides.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: No Circuits Required - Building ZK Proof Systems in Pure Rust
title: Boundless On-chain Execution Using Proven Off-chain Coprocessing
tags: RISC Zero, Talk, Presentation, Workshop, zkVM, Steel, EVM, Hackathon, Zero Knowledge Proof, Applied Cryptography, Rust, ZK Hack, Montreal
duration: 60 minuets
description: RISC Zero Workshop for the Zypher Provable Games Buildathon - June 2024
Expand All @@ -23,17 +23,25 @@ revealOptions:

<section data-background-opacity=0.3>

# No Circuits Required
# Boundless On-chain Execution

## Building ZK Proof Systems in _Pure Rust_
## Using Proven Off-chain Coprocessing

<img rounded style="width: 50%; height: 230px; object-fit: cover;" src="./img/fusion-dragon-ball.gif" />

<!-- FIXME: Math doesn't render offline! jsdeliver hard coded.-->

**_On-chain_ $~~~$ 👉 $ZK$ 👈 $~~~$ _Off-chain_**

<a target="_blank" href="https://nuke-web3.github.io/book/risc-zero/zk-hack-montreal/materials.html">Event Materials ↗️</a>

---

## Why RISC Zero?

### _Write Rust 🦀<br/> Not Circuits 𝛌_
> ### _Write Rust 🦀_
>
> ### _Not Circuits 𝛌_
Notes:

Expand Down Expand Up @@ -126,7 +134,7 @@ Notes:

---

## RISC Zero On-chain
## RISC Zero 🤝 EVM Chains

<img rounded style="width: 60%;" src="./img/risc0-ethereum-bonsai.png" />

Expand All @@ -136,7 +144,7 @@ Notes:

# ✨ Inspiration

##### ⚠️ -- Do not copy 🍝 -- 🙏
> #### ⚠️ &nbsp; Do **not** copy 🍝 &nbsp; ⚠️
Notes:

Expand All @@ -158,8 +166,12 @@ Notes:

---

## Proven Historical State of EVM

<img rounded style="width: 50%; height: 50%; object-fit: cover;" src="./img/steel-banner.png" />

> A trustless "off-chain worker" for EVM RPC calls, and more!
Notes:

Want to build even more complicated or otherwise impossible contract logic?
Expand Down Expand Up @@ -197,7 +209,7 @@ Notes:
## 🎇 What is special about RISC Zero? (2)

- Proof <a target="_blank" href="https://www.risczero.com/blog/continuations">continuation</a>
<br/>&nbsp; Unbounded guest programs
<br/>&nbsp; Boundless guest programs
- Proof <a target="_blank" href="https://www.risczero.com/blog/proof-composition">composition</a>
<br/>&nbsp; "Proof-ception"
<br/>&nbsp; Hybrid Client side {🕵️privacy} & server {🦾power}
Expand Down Expand Up @@ -248,4 +260,4 @@ Notes:
- Discord `#💻|support-forum` channel for help
<br/>&nbsp; Join: <a target="_blank" href="https://discord.com/invite/risczero">discord.gg/risczero</a>

> 🧠 Don't need to know the crypto details to build...<br/> don't forget you are building a cryptographic system!
> 🧠 Don't need to know the crypto details to build...<br/> BUT don't forget you are building a cryptographic system!
63 changes: 54 additions & 9 deletions content/risc-zero/zk-hack-montreal/workshop.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
## ZK ERC20 Balance of ECDSA Verified Account (R0 v1.0)
# Prove ERC20 Balance of Verified Account Owner (R0 v1.0)

### _Signing and Steeling_
## 👷 _Signing and Steeling_

Let's experiment with the powers provided by the [Steel library](https://github.com/risc0/risc0-ethereum/tree/main/steel) by taking the ERC20 example and extending it.
The base example only proves that some address holds a balance, with the essential proof being "Some address holds over 1 token at some ERC20 contract at the most recent block"
That isn't a particularly useful statement... let's constrain the proof a bit more to assert that the prover also holds the key to the account in question.
Let's experiment with the powers provided by the [Steel library](https://github.com/risc0/risc0-ethereum/tree/main/steel) by taking the [base ERC20 example](https://github.com/risc0/risc0-ethereum/tree/main/examples/erc20) and extending it with the [base ECDSA example](https://github.com/risc0/risc0/tree/main/examples/ecdsa).
The ERC20 example only proves that some address holds a balance, with the essential proof being "Some address holds over 1 token at some ERC20 contract at the most recent block"
That isn't a particularly useful statement... in our case we want to know that the **owner** of some account has a balance.

> NOTE: The address and contract are optionally hidden to the verifier, so we can know the prover has a balance, but not DOX them!
### 🫡 Our Mission

_**Constrain**_ the ERC20 example to _**assert**_ that the **prover** also holds the key to the account we are checking the balance of, hence is the "owner".
We do this by verifying a ECDSA signature for the EVM account in question.

_NOTE: The address and contract are optionally hidden to the verifier, so we can know the prover has a balance, but not DOX them!_

### 🚀 Let's GO!

1. Watch <a target="_blank" href="https://www.youtube.com/playlist?list=PLcPzhUaCxlCj7wKkzekYYq7QDvtGTOPm7">this playlist</a> to learn the basics of RISC Zero.
1. Use `rzup` to setup your development environment based on the **correct version of the <a target="_blank" href="https://dev.risczero.com/api/">RISC Zero Getting Started Docs</a>** for you.
Expand All @@ -16,18 +23,56 @@ That isn't a particularly useful statement... let's constrain the proof a bit mo
# Follow command instructions to use rzup
# ... This will take a while first time!
```
1. TODO workshop repo will be up soon™️
1. <a target="_blank" href="https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template#creating-a-repository-from-a-template">Generate a new repo from the template</a> for <a target="_blank" href="https://github.com/nuke-web3/signing-and-steeling">this workshop source</a>:
```sh
# Clone direct, or your new repo fom this template:
git clone https://github.com/<YOUR_GH_USER>/risc0-v1-chess
# **OR** Clone the template direct:
git clone https://github.com/nuke-web3/signing-and-steeling
cd signing-and-steeling
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 and key files:
```sh
signing-and-steeling
├── README.md
├── Cargo.toml # 📝 Config = MUST use consistent R0 versions!
├── methods
│ └── guest
│ └── src
│ └── main.rs # 🧰 Guest = Game Logic to be proven 🌟
└── src
└── main.rs # 🏃 Host = Execution of guest & GUI & more unproven
```
Other files may need some minor adjustments, but is essentially boilerplate for the context of this workshop.

1. Extend the ERC20 balance check to ensure that the **prover is the owner of the account being checked.**

<details>
<summary>⚠️ <b>SPOILERS</b> ⚠️</summary>

> <a target="_blank" href="https://github.com/nuke-web3/signing-and-steeling/pull/1">One possible solution with comments and tips</a>

</details>

## 📝 Key Takeaways

- Use crates in the zkVM without modification - no need to rewrite in circuits or zkDSL!
- Use standard patterns like `println!` & `fmt!` normally for basic experiments and debugging in `DEV_MODE`.
- 10s on lines of code overall -> useful proof, easily extensible!
- There is still many risks of creating privacy and security faults via bugs and all the normal ways cryptographic systems can break down...
_**With zkVMs you are abstracting the math/circuits of zk... NOT the robust design and audits required to harden your system!**_

> 🧠 You don't need to know the deeper cryptographic details to build proof systems using zkVMs... BUT don't forget you are building a _cryptographic system!_
>
>**With zkVMs you are NOT abstracting the requirement for robust design and audits of your proof system!**

## 🤓 Taking it Further

Here are some ideas to keep extending this example to learn more:

- Soon™️
- Take the core logic and host workflows and embed them into a **coprocessor**with the [Foundry Template](https://github.com/risc0/risc0-foundry-template)- NOTE: versions MUST match throughout for `Cargo.toml` with respect to `risc0-...` dependencies.
- Fix the replay attack inherent in this example to ensure the prover is the key holder, rather than anyone that has a valid signed message for this proof.
- Bench and optimize the guest program, as there are likely ways to make this example _much_ more performant!

0 comments on commit aed69e7

Please sign in to comment.