Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Risc0 cw verifier #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions risc0-cw-verifier/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
9 changes: 9 additions & 0 deletions risc0-cw-verifier/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "risc0-cw-verifier"
version = "0.1.0"
edition = "2021"

[dependencies]
risc0-zkp = { version = "0.21.0", default-features = false }
risc0-zkvm = { version = "0.21.0", default-features = false }

6 changes: 6 additions & 0 deletions risc0-cw-verifier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# risc0 verifier for WASM

```shell
$ # check that code compiles on WASM target
$ cargo wasm
```
32 changes: 32 additions & 0 deletions risc0-cw-verifier/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use risc0_zkp::core::digest::Digest;
use risc0_zkvm::{ExitCode, InnerReceipt, Journal, Receipt, ReceiptClaim, SystemState};

fn main() {
// create dummy receipt
// TODO: replace this with code for deserializing a real receipt
let receipt = Receipt {
inner: InnerReceipt::Fake {
claim: ReceiptClaim {
pre: SystemState {
pc: 0,
merkle_root: Digest::ZERO,
}
.into(),
post: SystemState {
pc: 0,
merkle_root: Digest::ZERO,
}
.into(),
exit_code: ExitCode::Halted(0),
input: Digest::ZERO.into(),
output: None.into(),
},
},
journal: Journal { bytes: vec![] },
};

// Verify receipt, panic if it's wrong
receipt
.verify(Digest::ZERO)
.expect("dummy receipt fails to verify");
}