aboutsummaryrefslogtreecommitdiff
path: root/zkvms/jolt/host/src/main.rs
blob: 4e74e8996400a91988d6eca16e784b19ea33eb7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use zkvms_host_io::{
    benchmarkable, output_proof_size, read_args,
    RunType::{Execute, Prove, Verify},
};

pub fn main() {
    let run_info = read_args();
    if run_info.run_type == Execute {
        panic!("Execution is not supported!");
    }

    let elf_path = std::env::var("ELF_PATH").expect("ELF PATH is missing");
    // guest_closures are generated by (Jolt's) wrapper_macro
    let (prove_guest, verify_guest) = guest::guest_closures(elf_path);

    match run_info.run_type {
        Execute => unreachable!(),
        Prove => benchmarkable! {
            let (output, proof) = prove_guest(run_info.input.clone().into());

            output_proof_size(&proof);

            println!("Prove output: {:?}", output);
        },
        Verify => benchmarkable! {
            let (_, proof) = prove_guest(run_info.input.clone().into());

            output_proof_size(&proof);

            let is_valid = verify_guest(proof);
            println!("Verify is valid: {:?}", is_valid);
        },
    }
}