aboutsummaryrefslogtreecommitdiff
path: root/zkvms/zkm/sdk/src/prover.rs
diff options
context:
space:
mode:
authorKamen Mladenov <kamen@syndamia.com>2025-01-16 12:47:40 +0200
committerKamen Mladenov <kamen@syndamia.com>2025-01-16 12:47:40 +0200
commitf276736ceba61373fb60216256c477ab2ccffe29 (patch)
tree98824fd9e68847c608113aea107cd4e5e627ac5b /zkvms/zkm/sdk/src/prover.rs
parent818ba1a13973fe64c3d73e2bf90c45e2dcafec72 (diff)
downloadzkVMs-benchmarks-f276736ceba61373fb60216256c477ab2ccffe29.tar
zkVMs-benchmarks-f276736ceba61373fb60216256c477ab2ccffe29.tar.gz
zkVMs-benchmarks-f276736ceba61373fb60216256c477ab2ccffe29.zip
feat(zkvms): Add zkm host
Diffstat (limited to 'zkvms/zkm/sdk/src/prover.rs')
-rw-r--r--zkvms/zkm/sdk/src/prover.rs91
1 files changed, 91 insertions, 0 deletions
diff --git a/zkvms/zkm/sdk/src/prover.rs b/zkvms/zkm/sdk/src/prover.rs
new file mode 100644
index 0000000..60da1e5
--- /dev/null
+++ b/zkvms/zkm/sdk/src/prover.rs
@@ -0,0 +1,91 @@
+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<String>,
+ pub ca_cert_path: Option<String>,
+ pub cert_path: Option<String>,
+ pub key_path: Option<String>,
+ pub domain_name: Option<String>,
+ pub proof_network_privkey: Option<String>,
+}
+
+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<u8>,
+ pub public_inputstream: Vec<u8>,
+ pub private_inputstream: Vec<u8>,
+ pub seg_size: u32,
+ pub execute_only: bool,
+ pub precompile: bool,
+ pub receipt_inputs: Vec<Vec<u8>>,
+ pub receipts: Vec<Vec<u8>>,
+}
+
+#[derive(Debug, Default, Deserialize, Serialize, Clone)]
+pub struct ProverResult {
+ pub total_steps: u64,
+ pub split_cost: u64,
+ pub output_stream: Vec<u8>,
+ pub proof_with_public_inputs: Vec<u8>,
+ pub stark_proof: Vec<u8>,
+ pub solidity_verifier: Vec<u8>,
+ pub public_values: Vec<u8>,
+ pub receipt: Vec<u8>,
+ pub elf_id: Vec<u8>,
+}
+
+#[async_trait]
+pub trait Prover {
+ async fn request_proof<'a>(&self, input: &'a ProverInput) -> anyhow::Result<String>;
+ async fn wait_proof<'a>(
+ &self,
+ proof_id: &'a str,
+ timeout: Option<Duration>,
+ ) -> anyhow::Result<Option<ProverResult>>;
+ async fn setup_and_generate_sol_verifier<'a>(
+ &self,
+ vk_path: &'a str,
+ input: &'a ProverInput,
+ timeout: Option<Duration>,
+ ) -> anyhow::Result<()>;
+ async fn prove<'a>(
+ &self,
+ input: &'a ProverInput,
+ timeout: Option<Duration>,
+ ) -> anyhow::Result<Option<ProverResult>>;
+}