diff --git a/.gitmodules b/.gitmodules index 27593ef..e579aae 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,4 +16,3 @@ [submodule "hash/risc0/external/risc0"] path = hash/risc0/external/risc0 url = https://github.com/risc0/risc0.git - branch = release-0.20 diff --git a/hash/risc0/README.md b/hash/risc0/README.md new file mode 100644 index 0000000..edaa9ab --- /dev/null +++ b/hash/risc0/README.md @@ -0,0 +1,7 @@ +Benchmarking inside risc'0 zkvm +-------------------------------- + +- `external` folder contains risc0 as a git submodule. +- `bench` folder contains the benchmarking for different hash functions. Go to the `bench/README.md` for more details. +- `inner_proof` folder contains methods for generating the Receipt for sha256 which is being used as an inner proof in `composition` +- `composition` folder contains methods of proof composition which uses `inner_proof`. diff --git a/hash/risc0/composition/Cargo.lock b/hash/risc0/composition/Cargo.lock index 9e5e2c8..d2dff75 100644 --- a/hash/risc0/composition/Cargo.lock +++ b/hash/risc0/composition/Cargo.lock @@ -398,9 +398,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" dependencies = [ "serde", ] diff --git a/hash/risc0/composition/methods/guest/src/main.rs b/hash/risc0/composition/methods/guest/src/main.rs index 3d2cecf..1f30186 100644 --- a/hash/risc0/composition/methods/guest/src/main.rs +++ b/hash/risc0/composition/methods/guest/src/main.rs @@ -18,8 +18,9 @@ use risc0_zkvm::sha; fn main() { let hash: sha::Digest = env::read(); - + let hash2: sha::Digest = env::read(); env::verify(INNER_PROOF_METHOD_ID, &serde::to_vec(&hash).unwrap()).unwrap(); + env::verify(INNER_PROOF_METHOD_ID, &serde::to_vec(&hash2).unwrap()).unwrap(); env::commit(&hash); } diff --git a/hash/risc0/composition/run.sh b/hash/risc0/composition/run.sh index 7acdd03..bd6dfec 100755 --- a/hash/risc0/composition/run.sh +++ b/hash/risc0/composition/run.sh @@ -1 +1 @@ -./target/release/composition \ No newline at end of file +./target/release/composition 32 \ No newline at end of file diff --git a/hash/risc0/composition/src/main.rs b/hash/risc0/composition/src/main.rs index 470bfe7..9a6a17b 100644 --- a/hash/risc0/composition/src/main.rs +++ b/hash/risc0/composition/src/main.rs @@ -17,18 +17,33 @@ use inner_proof::sha_bench; use risc0_zkvm::{default_prover, ExecutorEnv}; use risc0_zkvm::sha; use std::time::Instant; +use std::process; fn main() { - let (hash_receipt, hash) = sha_bench(32); + let args: Vec = std::env::args().collect(); + if args.len() != 2 { + println!("Wrong number of arguments! The program expects one arguments: "); + // Exit the program with a non-zero exit code + process::exit(1); + } + + let data_size = args[1].parse::().unwrap(); + let t0 = Instant::now(); + let (hash_receipt, hash) = sha_bench(data_size.try_into().unwrap()); + let (hash_receipt2, hash2) = sha_bench(data_size.try_into().unwrap()); + let env = ExecutorEnv::builder() // add_assumption makes the receipt to be verified available to the prover. .add_assumption(hash_receipt) .write(&hash) .unwrap() + .add_assumption(hash_receipt2) + .write(&hash2) + .unwrap() .build() .unwrap(); diff --git a/hash/risc0/external/risc0 b/hash/risc0/external/risc0 index a4d2b5d..1742ef8 160000 --- a/hash/risc0/external/risc0 +++ b/hash/risc0/external/risc0 @@ -1 +1 @@ -Subproject commit a4d2b5d95685554ee34a39d60b40fa2c5deff57a +Subproject commit 1742ef8098d246871055501a0559811c9a8fece4 diff --git a/hash/risc0/inner_proof/src/main.rs b/hash/risc0/inner_proof/src/main.rs index 50c6f19..0bb1c0d 100644 --- a/hash/risc0/inner_proof/src/main.rs +++ b/hash/risc0/inner_proof/src/main.rs @@ -11,9 +11,21 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. use inner_proof::sha_bench; use inner_proof_methods::INNER_PROOF_METHOD_ID; +use std::process; fn main() { - let (receipt, _output) = sha_bench(32); + + let args: Vec = std::env::args().collect(); + + if args.len() != 2 { + println!("Wrong number of arguments! The program expects two arguments: and "); + // Exit the program with a non-zero exit code + process::exit(1); + } + + let data_size = args[1].parse::().unwrap(); + + let (receipt, _output) = sha_bench(data_size.try_into().unwrap()); // Verify receipt, panic if it's wrong receipt.verify(INNER_PROOF_METHOD_ID).expect(