use clap::Parser; use sp1_sdk::{ProverClient, SP1Stdin}; /// The ELF (executable and linkable format) file for the Succinct RISC-V zkVM. pub const FIBONACCI_ELF: &[u8] = include_bytes!("./guest"); /// The arguments for the command. #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] struct Args { #[clap(long)] execute: bool, #[clap(long)] prove: bool, } fn main() { // Setup the logger. sp1_sdk::utils::setup_logger(); // Parse the command line arguments. let args = Args::parse(); if args.execute == args.prove { eprintln!("Error: You must specify either --execute or --prove"); std::process::exit(1); } // Setup the prover client. let client = ProverClient::new(); // Setup the inputs. let mut stdin = SP1Stdin::new(); let (graph, colors, coloring): (Vec>, u32, Vec>) = include!(env!("INPUTS")); stdin.write(&graph); stdin.write(&colors); stdin.write(&coloring); if args.execute { // Execute the program let (output, report) = client.execute(FIBONACCI_ELF, &stdin).run().unwrap(); println!("Program executed successfully."); // Read the output. let decoded = output; println!("{:?}", decoded); // Record the number of cycles executed. println!("Number of cycles: {}", report.total_instruction_count()); } else { // Setup the program for proving. let (pk, vk) = client.setup(FIBONACCI_ELF); // Generate the proof let proof = client .prove(&pk, &stdin) .run() .expect("failed to generate proof"); println!("Successfully generated proof!"); // Verify the proof. client.verify(&proof, &vk).expect("failed to verify proof"); println!("Successfully verified proof!"); } }