-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing the installation of risc0 in github workflows
- Loading branch information
1 parent
65aab18
commit d82f667
Showing
12 changed files
with
150 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ Cargo.lock | |
|
||
# Added by cargo | ||
|
||
methods/guest/target | ||
/target | ||
|
||
methods/guest/Cargo.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "methods" | ||
version = "0.1.0" | ||
edition = "2024" | ||
|
||
[build-dependencies] | ||
risc0-build = { version = "1.1.2" } | ||
|
||
[package.metadata.risc0] | ||
methods = ["guest"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
risc0_build::embed_methods(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "guest" | ||
version = "0.1.0" | ||
edition = "2023" | ||
|
||
[workspace] | ||
|
||
[dependencies] | ||
risc0-zkvm = { version = "1.1.2", default-features = false, features = ['std'] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use risc0_zkvm::guest::env; | ||
|
||
fn main() { | ||
// TODO: Implement your guest code here | ||
|
||
// read the input | ||
let input: u32 = env::read(); | ||
|
||
// TODO: do something with the input | ||
|
||
// write public output to the journal | ||
env::commit(&input); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include!(concat!(env!("OUT_DIR"), "/methods.rs")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// These constants represent the RISC-V ELF and the image ID generated by risc0-build. | ||
// The ELF is used for proving and the ID is used for verification. | ||
use methods::{ | ||
HELLO_GUEST_ELF, HELLO_GUEST_ID | ||
}; | ||
use risc0_zkvm::{default_prover, ExecutorEnv}; | ||
|
||
fn main() { | ||
// Initialize tracing. In order to view logs, run `RUST_LOG=info cargo run` | ||
tracing_subscriber::fmt() | ||
.with_env_filter(tracing_subscriber::filter::EnvFilter::from_default_env()) | ||
.init(); | ||
|
||
// An executor environment describes the configurations for the zkVM | ||
// including program inputs. | ||
// An default ExecutorEnv can be created like so: | ||
// `let env = ExecutorEnv::builder().build().unwrap();` | ||
// However, this `env` does not have any inputs. | ||
// | ||
// To add guest input to the executor environment, use | ||
// ExecutorEnvBuilder::write(). | ||
// To access this method, you'll need to use ExecutorEnv::builder(), which | ||
// creates an ExecutorEnvBuilder. When you're done adding input, call | ||
// ExecutorEnvBuilder::build(). | ||
|
||
// For example: | ||
let input: u32 = 15 * u32::pow(2, 27) + 1; | ||
let env = ExecutorEnv::builder() | ||
.write(&input) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
|
||
// Obtain the default prover. | ||
let prover = default_prover(); | ||
|
||
// Proof information by proving the specified ELF binary. | ||
// This struct contains the receipt along with statistics about execution of the guest | ||
let prove_info = prover | ||
.prove(env, HELLO_GUEST_ELF) | ||
.unwrap(); | ||
|
||
// extract the receipt. | ||
let receipt = prove_info.receipt; | ||
|
||
// TODO: Implement code for retrieving receipt journal here. | ||
|
||
// For example: | ||
let _output: u32 = receipt.journal.decode().unwrap(); | ||
|
||
// The receipt was verified at the end of proving, but the below code is an | ||
// example of how someone else could verify this receipt. | ||
receipt | ||
.verify(HELLO_GUEST_ID) | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2024 RISC Zero, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use hello_world::multiply; | ||
use hello_world_methods::MULTIPLY_ID; | ||
|
||
fn main() { | ||
tracing_subscriber::fmt() | ||
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) | ||
.init(); | ||
|
||
// Pick two numbers | ||
let (receipt, _) = multiply(17, 23); | ||
|
||
// Here is where one would send 'receipt' over the network... | ||
|
||
// Verify receipt, panic if it's wrong | ||
receipt.verify(MULTIPLY_ID).expect( | ||
"Code you have proven should successfully verify; did you specify the correct image ID?", | ||
); | ||
} |