diff --git a/cli/src/assets/program/main.rs b/cli/src/assets/program/main.rs index 0947d086ac..d6c371960c 100644 --- a/cli/src/assets/program/main.rs +++ b/cli/src/assets/program/main.rs @@ -5,7 +5,7 @@ extern crate succinct_zkvm; succinct_zkvm::entrypoint!(main); pub fn main() { - let n = 10; + let n = succinct_zkvm::io::read::(); let mut a = 0; let mut b = 1; let mut sum; @@ -14,5 +14,7 @@ pub fn main() { a = b; b = sum; } - println!("b: {}", b); + + succinct_zkvm::io::write(&a); + succinct_zkvm::io::write(&b); } diff --git a/cli/src/assets/script/main.rs b/cli/src/assets/script/main.rs index 8a60c7b023..e120ab0fbb 100644 --- a/cli/src/assets/script/main.rs +++ b/cli/src/assets/script/main.rs @@ -1,12 +1,28 @@ //! A simple script to generate and verify the proof of a given program. -use succinct_core::{utils, SuccinctProver}; +use succinct_core::{SuccinctProver, SuccinctStdin, SuccinctVerifier}; const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); fn main() { - std::env::set_var("RUST_LOG", "info"); - utils::setup_logger(); - let prover = SuccinctProver::new(); - prover.run_and_prove(ELF); + // Generate proof. + let mut stdin = SuccinctStdin::new(); + stdin.write(&5000u32); + let mut proof = SuccinctProver::prove(ELF, stdin).expect("proving failed"); + + // Read output. + let a = proof.stdout.read::(); + let b = proof.stdout.read::(); + println!("a: {}", a); + println!("b: {}", b); + + // Verify proof. + SuccinctVerifier::verify(ELF, &proof).expect("verification failed"); + + // Save proof. + proof + .save("proof-with-pis.json") + .expect("saving proof failed"); + + println!("succesfully generated and verified proof for the program!") } diff --git a/core/src/lib.rs b/core/src/lib.rs index ac984984a6..56b0566d5d 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -33,7 +33,6 @@ pub mod utils; pub use io::*; use anyhow::Result; -use rand::{rngs::StdRng, SeedableRng}; use runtime::{Program, Runtime}; use serde::Serialize; use stark::{ProgramVerificationError, Proof};