data size passed as environment variable argument in composition

This commit is contained in:
Manish Kumar 2024-01-25 23:35:41 +05:30
parent d0dda87066
commit f4b4d6e6e6
8 changed files with 42 additions and 8 deletions

1
.gitmodules vendored
View File

@ -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

7
hash/risc0/README.md Normal file
View File

@ -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`.

View File

@ -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",
]

View File

@ -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);
}

View File

@ -1 +1 @@
./target/release/composition
./target/release/composition 32

View File

@ -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<String> = std::env::args().collect();
if args.len() != 2 {
println!("Wrong number of arguments! The program expects one arguments: <size>");
// Exit the program with a non-zero exit code
process::exit(1);
}
let data_size = args[1].parse::<usize>().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();

@ -1 +1 @@
Subproject commit a4d2b5d95685554ee34a39d60b40fa2c5deff57a
Subproject commit 1742ef8098d246871055501a0559811c9a8fece4

View File

@ -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<String> = std::env::args().collect();
if args.len() != 2 {
println!("Wrong number of arguments! The program expects two arguments: <number_of_composition> and <size>");
// Exit the program with a non-zero exit code
process::exit(1);
}
let data_size = args[1].parse::<usize>().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(