dcap-qvl 0.3.9__cp38-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dcap_qvl/__init__.py ADDED
@@ -0,0 +1,130 @@
1
+ """
2
+ DCAP Quote Verification Library
3
+
4
+ This package provides Python bindings for the DCAP (Data Center Attestation Primitives)
5
+ quote verification library implemented in Rust.
6
+
7
+ Main classes:
8
+ - QuoteCollateralV3: Represents quote collateral data
9
+ - VerifiedReport: Contains verification results
10
+
11
+ Main functions:
12
+ - verify: Verify a quote with collateral data
13
+ - get_collateral: Get collateral from PCCS URL
14
+ - get_collateral_from_pcs: Get collateral from Intel PCS
15
+ - get_collateral_and_verify: Get collateral and verify quote
16
+ """
17
+
18
+ import time
19
+ from importlib.metadata import version
20
+ from typing import Optional
21
+
22
+ from ._dcap_qvl import (
23
+ PyQuoteCollateralV3 as QuoteCollateralV3,
24
+ PyVerifiedReport as VerifiedReport,
25
+ PyQuote as Quote,
26
+ py_verify as verify,
27
+ py_verify_with_root_ca as verify_with_root_ca,
28
+ parse_quote,
29
+ get_collateral_for_fmspc,
30
+ )
31
+
32
+ # Default PCCS URL (Phala Network's PCCS server - recommended)
33
+ PHALA_PCCS_URL = "https://pccs.phala.network"
34
+
35
+ # Intel's official PCS URL
36
+ INTEL_PCS_URL = "https://api.trustedservices.intel.com"
37
+
38
+ # Backward compatibility alias
39
+ PCS_URL = INTEL_PCS_URL
40
+
41
+
42
+ async def get_collateral(pccs_url: str, raw_quote: bytes) -> QuoteCollateralV3:
43
+ """Get collateral from PCCS URL.
44
+
45
+ Args:
46
+ pccs_url: PCCS server URL
47
+ raw_quote: Raw quote bytes
48
+
49
+ Returns:
50
+ QuoteCollateralV3: Quote collateral data
51
+
52
+ Raises:
53
+ ValueError: If quote is invalid or FMSPC cannot be extracted
54
+ RuntimeError: If network request fails
55
+ """
56
+ if not isinstance(raw_quote, (bytes, bytearray)):
57
+ raise TypeError("raw_quote must be bytes")
58
+
59
+ quote = Quote.parse(raw_quote)
60
+ fmspc = quote.fmspc()
61
+ is_sgx = quote.is_sgx()
62
+ ca = quote.ca()
63
+ return await get_collateral_for_fmspc(pccs_url, fmspc, ca, is_sgx)
64
+
65
+
66
+ async def get_collateral_from_pcs(raw_quote: bytes) -> QuoteCollateralV3:
67
+ """Get collateral from Intel PCS.
68
+
69
+ Use this function to explicitly fetch collateral from Intel's
70
+ Provisioning Certification Service. For most use cases,
71
+ use get_collateral() with PHALA_PCCS_URL instead.
72
+
73
+ Args:
74
+ raw_quote: Raw quote bytes
75
+
76
+ Returns:
77
+ QuoteCollateralV3: Quote collateral data
78
+
79
+ Raises:
80
+ ValueError: If quote is invalid or FMSPC cannot be extracted
81
+ RuntimeError: If network request fails
82
+ """
83
+ return await get_collateral(INTEL_PCS_URL, raw_quote)
84
+
85
+
86
+ async def get_collateral_and_verify(
87
+ raw_quote: bytes, pccs_url: Optional[str] = None
88
+ ) -> VerifiedReport:
89
+ """Get collateral and verify the quote.
90
+
91
+ Args:
92
+ raw_quote: Raw quote bytes
93
+ pccs_url: Optional PCCS URL (defaults to Phala PCCS)
94
+
95
+ Returns:
96
+ VerifiedReport: Verification result
97
+
98
+ Raises:
99
+ ValueError: If quote is invalid or verification fails
100
+ RuntimeError: If network request fails
101
+ """
102
+ url = (pccs_url or "").strip() or PHALA_PCCS_URL
103
+
104
+ # Get collateral
105
+ collateral = await get_collateral(url, raw_quote)
106
+
107
+ # Get current time
108
+ now_secs = int(time.time())
109
+
110
+ # Verify quote
111
+ return verify(raw_quote, collateral, now_secs)
112
+
113
+
114
+ __all__ = [
115
+ "QuoteCollateralV3",
116
+ "VerifiedReport",
117
+ "Quote",
118
+ "verify",
119
+ "verify_with_root_ca",
120
+ "get_collateral",
121
+ "get_collateral_from_pcs",
122
+ "get_collateral_and_verify",
123
+ "get_collateral_for_fmspc",
124
+ "parse_quote",
125
+ "PHALA_PCCS_URL",
126
+ "INTEL_PCS_URL",
127
+ "PCS_URL",
128
+ ]
129
+
130
+ __version__ = version("dcap-qvl")
dcap_qvl/_dcap_qvl.pyd ADDED
Binary file
dcap_qvl/_dcap_qvl.pyi ADDED
@@ -0,0 +1,328 @@
1
+ """
2
+ Type stubs for the _dcap_qvl C extension module.
3
+
4
+ This file provides detailed type hints for the compiled Rust extension,
5
+ enabling better IDE support, type checking with mypy, and improved
6
+ developer experience.
7
+ """
8
+
9
+ from typing import List
10
+
11
+ class PyQuoteCollateralV3:
12
+ """
13
+ Represents quote collateral data required for DCAP quote verification.
14
+
15
+ This class contains all the necessary certificate chains, CRLs, and
16
+ attestation information needed to verify an SGX or TDX quote.
17
+ """
18
+
19
+ def __init__(
20
+ self,
21
+ pck_crl_issuer_chain: str,
22
+ root_ca_crl: bytes,
23
+ pck_crl: bytes,
24
+ tcb_info_issuer_chain: str,
25
+ tcb_info: str,
26
+ tcb_info_signature: bytes,
27
+ qe_identity_issuer_chain: str,
28
+ qe_identity: str,
29
+ qe_identity_signature: bytes,
30
+ ) -> None:
31
+ """
32
+ Create a new PyQuoteCollateralV3 instance.
33
+
34
+ Args:
35
+ pck_crl_issuer_chain: PCK CRL issuer certificate chain (PEM format)
36
+ root_ca_crl: Root CA certificate revocation list
37
+ pck_crl: PCK certificate revocation list
38
+ tcb_info_issuer_chain: TCB info issuer certificate chain (PEM format)
39
+ tcb_info: TCB (Trusted Computing Base) information (JSON string)
40
+ tcb_info_signature: Signature for the TCB info
41
+ qe_identity_issuer_chain: QE identity issuer certificate chain (PEM format)
42
+ qe_identity: Quoting Enclave identity information (JSON string)
43
+ qe_identity_signature: Signature for the QE identity
44
+ """
45
+ ...
46
+
47
+ @property
48
+ def pck_crl_issuer_chain(self) -> str:
49
+ """PCK CRL issuer certificate chain in PEM format."""
50
+ ...
51
+
52
+ @property
53
+ def root_ca_crl(self) -> bytes:
54
+ """Root CA certificate revocation list."""
55
+ ...
56
+
57
+ @property
58
+ def pck_crl(self) -> bytes:
59
+ """PCK certificate revocation list."""
60
+ ...
61
+
62
+ @property
63
+ def tcb_info_issuer_chain(self) -> str:
64
+ """TCB info issuer certificate chain in PEM format."""
65
+ ...
66
+
67
+ @property
68
+ def tcb_info(self) -> str:
69
+ """TCB (Trusted Computing Base) information as JSON string."""
70
+ ...
71
+
72
+ @property
73
+ def tcb_info_signature(self) -> bytes:
74
+ """Signature for the TCB info."""
75
+ ...
76
+
77
+ @property
78
+ def qe_identity_issuer_chain(self) -> str:
79
+ """QE identity issuer certificate chain in PEM format."""
80
+ ...
81
+
82
+ @property
83
+ def qe_identity(self) -> str:
84
+ """Quoting Enclave identity information as JSON string."""
85
+ ...
86
+
87
+ @property
88
+ def qe_identity_signature(self) -> bytes:
89
+ """Signature for the QE identity."""
90
+ ...
91
+
92
+ def to_json(self) -> str:
93
+ """
94
+ Serialize the collateral to a JSON string.
95
+
96
+ Returns:
97
+ JSON string representation of the collateral data
98
+
99
+ Raises:
100
+ ValueError: If serialization fails
101
+ """
102
+ ...
103
+
104
+ @staticmethod
105
+ def from_json(json_str: str) -> "PyQuoteCollateralV3":
106
+ """
107
+ Create a PyQuoteCollateralV3 instance from a JSON string.
108
+
109
+ Args:
110
+ json_str: JSON string containing collateral data
111
+
112
+ Returns:
113
+ New PyQuoteCollateralV3 instance
114
+
115
+ Raises:
116
+ ValueError: If JSON parsing fails or data is invalid
117
+ """
118
+ ...
119
+
120
+ class PyVerifiedReport:
121
+ """
122
+ Contains the results of DCAP quote verification.
123
+
124
+ This class holds the verification status and any security advisories
125
+ that were found during the quote verification process.
126
+ """
127
+
128
+ @property
129
+ def status(self) -> str:
130
+ """
131
+ Verification status string.
132
+
133
+ Common values include:
134
+ - "OK": Verification successful, no issues
135
+ - "SW_HARDENING_NEEDED": Software hardening recommended
136
+ - "CONFIGURATION_NEEDED": Platform configuration required
137
+ - "OUT_OF_DATE": TCB is out of date
138
+ - "REVOKED": Certificate or key has been revoked
139
+ """
140
+ ...
141
+
142
+ @property
143
+ def advisory_ids(self) -> List[str]:
144
+ """
145
+ List of security advisory IDs that apply to this quote.
146
+
147
+ These are Intel security advisory identifiers (e.g., "INTEL-SA-00334")
148
+ that indicate known security issues affecting the attested platform.
149
+ """
150
+ ...
151
+
152
+ def to_json(self) -> str:
153
+ """
154
+ Serialize the verification report to a JSON string.
155
+
156
+ Returns:
157
+ JSON string representation of the verification report
158
+
159
+ Raises:
160
+ ValueError: If serialization fails
161
+ """
162
+ ...
163
+
164
+ class PyQuote:
165
+ """
166
+ Represents a parsed SGX or TDX quote.
167
+
168
+ This class provides access to quote metadata and identifiers
169
+ without requiring collateral data for verification.
170
+ """
171
+
172
+ @staticmethod
173
+ def parse(raw_quote: bytes) -> "PyQuote":
174
+ """
175
+ Parse a raw quote from bytes.
176
+
177
+ Args:
178
+ raw_quote: Raw quote data as bytes (SGX or TDX format)
179
+
180
+ Returns:
181
+ PyQuote instance with parsed quote data
182
+
183
+ Raises:
184
+ ValueError: If quote parsing fails due to invalid format or corrupted data
185
+ """
186
+ ...
187
+
188
+ def fmspc(self) -> str:
189
+ """
190
+ Extract the FMSPC (Family-Model-Stepping-Platform-CustomSKU) identifier.
191
+
192
+ The FMSPC is a 6-byte identifier that uniquely identifies the
193
+ platform's TCB level and is used for collateral retrieval.
194
+
195
+ Returns:
196
+ FMSPC as uppercase hexadecimal string (12 characters)
197
+
198
+ Raises:
199
+ ValueError: If FMSPC cannot be extracted from the quote
200
+ """
201
+ ...
202
+
203
+ def ca(self) -> str:
204
+ """
205
+ Extract the CA (Certificate Authority) identifier.
206
+
207
+ The CA identifier indicates which certificate authority
208
+ should be used for quote verification.
209
+
210
+ Returns:
211
+ CA identifier as string
212
+
213
+ Raises:
214
+ ValueError: If CA identifier cannot be extracted from the quote
215
+ """
216
+ ...
217
+
218
+ def is_tdx(self) -> bool:
219
+ """
220
+ Check if this is a TDX (Trust Domain Extensions) quote.
221
+
222
+ Returns:
223
+ True if the quote is TDX format, False if SGX format
224
+ """
225
+ ...
226
+
227
+ def is_sgx(self) -> bool:
228
+ """
229
+ Check if this is an SGX quote.
230
+
231
+ Returns:
232
+ True if the quote is SGX format, False if TDX format
233
+ """
234
+ ...
235
+
236
+ def quote_type(self) -> str:
237
+ """
238
+ Get the quote type as a string.
239
+
240
+ Returns:
241
+ "TDX" for TDX quotes, "SGX" for SGX quotes
242
+ """
243
+ ...
244
+
245
+ def py_verify(
246
+ raw_quote: bytes, collateral: PyQuoteCollateralV3, now_secs: int
247
+ ) -> PyVerifiedReport:
248
+ """
249
+ Verify an SGX or TDX quote with the provided collateral data.
250
+
251
+ This function performs cryptographic verification of the quote against
252
+ the provided collateral information, checking certificates, signatures,
253
+ and revocation status.
254
+
255
+ Args:
256
+ raw_quote: Raw quote data as bytes (SGX or TDX format)
257
+ collateral: Quote collateral containing certificates and attestation data
258
+ now_secs: Current timestamp in seconds since Unix epoch for time-based checks
259
+
260
+ Returns:
261
+ PyVerifiedReport containing verification status and advisory information
262
+
263
+ Raises:
264
+ ValueError: If verification fails due to invalid data, expired certificates,
265
+ revoked keys, or other verification errors
266
+ """
267
+ ...
268
+
269
+ def py_verify_with_root_ca(
270
+ raw_quote: bytes,
271
+ collateral: PyQuoteCollateralV3,
272
+ root_ca_der: bytes,
273
+ now_secs: int
274
+ ) -> PyVerifiedReport:
275
+ """
276
+ Verify an SGX or TDX quote with the provided collateral data and custom root CA.
277
+
278
+ Args:
279
+ raw_quote: Raw quote data as bytes (SGX or TDX format)
280
+ collateral: Quote collateral containing certificates and attestation data
281
+ root_ca_der: Custom root CA certificate in DER format
282
+ now_secs: Current timestamp in seconds since Unix epoch for time-based checks
283
+
284
+ Returns:
285
+ PyVerifiedReport containing verification status and advisory information
286
+
287
+ Raises:
288
+ ValueError: If verification fails
289
+ """
290
+ ...
291
+
292
+ def parse_quote(raw_quote: bytes) -> PyQuote:
293
+ """
294
+ Parse a raw quote from bytes (convenience function).
295
+
296
+ This is a convenience function that calls PyQuote.parse() directly.
297
+
298
+ Args:
299
+ raw_quote: Raw quote data as bytes (SGX or TDX format)
300
+
301
+ Returns:
302
+ PyQuote instance with parsed quote data
303
+
304
+ Raises:
305
+ ValueError: If quote parsing fails due to invalid format or corrupted data
306
+ """
307
+ ...
308
+
309
+ async def get_collateral_for_fmspc(
310
+ pccs_url: str, fmspc: str, ca: str, is_sgx: bool
311
+ ) -> PyQuoteCollateralV3:
312
+ """
313
+ Get collateral for a specific FMSPC from PCCS URL.
314
+
315
+ Args:
316
+ pccs_url: PCCS server URL
317
+ fmspc: FMSPC identifier as hex string
318
+ ca: Certificate authority identifier
319
+ is_sgx: True for SGX, False for TDX
320
+
321
+ Returns:
322
+ PyQuoteCollateralV3 with collateral data
323
+
324
+ Raises:
325
+ ValueError: If FMSPC is invalid
326
+ RuntimeError: If network request fails
327
+ """
328
+ ...
@@ -0,0 +1,389 @@
1
+ Metadata-Version: 2.4
2
+ Name: dcap-qvl
3
+ Version: 0.3.9
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Rust
14
+ Classifier: Topic :: Security :: Cryptography
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Summary: Python bindings for DCAP (Data Center Attestation Primitives) quote verification library
17
+ Keywords: sgx,tdx,dcap,attestation,verification,cryptography
18
+ Author-email: Kevin Wang <wy721@qq.com>
19
+ License: MIT
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
22
+ Project-URL: Homepage, https://github.com/Phala-Network/dcap-qvl
23
+ Project-URL: Repository, https://github.com/Phala-Network/dcap-qvl
24
+ Project-URL: Issues, https://github.com/Phala-Network/dcap-qvl/issues
25
+
26
+ # Python Bindings for DCAP-QVL
27
+
28
+ This package provides Python bindings for the DCAP (Data Center Attestation Primitives) quote verification library implemented in Rust.
29
+
30
+ ## Quick Start
31
+
32
+ ```bash
33
+ # Install from PyPI
34
+ pip install dcap-qvl
35
+
36
+ # Basic usage
37
+ python -c "
38
+ import dcap_qvl
39
+ print('DCAP-QVL Python bindings successfully installed!')
40
+ print(f'Available functions: {dcap_qvl.__all__}')
41
+ "
42
+ ```
43
+
44
+ ## Features
45
+
46
+ - Verify SGX and TDX quotes
47
+ - Handle quote collateral data
48
+ - Parse verification results
49
+ - Pure Rust implementation with Python bindings
50
+ - Cross-platform compatibility (Linux, macOS, Windows)
51
+ - Asynchronous collateral fetching from PCCS/PCS with async/await support
52
+ - Compatible with Python 3.8+
53
+
54
+ ## Installation
55
+
56
+ ### From PyPI (recommended)
57
+
58
+ ```bash
59
+ pip install dcap-qvl
60
+ ```
61
+
62
+ ### Using uv
63
+
64
+ ```bash
65
+ uv add dcap-qvl
66
+ ```
67
+
68
+ ## Usage
69
+
70
+ ### Basic Quote Verification
71
+
72
+ ```python
73
+ import dcap_qvl
74
+ import json
75
+ import time
76
+
77
+ # Load quote data (binary)
78
+ with open("path/to/quote", "rb") as f:
79
+ quote_data = f.read()
80
+
81
+ # Load collateral data (JSON)
82
+ with open("path/to/collateral.json", "r") as f:
83
+ collateral_json = json.load(f)
84
+
85
+ # Create collateral object
86
+ collateral = dcap_qvl.QuoteCollateralV3.from_json(json.dumps(collateral_json))
87
+
88
+ # Verify the quote
89
+ now = int(time.time())
90
+ try:
91
+ result = dcap_qvl.verify(quote_data, collateral, now)
92
+ print(f"Verification successful! Status: {result.status}")
93
+ print(f"Advisory IDs: {result.advisory_ids}")
94
+ except ValueError as e:
95
+ print(f"Verification failed: {e}")
96
+ ```
97
+
98
+ ### Working with Collateral Data
99
+
100
+ ```python
101
+ # Create collateral manually
102
+ collateral = dcap_qvl.QuoteCollateralV3(
103
+ pck_crl_issuer_chain="...",
104
+ root_ca_crl=b"...", # bytes
105
+ pck_crl=b"...", # bytes
106
+ tcb_info_issuer_chain="...",
107
+ tcb_info="...", # JSON string
108
+ tcb_info_signature=b"...", # bytes
109
+ qe_identity_issuer_chain="...",
110
+ qe_identity="...", # JSON string
111
+ qe_identity_signature=b"...", # bytes
112
+ )
113
+
114
+ # Serialize to JSON
115
+ json_str = collateral.to_json()
116
+
117
+ # Deserialize from JSON
118
+ collateral = dcap_qvl.QuoteCollateralV3.from_json(json_str)
119
+ ```
120
+
121
+ ## API Reference
122
+
123
+ ### Async Collateral Functions
124
+
125
+ All collateral functions are asynchronous and must be awaited. They use the Rust async runtime for optimal performance.
126
+
127
+ #### `async get_collateral_for_fmspc(pccs_url: str, fmspc: str, ca: str, is_sgx: bool) -> QuoteCollateralV3`
128
+
129
+ Get collateral for a specific FMSPC directly from PCCS URL (Rust async export).
130
+
131
+ **Parameters:**
132
+ - `pccs_url`: PCCS URL (e.g., "https://api.trustedservices.intel.com")
133
+ - `fmspc`: FMSPC value as hex string (e.g., "B0C06F000000")
134
+ - `ca`: Certificate Authority ("processor" or "platform")
135
+ - `is_sgx`: True for SGX quotes, False for TDX quotes
136
+
137
+ **Returns:**
138
+ - `QuoteCollateralV3`: Quote collateral data
139
+
140
+ **Raises:**
141
+ - `ValueError`: If FMSPC is invalid or collateral cannot be retrieved
142
+ - `RuntimeError`: If network request fails
143
+
144
+ **Example:**
145
+ ```python
146
+ import asyncio
147
+ import dcap_qvl
148
+
149
+ async def main():
150
+ collateral = await dcap_qvl.get_collateral_for_fmspc(
151
+ pccs_url="https://api.trustedservices.intel.com",
152
+ fmspc="B0C06F000000",
153
+ ca="processor",
154
+ is_sgx=True
155
+ )
156
+ print(f"Got collateral: {len(collateral.tcb_info)} chars")
157
+
158
+ asyncio.run(main())
159
+ ```
160
+
161
+ #### `async get_collateral(pccs_url: str, raw_quote: bytes) -> QuoteCollateralV3`
162
+
163
+ Get collateral from a custom PCCS URL by parsing the quote.
164
+
165
+ **Parameters:**
166
+ - `pccs_url`: PCCS URL (e.g., "https://api.trustedservices.intel.com")
167
+ - `raw_quote`: Raw quote data as bytes
168
+
169
+ **Returns:**
170
+ - `QuoteCollateralV3`: Quote collateral data
171
+
172
+ **Raises:**
173
+ - `ValueError`: If quote is invalid or FMSPC cannot be extracted
174
+ - `RuntimeError`: If network request fails
175
+
176
+ **Example:**
177
+ ```python
178
+ import asyncio
179
+ import dcap_qvl
180
+
181
+ async def main():
182
+ pccs_url = "https://api.trustedservices.intel.com"
183
+ quote_data = open("quote.bin", "rb").read()
184
+ collateral = await dcap_qvl.get_collateral(pccs_url, quote_data)
185
+ print(f"Got collateral: {len(collateral.tcb_info)} chars")
186
+
187
+ asyncio.run(main())
188
+ ```
189
+
190
+ #### `async get_collateral_from_pcs(raw_quote: bytes) -> QuoteCollateralV3`
191
+
192
+ Get collateral from Intel's PCS (default).
193
+
194
+ **Parameters:**
195
+ - `raw_quote`: Raw quote data as bytes
196
+
197
+ **Returns:**
198
+ - `QuoteCollateralV3`: Quote collateral data
199
+
200
+ **Raises:**
201
+ - `ValueError`: If quote is invalid or FMSPC cannot be extracted
202
+ - `RuntimeError`: If network request fails
203
+
204
+ **Example:**
205
+ ```python
206
+ import asyncio
207
+ import dcap_qvl
208
+
209
+ async def main():
210
+ quote_data = open("quote.bin", "rb").read()
211
+ collateral = await dcap_qvl.get_collateral_from_pcs(quote_data)
212
+ print(f"Got collateral from Intel PCS")
213
+
214
+ asyncio.run(main())
215
+ ```
216
+
217
+ #### `async get_collateral_and_verify(raw_quote: bytes, pccs_url: Optional[str] = None) -> VerifiedReport`
218
+
219
+ Get collateral and verify quote in one step.
220
+
221
+ **Parameters:**
222
+ - `raw_quote`: Raw quote data as bytes
223
+ - `pccs_url`: Optional PCCS URL (uses Intel PCS if None)
224
+
225
+ **Returns:**
226
+ - `VerifiedReport`: Verification results
227
+
228
+ **Raises:**
229
+ - `ValueError`: If quote is invalid or verification fails
230
+ - `RuntimeError`: If network request fails
231
+
232
+ **Example:**
233
+ ```python
234
+ import asyncio
235
+ import dcap_qvl
236
+
237
+ async def main():
238
+ quote_data = open("quote.bin", "rb").read()
239
+ result = await dcap_qvl.get_collateral_and_verify(quote_data)
240
+ print(f"Status: {result.status}")
241
+ print(f"Advisory IDs: {result.advisory_ids}")
242
+
243
+ asyncio.run(main())
244
+ ```
245
+
246
+ ### Classes
247
+
248
+ #### `QuoteCollateralV3`
249
+
250
+ Represents quote collateral data required for verification.
251
+
252
+ **Constructor:**
253
+ ```python
254
+ QuoteCollateralV3(
255
+ pck_crl_issuer_chain: str,
256
+ root_ca_crl: bytes,
257
+ pck_crl: bytes,
258
+ tcb_info_issuer_chain: str,
259
+ tcb_info: str,
260
+ tcb_info_signature: bytes,
261
+ qe_identity_issuer_chain: str,
262
+ qe_identity: str,
263
+ qe_identity_signature: bytes,
264
+ )
265
+ ```
266
+
267
+ **Methods:**
268
+ - `to_json() -> str`: Serialize to JSON string
269
+ - `from_json(json_str: str) -> QuoteCollateralV3`: Create from JSON string (static method)
270
+
271
+ **Properties:**
272
+ - `pck_crl_issuer_chain: str`
273
+ - `root_ca_crl: bytes`
274
+ - `pck_crl: bytes`
275
+ - `tcb_info_issuer_chain: str`
276
+ - `tcb_info: str`
277
+ - `tcb_info_signature: bytes`
278
+ - `qe_identity_issuer_chain: str`
279
+ - `qe_identity: str`
280
+ - `qe_identity_signature: bytes`
281
+
282
+ #### `VerifiedReport`
283
+
284
+ Contains the results of quote verification.
285
+
286
+ **Properties:**
287
+ - `status: str`: Verification status
288
+ - `advisory_ids: List[str]`: List of advisory IDs
289
+
290
+ **Methods:**
291
+ - `to_json() -> str`: Serialize to JSON string
292
+
293
+ ### Functions
294
+
295
+ #### `verify(raw_quote: bytes, collateral: QuoteCollateralV3, now_secs: int) -> VerifiedReport`
296
+
297
+ Verify a quote with the provided collateral data.
298
+
299
+ **Parameters:**
300
+ - `raw_quote`: Raw quote data as bytes
301
+ - `collateral`: Quote collateral data
302
+ - `now_secs`: Current timestamp in seconds since Unix epoch
303
+
304
+ **Returns:**
305
+ - `VerifiedReport`: Verification results
306
+
307
+ **Raises:**
308
+ - `ValueError`: If verification fails
309
+
310
+ ## Development
311
+
312
+ ### Building from Source
313
+
314
+ If you want to build from source or contribute to development:
315
+
316
+ ```bash
317
+ # Clone the repository
318
+ git clone https://github.com/Phala-Network/dcap-qvl.git
319
+ cd dcap-qvl/python-bindings
320
+
321
+ # Install development dependencies (including maturin)
322
+ uv sync
323
+
324
+ # Build and install the Python extension in development mode
325
+ uv run maturin develop --features python
326
+
327
+ # Run tests
328
+ uv run python -m pytest tests/test_python_bindings.py
329
+ ```
330
+
331
+ **Note:** maturin is only required for building from source. Regular users installing from PyPI don't need maturin.
332
+
333
+ ### Running Examples
334
+
335
+ After installing the package, you can run the examples:
336
+
337
+ ```bash
338
+ # Download the examples from the repository
339
+ git clone https://github.com/Phala-Network/dcap-qvl.git
340
+ cd dcap-qvl/python-bindings
341
+
342
+ # Basic functionality test
343
+ python examples/basic_test.py
344
+
345
+ # Full example (requires sample data files)
346
+ python examples/python_example.py
347
+ ```
348
+
349
+ Or if you're using uv for development:
350
+
351
+ ```bash
352
+ # Basic functionality test
353
+ uv run python examples/basic_test.py
354
+
355
+ # Full example (requires sample data files)
356
+ uv run python examples/python_example.py
357
+ ```
358
+
359
+ ### Testing Across Python Versions
360
+
361
+ The project includes comprehensive testing across all supported Python versions:
362
+
363
+ ```bash
364
+ # Quick test across all Python versions
365
+ make test_python_versions
366
+
367
+ # Test current Python version only
368
+ make test_python
369
+ ```
370
+
371
+ See [PYTHON_TESTING.md](PYTHON_TESTING.md) for detailed information about Python version compatibility testing.
372
+
373
+ ## Requirements
374
+
375
+ ### For regular usage (installing from PyPI):
376
+ - Python 3.8+
377
+
378
+ ### For development (building from source):
379
+ - Python 3.8+
380
+ - Rust toolchain (rustc, cargo)
381
+ - maturin (automatically installed with `uv sync`)
382
+
383
+ ## License
384
+
385
+ MIT License - see [LICENSE](../../LICENSE) for details.
386
+
387
+ ## Contributing
388
+
389
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,6 @@
1
+ dcap_qvl-0.3.9.dist-info/METADATA,sha256=sI1IjeYz9mzoj3V_DjiwvWxZ4jdx9mw7MX4-GbZhyu0,10248
2
+ dcap_qvl-0.3.9.dist-info/WHEEL,sha256=lMUAg5cfi6g8a7v52pog4330UzKeSSlNI3fLvrdVzVU,94
3
+ dcap_qvl/__init__.py,sha256=4xmJtn_20NzAmQAshf2TE8cdmJ-mnq-aJ19l_4tS2ow,3580
4
+ dcap_qvl/_dcap_qvl.pyd,sha256=6FjMO0ZFFgWoaqfLeFVd48lfblTYzI6-v1-2m6_wq1s,6440448
5
+ dcap_qvl/_dcap_qvl.pyi,sha256=xSN4Y3qgeoBW0czSUiDumpdLLAC45CYiywlEW4hURZA,9497
6
+ dcap_qvl-0.3.9.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.9.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp38-abi3-win_amd64