-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Guibas
authored and
John Guibas
committed
Feb 10, 2024
1 parent
ac9dc67
commit 772a51d
Showing
3 changed files
with
25 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters