Skip to content

Commit e3f52d2

Browse files
committed
update zkdcap and fix proto definitions
Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
1 parent 2120cc3 commit e3f52d2

File tree

19 files changed

+63
-51
lines changed

19 files changed

+63
-51
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ crypto = { path = "../modules/crypto" }
2727
keymanager = { path = "../modules/keymanager" }
2828
remote-attestation = { path = "../modules/remote-attestation" }
2929
attestation-report = { path = "../modules/attestation-report" }
30-
zkdcap-risc0 = { git = "https://github.com/datachainlab/zkdcap", rev = "e6fd9cf9e6ad0ff80b8e20247d1cafa6fed59c6e" }
30+
zkdcap-risc0 = { git = "https://github.com/datachainlab/zkdcap", rev = "54ab01c04ca8738b8568b4a6c74a493715af9d2b" }
3131

3232
[build-dependencies]
3333
git2 = { version = "0.20", default-features = false }

modules/attestation-report/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pem = { version = "2.0", default-features = false }
1818
webpki = { version = "0.22", features = ["alloc"] }
1919
anyhow = { version = "1", default-features = false }
2020

21-
dcap-quote-verifier = { git = "https://github.com/datachainlab/zkdcap", rev = "e6fd9cf9e6ad0ff80b8e20247d1cafa6fed59c6e", optional = true }
21+
dcap-quote-verifier = { git = "https://github.com/datachainlab/zkdcap", rev = "54ab01c04ca8738b8568b4a6c74a493715af9d2b", optional = true }
2222

2323
[dev-dependencies]
2424
tokio = { version = "1.0", default-features = false, features = ["macros"] }

modules/attestation-report/src/dcap.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ pub enum ZKVMProof {
5353
}
5454

5555
impl ZKVMProof {
56-
/// Returns the commit corresponding to the proof
57-
pub fn commit(&self) -> &[u8] {
56+
/// Returns the output of dcap-quote-verifier program executed inside the zkVM
57+
pub fn output(&self) -> &[u8] {
5858
match self {
59-
ZKVMProof::Risc0(ref proof) => &proof.commit,
59+
ZKVMProof::Risc0(ref proof) => &proof.output,
6060
}
6161
}
6262

@@ -81,9 +81,9 @@ pub struct Risc0ZKVMProof {
8181
#[serde_as(as = "serde_with::hex::Hex<serde_with::formats::Lowercase>")]
8282
/// A Groth16 proof for the correct execution of the guest program.
8383
pub seal: Vec<u8>,
84-
/// The public outputs of dcap-quote-verifier program executed inside the zkVM
84+
/// The output of dcap-quote-verifier program executed inside the zkVM
8585
#[serde_as(as = "serde_with::hex::Hex<serde_with::formats::Lowercase>")]
86-
pub commit: Vec<u8>,
86+
pub output: Vec<u8>,
8787
}
8888

8989
impl Risc0ZKVMProof {
@@ -137,8 +137,8 @@ impl ZKDCAPQuote {
137137

138138
/// Returns the commit corresponding to the zkVM proof
139139
#[cfg(feature = "std")]
140-
pub fn commit(&self) -> Result<dcap_quote_verifier::verifier::VerifiedOutput, Error> {
141-
dcap_quote_verifier::verifier::VerifiedOutput::from_bytes(self.zkp.commit())
140+
pub fn commit(&self) -> Result<dcap_quote_verifier::verifier::QuoteVerificationOutput, Error> {
141+
dcap_quote_verifier::verifier::QuoteVerificationOutput::from_bytes(self.zkp.output())
142142
.map_err(Error::dcap_quote_verifier)
143143
}
144144
}

modules/keymanager/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl TryFrom<SealedEnclaveKeyInfo> for ProtoEnclaveKeyInfo {
447447
image_id: proof.image_id.to_vec(),
448448
selector: proof.selector.to_vec(),
449449
seal: proof.seal,
450-
commit: proof.commit,
450+
output: proof.output,
451451
})
452452
}
453453
}),

modules/lcp-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ flex-error = { version = "0.4.4", default-features = false }
1111
tiny-keccak = { version = "2.0" }
1212
hex-literal = { version = "0.4.1" }
1313
alloy-sol-types = { version = "0.8", default-features = false }
14-
dcap-quote-verifier = { git = "https://github.com/datachainlab/zkdcap", rev = "e6fd9cf9e6ad0ff80b8e20247d1cafa6fed59c6e" }
14+
dcap-quote-verifier = { git = "https://github.com/datachainlab/zkdcap", rev = "54ab01c04ca8738b8568b4a6c74a493715af9d2b" }
1515

1616
attestation-report = { path = "../attestation-report", default-features = false }
1717
remote-attestation = { path = "../remote-attestation", default-features = false }

modules/lcp-client/src/client_def.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,40 +251,47 @@ impl LCPClient {
251251
selector,
252252
seal,
253253
zkdcap_verifier_info.program_id,
254-
message.commit.to_bytes(),
254+
message.quote_verification_output.to_bytes(),
255255
)?;
256256

257-
let report = if let QuoteBody::SGXQuoteBody(report) = message.commit.quote_body {
258-
report
259-
} else {
260-
return Err(Error::unexpected_quote_body());
261-
};
257+
let report =
258+
if let QuoteBody::SGXQuoteBody(report) = message.quote_verification_output.quote_body {
259+
report
260+
} else {
261+
return Err(Error::unexpected_quote_body());
262+
};
262263
let report_data = ReportData(report.report_data);
263264

264265
assert_eq!(
265266
report.mrenclave.as_slice(),
266267
client_state.mr_enclave.as_slice(),
267268
"mrenclave mismatch"
268269
);
269-
assert_eq!(message.commit.quote_version, 3, "unexpected quote version");
270-
assert_eq!(message.commit.tee_type, SGX_TEE_TYPE, "unexpected tee type");
271270
assert_eq!(
272-
message.commit.sgx_intel_root_ca_hash,
271+
message.quote_verification_output.quote_version, 3,
272+
"unexpected quote version"
273+
);
274+
assert_eq!(
275+
message.quote_verification_output.tee_type, SGX_TEE_TYPE,
276+
"unexpected tee type"
277+
);
278+
assert_eq!(
279+
message.quote_verification_output.sgx_intel_root_ca_hash,
273280
remote_attestation::dcap::INTEL_ROOT_CA_HASH,
274281
);
275282
assert!(
276283
message
277-
.commit
284+
.quote_verification_output
278285
.validity
279286
.validate_time(ctx.host_timestamp().as_unix_timestamp_secs()),
280287
"invalid validity intersection"
281288
);
282-
let tcb_status = message.commit.tcb_status.to_string();
289+
let tcb_status = message.quote_verification_output.tcb_status.to_string();
283290
assert!(
284291
tcb_status == "UpToDate" || client_state.allowed_quote_statuses.contains(&tcb_status),
285292
"unexpected tcb status"
286293
);
287-
for advisory_id in message.commit.advisory_ids.iter() {
294+
for advisory_id in message.quote_verification_output.advisory_ids.iter() {
288295
assert!(
289296
client_state.allowed_advisory_ids.contains(advisory_id),
290297
"unexpected advisory id"
@@ -295,7 +302,7 @@ impl LCPClient {
295302
verify_signature_address(
296303
compute_eip712_zkdcap_register_enclave_key(
297304
zkdcap_verifier_info,
298-
message.commit.hash(),
305+
message.quote_verification_output.hash(),
299306
)
300307
.as_ref(),
301308
operator_signature.as_ref(),
@@ -310,7 +317,10 @@ impl LCPClient {
310317
ctx,
311318
&client_id,
312319
report_data.enclave_key(),
313-
EKOperatorInfo::new(message.commit.validity.not_after_min, operator),
320+
EKOperatorInfo::new(
321+
message.quote_verification_output.validity.not_after_min,
322+
operator,
323+
),
314324
);
315325
Ok(())
316326
}

modules/lcp-client/src/message.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::prelude::*;
44
use alloy_sol_types::{sol, SolValue};
55
use attestation_report::IASSignedReport;
66
use crypto::Address;
7-
use dcap_quote_verifier::verifier::VerifiedOutput;
7+
use dcap_quote_verifier::verifier::QuoteVerificationOutput;
88
use light_client::commitments::{Error as CommitmentError, EthABIEncoder, ProxyMessage};
99
use light_client::types::proto::ibc::lightclients::lcp::v1::{
1010
RegisterEnclaveKeyMessage as RawRegisterEnclaveKeyMessage,
@@ -113,7 +113,7 @@ impl From<RegisterEnclaveKeyMessage> for RawRegisterEnclaveKeyMessage {
113113
#[derive(Debug, Clone, PartialEq)]
114114
pub struct ZKDCAPRegisterEnclaveKeyMessage {
115115
pub zkvm_type: ZKVMType,
116-
pub commit: VerifiedOutput,
116+
pub quote_verification_output: QuoteVerificationOutput,
117117
pub proof: Vec<u8>,
118118
pub operator_signature: Option<Vec<u8>>,
119119
}
@@ -141,8 +141,10 @@ impl TryFrom<RawZKDCAPRegisterEnclaveKeyMessage> for ZKDCAPRegisterEnclaveKeyMes
141141
zkvm_type: ZKVMType::from_u8(
142142
u8::try_from(value.zkvm_type).map_err(Error::zk_vm_type_conversion)?,
143143
)?,
144-
commit: VerifiedOutput::from_bytes(&value.commit)
145-
.map_err(Error::dcap_quote_verifier)?,
144+
quote_verification_output: QuoteVerificationOutput::from_bytes(
145+
&value.quote_verification_output,
146+
)
147+
.map_err(Error::dcap_quote_verifier)?,
146148
proof: value.proof,
147149
operator_signature: (!value.operator_signature.is_empty())
148150
.then_some(value.operator_signature),
@@ -154,7 +156,7 @@ impl From<ZKDCAPRegisterEnclaveKeyMessage> for RawZKDCAPRegisterEnclaveKeyMessag
154156
fn from(value: ZKDCAPRegisterEnclaveKeyMessage) -> Self {
155157
RawZKDCAPRegisterEnclaveKeyMessage {
156158
zkvm_type: value.zkvm_type as u32,
157-
commit: value.commit.to_bytes(),
159+
quote_verification_output: value.quote_verification_output.to_bytes(),
158160
proof: value.proof,
159161
operator_signature: value.operator_signature.unwrap_or_default(),
160162
}

modules/remote-attestation/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ serde_json = { version = "1.0", features = ["preserve_order"] }
2828
rsa = { version = "0.9.2", features = ["pem"], optional = true }
2929
chrono = { version = "0.4.38", features = ["now"], optional = true }
3030

31-
dcap-quote-verifier = { git = "https://github.com/datachainlab/zkdcap", rev = "e6fd9cf9e6ad0ff80b8e20247d1cafa6fed59c6e" }
32-
dcap-collaterals = { git = "https://github.com/datachainlab/zkdcap", rev = "e6fd9cf9e6ad0ff80b8e20247d1cafa6fed59c6e" }
31+
dcap-quote-verifier = { git = "https://github.com/datachainlab/zkdcap", rev = "54ab01c04ca8738b8568b4a6c74a493715af9d2b" }
32+
dcap-collaterals = { git = "https://github.com/datachainlab/zkdcap", rev = "54ab01c04ca8738b8568b4a6c74a493715af9d2b" }
3333

3434
lcp-types = { path = "../types" }
3535
crypto = { path = "../crypto", default-features = false }

modules/remote-attestation/src/dcap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use dcap_quote_verifier::cert::{get_x509_subject_cn, parse_certchain};
66
use dcap_quote_verifier::sgx_extensions::extract_sgx_extensions;
77
use dcap_quote_verifier::types::quotes::version_3::QuoteV3;
88
use dcap_quote_verifier::types::utils::parse_pem;
9-
use dcap_quote_verifier::{collaterals::IntelCollateral, quotes::version_3::verify_quote_dcapv3};
9+
use dcap_quote_verifier::{collaterals::IntelCollateral, quotes::version_3::verify_quote_v3};
1010
use keymanager::EnclaveKeyManager;
1111
use lcp_types::Time;
1212
use log::*;
@@ -75,7 +75,7 @@ pub(crate) fn dcap_ra(
7575
let quote = QuoteV3::from_bytes(&raw_quote).map_err(Error::dcap_quote_verifier)?;
7676

7777
let collateral = get_collateral(pccs_url, certs_service_url, is_early_update, &quote)?;
78-
let output = verify_quote_dcapv3(&quote, &collateral, current_time.as_unix_timestamp_secs())
78+
let output = verify_quote_v3(&quote, &collateral, current_time.as_unix_timestamp_secs())
7979
.map_err(Error::dcap_quote_verifier)?;
8080

8181
debug!(
@@ -226,7 +226,7 @@ mod tests {
226226
&quote,
227227
)
228228
.unwrap();
229-
let res = verify_quote_dcapv3(&quote, &collateral, Time::now().as_unix_timestamp_secs());
229+
let res = verify_quote_v3(&quote, &collateral, Time::now().as_unix_timestamp_secs());
230230
assert!(res.is_ok(), "{:?}", res);
231231
let output = res.unwrap();
232232
assert_eq!(output.tee_type, SGX_TEE_TYPE);

0 commit comments

Comments
 (0)