Skip to content

Commit 202e2ac

Browse files
authored
feat: remove zkm prover (#59)
1 parent 2dd8406 commit 202e2ac

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

guest-program/revme/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = "0.1.0"
55
edition = "2021"
66

77
[dependencies]
8-
zkm-runtime = { git = "https://github.com/zkMIPS/zkm.git"}
8+
zkm-runtime = { git = "https://github.com/zkMIPS/zkm" }
99
##just testing
1010
#zkm-runtime = { path = "../../../zkm/runtime/entrypoint" }
1111

sdk/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ async-trait = "0.1"
1313

1414
zkm-prover = { git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
1515
zkm-emulator = { git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
16-
common = { git = "https://github.com/zkMIPS/zkm-prover", branch = "main", default-features = false }
1716
plonky2 = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }
1817
#starky = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }
1918

20-
tonic = "0.8.1"
19+
tonic = { version = "0.8.1", features = ["tls", "transport"] }
2120
prost = "0.11.0"
2221

2322
reqwest = { version = "0.11", features = ["rustls-tls"] }

sdk/src/network/prover.rs

+43-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use common::tls::Config;
21
use stage_service::stage_service_client::StageServiceClient;
32
use stage_service::{GenerateProofRequest, GetStatusRequest};
43

4+
use std::path::Path;
55
use std::time::Instant;
66
use tonic::transport::Endpoint;
7+
use tonic::transport::{Certificate, Identity};
78
use tonic::transport::{Channel, ClientTlsConfig};
89

910
use crate::prover::{ClientCfg, Prover, ProverInput, ProverResult};
@@ -13,6 +14,12 @@ use tokio::time::Duration;
1314

1415
use async_trait::async_trait;
1516

17+
#[derive(Clone)]
18+
pub struct Config {
19+
pub ca_cert: Option<Certificate>,
20+
pub identity: Option<Identity>,
21+
}
22+
1623
pub mod stage_service {
1724
tonic::include_proto!("stage.v1");
1825
}
@@ -32,7 +39,9 @@ impl NetworkProver {
3239
let ssl_config = if ca_cert_path.is_empty() {
3340
None
3441
} else {
35-
Some(Config::new(ca_cert_path, cert_path, key_path).await?)
42+
let (ca_cert, identity) =
43+
get_cert_and_identity(ca_cert_path, cert_path, key_path).await?;
44+
Some(Config { ca_cert, identity })
3645
};
3746
let endpoint_para = client_config.endpoint.to_owned().expect("ENDPOINT must be set");
3847
let endpoint = match ssl_config {
@@ -217,3 +226,35 @@ impl Prover for NetworkProver {
217226
self.wait_proof(&proof_id, timeout).await
218227
}
219228
}
229+
230+
async fn get_cert_and_identity(
231+
ca_cert_path: String,
232+
cert_path: String,
233+
key_path: String,
234+
) -> anyhow::Result<(Option<Certificate>, Option<Identity>)> {
235+
let ca_cert_path = Path::new(&ca_cert_path);
236+
let cert_path = Path::new(&cert_path);
237+
let key_path = Path::new(&key_path);
238+
// if !ca_cert_path.is_file() || !cert_path.is_file() || !key_path.is_file() {
239+
// bail!("both ca_cert_path, cert_path and key_path should be valid file")
240+
// }
241+
let mut ca: Option<Certificate> = None;
242+
let mut identity: Option<Identity> = None;
243+
if ca_cert_path.is_file() {
244+
let ca_cert = tokio::fs::read(ca_cert_path)
245+
.await
246+
.unwrap_or_else(|err| panic!("Failed to read {:?}, err: {:?}", ca_cert_path, err));
247+
ca = Some(Certificate::from_pem(ca_cert));
248+
}
249+
250+
if cert_path.is_file() && key_path.is_file() {
251+
let cert = tokio::fs::read(cert_path)
252+
.await
253+
.unwrap_or_else(|err| panic!("Failed to read {:?}, err: {:?}", cert_path, err));
254+
let key = tokio::fs::read(key_path)
255+
.await
256+
.unwrap_or_else(|err| panic!("Failed to read {:?}, err: {:?}", key_path, err));
257+
identity = Some(Identity::from_pem(cert, key));
258+
}
259+
Ok((ca, identity))
260+
}

0 commit comments

Comments
 (0)