Skip to content

Commit

Permalink
new assets
Browse files Browse the repository at this point in the history
  • Loading branch information
John Guibas authored and John Guibas committed Feb 10, 2024
1 parent ac9dc67 commit 772a51d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cli/src/assets/program/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate succinct_zkvm;
succinct_zkvm::entrypoint!(main);

pub fn main() {
let n = 10;
let n = succinct_zkvm::io::read::<u32>();
let mut a = 0;
let mut b = 1;
let mut sum;
Expand All @@ -14,5 +14,7 @@ pub fn main() {
a = b;
b = sum;
}
println!("b: {}", b);

succinct_zkvm::io::write(&a);
succinct_zkvm::io::write(&b);
}
26 changes: 21 additions & 5 deletions cli/src/assets/script/main.rs
Original file line number Diff line number Diff line change
@@ -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::<u32>();
let b = proof.stdout.read::<u32>();
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!")
}
1 change: 0 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit 772a51d

Please sign in to comment.