diff options
| author | Kamen Mladenov <kamen@syndamia.com> | 2025-01-17 18:49:41 +0200 |
|---|---|---|
| committer | Kamen Mladenov <kamen@syndamia.com> | 2025-01-17 18:49:50 +0200 |
| commit | 3f532203df67bfc0839416962ac9c012b127105d (patch) | |
| tree | 9f4ca730780f169932b2ba95ec6c11ddb236504b /zkvms/nexus/host/src | |
| parent | 254e1ebf2127d2469639a2f0f786b6876a3eb78c (diff) | |
| download | zkVMs-benchmarks-3f532203df67bfc0839416962ac9c012b127105d.tar zkVMs-benchmarks-3f532203df67bfc0839416962ac9c012b127105d.tar.gz zkVMs-benchmarks-3f532203df67bfc0839416962ac9c012b127105d.zip | |
feat(zkvms): Add nexus host
Diffstat (limited to 'zkvms/nexus/host/src')
| -rw-r--r-- | zkvms/nexus/host/src/main.rs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/zkvms/nexus/host/src/main.rs b/zkvms/nexus/host/src/main.rs new file mode 100644 index 0000000..7d3ca0b --- /dev/null +++ b/zkvms/nexus/host/src/main.rs @@ -0,0 +1,63 @@ +use zkvms_host_io::{read_args, RunType::{ Execute, Prove, Verify }}; +use nexus_sdk::{ + compile::CompileOpts, + nova::seq::{Generate, Nova, PP}, + Local, Prover, Verifiable, +}; + +type Input = (Vec<Vec<bool>>, u32, Vec<Vec<u32>>); +type Output = bool; + +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"); + + println!("Setting up Nova public parameters..."); + let pp: PP = PP::generate().expect("failed to generate parameters"); + + println!("Loading guest..."); + let prover: Nova<Local> = Nova::new_from_file(&elf_path).expect("failed to load guest program"); + + let input: Input = run_info.input; + + match run_info.run_type { + Execute => unreachable!(), + Prove => { + println!("Proving execution of vm..."); + let proof = prover + .prove_with_input::<Input>(&pp, &input) + .expect("failed to prove program"); + + println!( + " output is {}!", + proof + .output::<Output>() + .expect("failed to deserialize output") + ); + + println!(">>>>> Logging\n{}<<<<<", proof.logs().join("")); + }, + Verify => { + println!("Proving execution of vm..."); + let proof = prover + .prove_with_input::<Input>(&pp, &input) + .expect("failed to prove program"); + + println!( + " output is {}!", + proof + .output::<Output>() + .expect("failed to deserialize output") + ); + + println!(">>>>> Logging\n{}<<<<<", proof.logs().join("")); + + print!("Verifying execution..."); + proof.verify(&pp).expect("failed to verify proof"); + }, + } +} |
