Skip to content
Closed
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
4 changes: 2 additions & 2 deletions crates/miden-proving-service-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ tonic = { version = "0.12", default-features = false, features = ["prost", "code
getrandom = { version = "0.3", features = ["wasm_js"] }

[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
tonic = { version = "0.12", default-features = false, features = ["prost", "codegen", "transport"] }
tonic = { version = "0.12", default-features = false, features = ["prost", "codegen", "transport", "tls","tls-roots"] }
tonic-web = { version = "0.12", optional = true }

[dependencies]
async-trait = "0.1"
miden-objects = { workspace = true, default-features = false, optional = true }
miden-tx = { workspace = true, default-features = false, optional = true }
lunal-attestation = { git = "https://github.com/lunal-dot-dev/attestation-rs.git" }
prost = { version = "0.13", default-features = false, features = ["derive"] }
thiserror = "2.0"
tokio = { version = "1.44", default-features = false, features = ["sync"], optional = true }
Expand All @@ -43,4 +44,3 @@ prost = { version = "0.13", default-features = false, features = ["derive"] }
prost-build = { version = "0.13" }
protox = { version = "0.7" }
tonic-build = { version = "0.12" }

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use alloc::{
sync::Arc,
};

use lunal_attestation::verify::verify_attestation;
use miden_objects::{
transaction::{ProvenTransaction, TransactionWitness},
utils::{Deserializable, DeserializationError, Serializable},
Expand Down Expand Up @@ -66,8 +67,19 @@ impl RemoteTransactionProver {
};

#[cfg(not(target_arch = "wasm32"))]
use tonic::transport::Endpoint;
let mut endpoint = Endpoint::from_shared(self.endpoint.clone())
.map_err(|_| RemoteProverError::ConnectionFailed(self.endpoint.to_string()))?;

// enable TLS for HTTPs endpoints
if self.endpoint.starts_with("https://") {
endpoint = endpoint
.tls_config(tonic::transport::ClientTlsConfig::new().with_native_roots())
.map_err(|e| RemoteProverError::ConnectionFailed(e.to_string()))?;
}

let new_client = {
ApiClient::connect(self.endpoint.clone())
ApiClient::connect(endpoint)
.await
.map_err(|_| RemoteProverError::ConnectionFailed(self.endpoint.to_string()))?
};
Expand Down Expand Up @@ -103,6 +115,17 @@ impl TransactionProver for RemoteTransactionProver {
TransactionProverError::other_with_source("failed to prove transaction", err)
})?;

// Extract the attestation report from metadata
if let Some(attestation_value) = response.metadata().get("Attestation-Report") {
// Verify the attestation
verify_attestation(attestation_value.to_str()).await.map_err(|err| {
TransactionProverError::other_with_source(
"failed to verify transaction attestation",
err,
)
})?;
}

// Deserialize the response bytes back into a ProvenTransaction.
let proven_transaction =
ProvenTransaction::try_from(response.into_inner()).map_err(|_| {
Expand Down
Loading