aboutsummaryrefslogtreecommitdiff
path: root/zkvms/jolt/host/src/main.rs
blob: 3ad8377da5fa08e71d8c40ff0fc094c1b09ee5f7 (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
use zkvms_host_io::{
    benchmarkable, read_args,
    RunType::{Execute, Prove, Verify},
};

type Input = (Vec<Vec<bool>>, u32, Vec<Vec<u32>>);

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, _) = prove_guest(run_info.input.clone().into());
            println!("Prove output: {}", output);
        },
        Verify => benchmarkable! {
            let (_, proof) = prove_guest(run_info.input.clone().into());
            let is_valid = verify_guest(proof);
            println!("Verify is valid: {}", is_valid);
        },
    }
}