proof generation + verification complete

This commit is contained in:
Ajinkya Kulkarni 2024-04-17 14:35:00 +02:00
parent 01ec9bdf7d
commit 92a83bb58e
5 changed files with 41 additions and 20 deletions

3
program/Cargo.lock generated
View file

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

View file

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

21
script/Cargo.lock generated
View file

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

View file

@ -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" }
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" }

View file

@ -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<u8> = "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<Obligation> = 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!");