diff options
Diffstat (limited to 'zkvms/nexus/host')
| -rw-r--r-- | zkvms/nexus/host/Cargo.toml | 13 | ||||
| -rw-r--r-- | zkvms/nexus/host/src/main.rs | 63 |
2 files changed, 76 insertions, 0 deletions
diff --git a/zkvms/nexus/host/Cargo.toml b/zkvms/nexus/host/Cargo.toml new file mode 100644 index 0000000..6ace3f7 --- /dev/null +++ b/zkvms/nexus/host/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "host-nexus" +version = "0.1.0" +edition = "2021" + +[dependencies] +nexus-sdk = { path = "/nix/store/krlanfap664k4g88qgsssxi0818z92r8-Nexus-zkVM-unstable-2024-12-18/sdk" } + +zkvms_host_io = { path = "../../../zkvms_host_io" } + +# THESE ARE A COPY OF THE GUEST DEPENDENCIES +# They're here as a hack, so crane.lib will fetch them +postcard = { version = "1.0.10", default-features = false, features = ["alloc"] } 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"); + }, + } +} |
