proof generation + verification complete
This commit is contained in:
parent
01ec9bdf7d
commit
92a83bb58e
5 changed files with 41 additions and 20 deletions
3
program/Cargo.lock
generated
3
program/Cargo.lock
generated
|
@ -383,8 +383,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha2"
|
name = "sha2"
|
||||||
version = "0.10.8"
|
version = "0.10.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.10.8#3d692aa90b91513886d757d01f8fc2d51c0ec0d7"
|
||||||
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
|
|
|
@ -9,3 +9,6 @@ sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git" }
|
||||||
mtcs-core = {path = "../core"}
|
mtcs-core = {path = "../core"}
|
||||||
rs_merkle = "1.4.2"
|
rs_merkle = "1.4.2"
|
||||||
bincode = "1.3.3"
|
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" }
|
||||||
|
|
21
script/Cargo.lock
generated
21
script/Cargo.lock
generated
|
@ -1533,10 +1533,22 @@ dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mtcs-core"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtcs-sp1-script"
|
name = "mtcs-sp1-script"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bincode",
|
||||||
|
"hex",
|
||||||
|
"mtcs-core",
|
||||||
|
"rs_merkle",
|
||||||
|
"serde_json",
|
||||||
"sp1-helper",
|
"sp1-helper",
|
||||||
"sp1-sdk",
|
"sp1-sdk",
|
||||||
]
|
]
|
||||||
|
@ -2425,6 +2437,15 @@ dependencies = [
|
||||||
"paste",
|
"paste",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rs_merkle"
|
||||||
|
version = "1.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3b241d2e59b74ef9e98d94c78c47623d04c8392abaf82014dfd372a16041128f"
|
||||||
|
dependencies = [
|
||||||
|
"sha2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.23"
|
version = "0.1.23"
|
||||||
|
|
|
@ -6,6 +6,11 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git" }
|
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]
|
[build-dependencies]
|
||||||
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" }
|
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" }
|
||||||
|
|
|
@ -1,37 +1,30 @@
|
||||||
// These constants represent the RISC-V ELF and the image ID generated by risc0-build.
|
// 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.
|
// The ELF is used for proving and the ID is used for verification.
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use methods::{PROVER_ELF, PROVER_ID};
|
|
||||||
use mtcs_core::*;
|
use mtcs_core::*;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
use rs_merkle::{algorithms::Sha256 as MerkleSha256, Hasher, MerkleTree};
|
use rs_merkle::{algorithms::Sha256 as MerkleSha256, Hasher, MerkleTree};
|
||||||
use std::time::SystemTime;
|
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");
|
const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Initialize tracing. In order to view logs, run `RUST_LOG=info cargo run`
|
utils::setup_logger();
|
||||||
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().
|
|
||||||
let start_time = SystemTime::now();
|
let start_time = SystemTime::now();
|
||||||
|
|
||||||
println!("generating guest inputs...");
|
println!("generating guest inputs...");
|
||||||
// For example:
|
// For example:
|
||||||
let key: Vec<u8> = "passw0rdpassw0rdpassw0rdpassw0rd".as_bytes().to_vec();
|
let key: Vec<u8> = "passw0rdpassw0rdpassw0rdpassw0rd".as_bytes().to_vec();
|
||||||
|
|
||||||
let secret = PrivateKey { key };
|
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<Obligation> = serde_json::from_str("obligations.json").expect("JSON was not well-formatted");
|
||||||
|
|
||||||
let cycle: Cycle = Cycle {
|
let cycle: Cycle = Cycle {
|
||||||
setoff: 103,
|
setoff: 103,
|
||||||
size: 3,
|
size: 3,
|
||||||
|
@ -175,7 +168,7 @@ fn main() {
|
||||||
|
|
||||||
println!("generating proof...");
|
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!");
|
println!("proof generation completed!");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue