use async_trait::async_trait; use serde::Deserialize; use serde::Serialize; use std::default::Default; use tokio::time::Duration; #[derive(Debug, Default, Clone)] pub struct ClientCfg { pub zkm_prover: String, pub vk_path: String, //pub setup_flag: bool, pub endpoint: Option, pub ca_cert_path: Option, pub cert_path: Option, pub key_path: Option, pub domain_name: Option, pub proof_network_privkey: Option, } impl ClientCfg { pub fn new(zkm_prover_type: String, vk_path: String) -> ClientCfg { ClientCfg { zkm_prover: zkm_prover_type, vk_path, ..Default::default() } } pub fn set_network( &mut self, endpoint: String, ca_cert_path: String, cert_path: String, key_path: String, domain_name: String, private_key: String, ) { self.endpoint = Some(endpoint); self.ca_cert_path = Some(ca_cert_path); self.cert_path = Some(cert_path); self.key_path = Some(key_path); self.domain_name = Some(domain_name); self.proof_network_privkey = Some(private_key); } } #[derive(Debug, Default, Deserialize, Serialize, Clone)] pub struct ProverInput { pub elf: Vec, pub public_inputstream: Vec, pub private_inputstream: Vec, pub seg_size: u32, pub execute_only: bool, pub precompile: bool, pub receipt_inputs: Vec>, pub receipts: Vec>, } #[derive(Debug, Default, Deserialize, Serialize, Clone)] pub struct ProverResult { pub total_steps: u64, pub split_cost: u64, pub output_stream: Vec, pub proof_with_public_inputs: Vec, pub stark_proof: Vec, pub solidity_verifier: Vec, pub public_values: Vec, pub receipt: Vec, pub elf_id: Vec, } #[async_trait] pub trait Prover { async fn request_proof<'a>(&self, input: &'a ProverInput) -> anyhow::Result; async fn wait_proof<'a>( &self, proof_id: &'a str, timeout: Option, ) -> anyhow::Result>; async fn setup_and_generate_sol_verifier<'a>( &self, vk_path: &'a str, input: &'a ProverInput, timeout: Option, ) -> anyhow::Result<()>; async fn prove<'a>( &self, input: &'a ProverInput, timeout: Option, ) -> anyhow::Result>; }