diff --git a/program/Cargo.lock b/program/Cargo.lock index 94bd485..d0c729e 100644 --- a/program/Cargo.lock +++ b/program/Cargo.lock @@ -383,8 +383,7 @@ dependencies = [ [[package]] name = "sha2" version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.10.8#3d692aa90b91513886d757d01f8fc2d51c0ec0d7" dependencies = [ "cfg-if", "cpufeatures", diff --git a/program/Cargo.toml b/program/Cargo.toml index 6050eb0..265476a 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -9,3 +9,6 @@ sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git" } mtcs-core = {path = "../core"} rs_merkle = "1.4.2" bincode = "1.3.3" + +[patch.crates-io] +sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" } diff --git a/script/Cargo.lock b/script/Cargo.lock index 250cc72..7102eb8 100644 --- a/script/Cargo.lock +++ b/script/Cargo.lock @@ -1533,10 +1533,22 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mtcs-core" +version = "0.1.0" +dependencies = [ + "serde", +] + [[package]] name = "mtcs-sp1-script" version = "0.1.0" dependencies = [ + "bincode", + "hex", + "mtcs-core", + "rs_merkle", + "serde_json", "sp1-helper", "sp1-sdk", ] @@ -2425,6 +2437,15 @@ dependencies = [ "paste", ] +[[package]] +name = "rs_merkle" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b241d2e59b74ef9e98d94c78c47623d04c8392abaf82014dfd372a16041128f" +dependencies = [ + "sha2", +] + [[package]] name = "rustc-demangle" version = "0.1.23" diff --git a/script/Cargo.toml b/script/Cargo.toml index 8c59a7a..56bb12b 100644 --- a/script/Cargo.toml +++ b/script/Cargo.toml @@ -6,6 +6,11 @@ edition = "2021" [dependencies] sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git" } +mtcs-core = {path = "../core"} +rs_merkle = "1.4.2" +bincode = "1.3.3" +hex = "0.4.3" +serde_json = "1.0" [build-dependencies] -sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" } \ No newline at end of file +sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" } diff --git a/script/src/main.rs b/script/src/main.rs index 6602bc0..f818ab7 100644 --- a/script/src/main.rs +++ b/script/src/main.rs @@ -1,37 +1,30 @@ // 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 bincode::serialize; -use methods::{PROVER_ELF, PROVER_ID}; use mtcs_core::*; +use std::fs; use rs_merkle::{algorithms::Sha256 as MerkleSha256, Hasher, MerkleTree}; use std::time::SystemTime; -use sp1_sdk::{SP1Prover, SP1Stdin, SP1Verifier}; +use sp1_sdk::{SP1Prover, SP1Stdin, SP1Verifier, utils}; const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); fn main() { - // Initialize tracing. In order to view logs, run `RUST_LOG=info cargo run` - env_logger::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 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(). + utils::setup_logger(); let start_time = SystemTime::now(); + println!("generating guest inputs..."); // For example: let key: Vec = "passw0rdpassw0rdpassw0rdpassw0rd".as_bytes().to_vec(); let secret = PrivateKey { key }; + // let cycle_data: String = fs::read_to_string("../cycle.json").unwrap(); + + // let cycle: Cycle = serde_json::from_str(&cycle_file.to_owned()).expect("JSON not well formatted"); +// let all_obligations: Vec = serde_json::from_str("obligations.json").expect("JSON was not well-formatted"); + let cycle: Cycle = Cycle { setoff: 103, size: 3, @@ -175,7 +168,7 @@ fn main() { println!("generating proof..."); - let mut proof = SP1Prover::prove(ELF, stdin).expect("proving failed"); + let proof = SP1Prover::prove(ELF, stdin).expect("proving failed"); println!("proof generation completed!");