aboutsummaryrefslogtreecommitdiff
path: root/zkvms/risc0
diff options
context:
space:
mode:
authorKamen Mladenov <kamen@syndamia.com>2025-02-10 14:06:57 +0200
committerKamen Mladenov <kamen@syndamia.com>2025-02-10 14:06:57 +0200
commitd69e4e7f11ff45e82dace6b861aebe665dccb303 (patch)
tree4a9ec5409bd16c749b4383c1054b0e2974b3893f /zkvms/risc0
parent360ff374f5c4b32337e9c2259bbe9077455c360c (diff)
downloadzkVMs-benchmarks-d69e4e7f11ff45e82dace6b861aebe665dccb303.tar
zkVMs-benchmarks-d69e4e7f11ff45e82dace6b861aebe665dccb303.tar.gz
zkVMs-benchmarks-d69e4e7f11ff45e82dace6b861aebe665dccb303.zip
docs(zkvms/risc0): Add detailed documentation comments
Diffstat (limited to 'zkvms/risc0')
-rw-r--r--zkvms/risc0/guest/Cargo.toml7
-rw-r--r--zkvms/risc0/host/src/main.rs1
-rw-r--r--zkvms/risc0/wrapper_macro/src/lib.rs26
3 files changed, 33 insertions, 1 deletions
diff --git a/zkvms/risc0/guest/Cargo.toml b/zkvms/risc0/guest/Cargo.toml
index 4495781..08fda0b 100644
--- a/zkvms/risc0/guest/Cargo.toml
+++ b/zkvms/risc0/guest/Cargo.toml
@@ -1,10 +1,15 @@
[package]
name = "guest"
+description = "RISC0's specific guest crate, which includes the chosen guest in guests"
version = "0.1.0"
edition = "2021"
[workspace]
[dependencies]
-wrapper_macro = { version = "0.1.0", path = "../wrapper_macro" }
risc0-zkvm = { path = "/nix/store/l1rxg23rrrdwi9cf6rc82mqavklvqc18-risc0-unstable-2024-12-21/risc0/zkvm", default-features = false, features = ['std'] }
+
+wrapper_macro = { version = "0.1.0", path = "../wrapper_macro" }
+
+# The zkp dependency references a chosen guest in guests. It is included
+# (inserted here) by Nix. See zkvmLib.nix
diff --git a/zkvms/risc0/host/src/main.rs b/zkvms/risc0/host/src/main.rs
index 624b3f2..6428d84 100644
--- a/zkvms/risc0/host/src/main.rs
+++ b/zkvms/risc0/host/src/main.rs
@@ -6,6 +6,7 @@ use hex::FromHex;
// https://github.com/risc0/risc0/blob/881e512732eca72849b2d0e263a1242aba3158af/risc0/build/src/lib.rs#L280-L284
static HELLO_GUEST_ELF: &[u8] = include_bytes!("./guest");
// https://github.com/risc0/risc0/blob/881e512732eca72849b2d0e263a1242aba3158af/risc0/build/src/lib.rs#L255
+// Generated by Nix, see zkvms/risc0/default.nix
static HELLO_GUEST_ID: &str = env!("GUEST_ID");
fn build_env(input: &Input) -> ExecutorEnv {
diff --git a/zkvms/risc0/wrapper_macro/src/lib.rs b/zkvms/risc0/wrapper_macro/src/lib.rs
index 22afa44..24eddd4 100644
--- a/zkvms/risc0/wrapper_macro/src/lib.rs
+++ b/zkvms/risc0/wrapper_macro/src/lib.rs
@@ -4,6 +4,32 @@ use proc_macro::TokenStream;
mod parse_fn;
use crate::parse_fn::{ split_fn, args_split, args_divide_public, args_divide_grouped };
+/// Create a body, which reads all inputs, stores them in variables, then
+/// commits the ones, defined as public in `default_public_input.toml` to the
+/// journal and finally executes the guest entrypoint function with those
+/// arguments, committing its output.
+///
+/// # Usage
+///
+/// Inside RISC0's guest (excluding the `entrypoint_expr` call):
+///
+/// ```rust
+/// make_wrapper!{fn main(...) -> ...}
+/// ```
+///
+/// # Example output
+///
+/// ```rust
+/// {
+/// let ... : ... = read();
+/// let ... : ... = read();
+/// ...
+/// commit(&...);
+/// commit(&...);
+/// ...
+/// commit(&zkp::main(..., ..., ...));
+/// }
+/// ```
#[proc_macro]
pub fn make_wrapper(item: TokenStream) -> TokenStream {
let (name, args, ret) = split_fn(&item);