Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove zkm prover #59

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guest-program/revme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
zkm-runtime = { git = "https://github.com/zkMIPS/zkm.git"}
zkm-runtime = { git = "https://github.com/zkMIPS/zkm" }
##just testing
#zkm-runtime = { path = "../../../zkm/runtime/entrypoint" }

Expand Down
3 changes: 1 addition & 2 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ async-trait = "0.1"

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

tonic = "0.8.1"
tonic = { version = "0.8.1", features = ["tls", "transport"] }
prost = "0.11.0"

reqwest = { version = "0.11", features = ["rustls-tls"] }
Expand Down
45 changes: 43 additions & 2 deletions sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use common::tls::Config;
use stage_service::stage_service_client::StageServiceClient;
use stage_service::{GenerateProofRequest, GetStatusRequest};

use std::path::Path;
use std::time::Instant;
use tonic::transport::Endpoint;
use tonic::transport::{Certificate, Identity};
use tonic::transport::{Channel, ClientTlsConfig};

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

use async_trait::async_trait;

#[derive(Clone)]
pub struct Config {
pub ca_cert: Option<Certificate>,
pub identity: Option<Identity>,
}

pub mod stage_service {
tonic::include_proto!("stage.v1");
}
Expand All @@ -32,7 +39,9 @@ impl NetworkProver {
let ssl_config = if ca_cert_path.is_empty() {
None
} else {
Some(Config::new(ca_cert_path, cert_path, key_path).await?)
let (ca_cert, identity) =
get_cert_and_identity(ca_cert_path, cert_path, key_path).await?;
Some(Config { ca_cert, identity })
};
let endpoint_para = client_config.endpoint.to_owned().expect("ENDPOINT must be set");
let endpoint = match ssl_config {
Expand Down Expand Up @@ -217,3 +226,35 @@ impl Prover for NetworkProver {
self.wait_proof(&proof_id, timeout).await
}
}

async fn get_cert_and_identity(
ca_cert_path: String,
cert_path: String,
key_path: String,
) -> anyhow::Result<(Option<Certificate>, Option<Identity>)> {
let ca_cert_path = Path::new(&ca_cert_path);
let cert_path = Path::new(&cert_path);
let key_path = Path::new(&key_path);
// if !ca_cert_path.is_file() || !cert_path.is_file() || !key_path.is_file() {
// bail!("both ca_cert_path, cert_path and key_path should be valid file")
// }
let mut ca: Option<Certificate> = None;
let mut identity: Option<Identity> = None;
if ca_cert_path.is_file() {
let ca_cert = tokio::fs::read(ca_cert_path)
.await
.unwrap_or_else(|err| panic!("Failed to read {:?}, err: {:?}", ca_cert_path, err));
ca = Some(Certificate::from_pem(ca_cert));
}

if cert_path.is_file() && key_path.is_file() {
let cert = tokio::fs::read(cert_path)
.await
.unwrap_or_else(|err| panic!("Failed to read {:?}, err: {:?}", cert_path, err));
let key = tokio::fs::read(key_path)
.await
.unwrap_or_else(|err| panic!("Failed to read {:?}, err: {:?}", key_path, err));
identity = Some(Identity::from_pem(cert, key));
}
Ok((ca, identity))
}
Loading