1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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>>;
}
|