mplang-nightly 0.1.dev259__py3-none-any.whl → 0.1.dev260__py3-none-any.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.
- mplang/v2/backends/tee_impl.py +2 -1
- mplang/v2/dialects/tee.py +26 -51
- {mplang_nightly-0.1.dev259.dist-info → mplang_nightly-0.1.dev260.dist-info}/METADATA +1 -1
- {mplang_nightly-0.1.dev259.dist-info → mplang_nightly-0.1.dev260.dist-info}/RECORD +7 -7
- {mplang_nightly-0.1.dev259.dist-info → mplang_nightly-0.1.dev260.dist-info}/WHEEL +0 -0
- {mplang_nightly-0.1.dev259.dist-info → mplang_nightly-0.1.dev260.dist-info}/entry_points.txt +0 -0
- {mplang_nightly-0.1.dev259.dist-info → mplang_nightly-0.1.dev260.dist-info}/licenses/LICENSE +0 -0
mplang/v2/backends/tee_impl.py
CHANGED
|
@@ -155,7 +155,8 @@ def _quote_gen_impl(
|
|
|
155
155
|
f"got {type(pk).__name__}"
|
|
156
156
|
)
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
# In a real implementation, the platform would be detected from the environment
|
|
159
|
+
platform = "mock"
|
|
159
160
|
|
|
160
161
|
return MockQuoteValue(
|
|
161
162
|
platform=platform,
|
mplang/v2/dialects/tee.py
CHANGED
|
@@ -22,11 +22,11 @@ computation where:
|
|
|
22
22
|
|
|
23
23
|
Architecture:
|
|
24
24
|
PublicKey (from crypto.kem_keygen)
|
|
25
|
-
↓ quote_gen(pk
|
|
26
|
-
Quote
|
|
25
|
+
↓ quote_gen(pk)
|
|
26
|
+
Quote (cryptographic attestation proof)
|
|
27
27
|
↓ (transfer to verifier)
|
|
28
28
|
↓ attest(quote)
|
|
29
|
-
AttestedKey[
|
|
29
|
+
AttestedKey[curve] (verified TEE public key)
|
|
30
30
|
↓ crypto.kem_derive(local_sk, attested_pk)
|
|
31
31
|
SharedSecret (secure channel with TEE)
|
|
32
32
|
|
|
@@ -71,7 +71,6 @@ from mplang.v2.edsl import serde
|
|
|
71
71
|
# --- Type Definitions
|
|
72
72
|
# ==============================================================================
|
|
73
73
|
|
|
74
|
-
Platform = Literal["mock", "sgx", "tdx", "sev"]
|
|
75
74
|
KeyCurve = Literal["x25519", "secp256k1"]
|
|
76
75
|
|
|
77
76
|
|
|
@@ -86,37 +85,29 @@ class QuoteType(elt.BaseType):
|
|
|
86
85
|
|
|
87
86
|
The quote can be verified by anyone with access to the TEE vendor's
|
|
88
87
|
root certificates (Intel, AMD, etc.).
|
|
89
|
-
|
|
90
|
-
Attributes:
|
|
91
|
-
platform: TEE platform identifier
|
|
92
88
|
"""
|
|
93
89
|
|
|
94
|
-
def __init__(self, platform: str = "mock"):
|
|
95
|
-
self.platform: Platform = platform # type: ignore[assignment]
|
|
96
|
-
|
|
97
90
|
def __str__(self) -> str:
|
|
98
|
-
return
|
|
91
|
+
return "TEEQuote"
|
|
99
92
|
|
|
100
93
|
def __repr__(self) -> str:
|
|
101
|
-
return
|
|
94
|
+
return "QuoteType()"
|
|
102
95
|
|
|
103
96
|
def __eq__(self, other: object) -> bool:
|
|
104
|
-
|
|
105
|
-
return False
|
|
106
|
-
return self.platform == other.platform
|
|
97
|
+
return isinstance(other, QuoteType)
|
|
107
98
|
|
|
108
99
|
def __hash__(self) -> int:
|
|
109
|
-
return hash(
|
|
100
|
+
return hash("QuoteType")
|
|
110
101
|
|
|
111
102
|
# --- Serde methods ---
|
|
112
103
|
_serde_kind: ClassVar[str] = "tee.QuoteType"
|
|
113
104
|
|
|
114
105
|
def to_json(self) -> dict[str, Any]:
|
|
115
|
-
return {
|
|
106
|
+
return {}
|
|
116
107
|
|
|
117
108
|
@classmethod
|
|
118
109
|
def from_json(cls, data: dict[str, Any]) -> QuoteType:
|
|
119
|
-
return cls(
|
|
110
|
+
return cls()
|
|
120
111
|
|
|
121
112
|
|
|
122
113
|
@serde.register_class
|
|
@@ -134,37 +125,35 @@ class AttestedKeyType(elt.BaseType):
|
|
|
134
125
|
3. The public key is bound in the quote's report_data
|
|
135
126
|
|
|
136
127
|
Attributes:
|
|
137
|
-
platform: TEE platform that generated the original quote
|
|
138
128
|
curve: Cryptographic curve of the key
|
|
139
129
|
"""
|
|
140
130
|
|
|
141
|
-
def __init__(self,
|
|
142
|
-
self.platform: Platform = platform # type: ignore[assignment]
|
|
131
|
+
def __init__(self, curve: str = "x25519"):
|
|
143
132
|
self.curve: KeyCurve = curve # type: ignore[assignment]
|
|
144
133
|
|
|
145
134
|
def __str__(self) -> str:
|
|
146
|
-
return f"AttestedKey[{self.
|
|
135
|
+
return f"AttestedKey[{self.curve}]"
|
|
147
136
|
|
|
148
137
|
def __repr__(self) -> str:
|
|
149
|
-
return f"AttestedKeyType(
|
|
138
|
+
return f"AttestedKeyType(curve={self.curve!r})"
|
|
150
139
|
|
|
151
140
|
def __eq__(self, other: object) -> bool:
|
|
152
141
|
if not isinstance(other, AttestedKeyType):
|
|
153
142
|
return False
|
|
154
|
-
return self.
|
|
143
|
+
return self.curve == other.curve
|
|
155
144
|
|
|
156
145
|
def __hash__(self) -> int:
|
|
157
|
-
return hash(("AttestedKeyType", self.
|
|
146
|
+
return hash(("AttestedKeyType", self.curve))
|
|
158
147
|
|
|
159
148
|
# --- Serde methods ---
|
|
160
149
|
_serde_kind: ClassVar[str] = "tee.AttestedKeyType"
|
|
161
150
|
|
|
162
151
|
def to_json(self) -> dict[str, Any]:
|
|
163
|
-
return {"
|
|
152
|
+
return {"curve": self.curve}
|
|
164
153
|
|
|
165
154
|
@classmethod
|
|
166
155
|
def from_json(cls, data: dict[str, Any]) -> AttestedKeyType:
|
|
167
|
-
return cls(
|
|
156
|
+
return cls(curve=data["curve"])
|
|
168
157
|
|
|
169
158
|
|
|
170
159
|
@serde.register_class
|
|
@@ -173,37 +162,29 @@ class MeasurementType(elt.BaseType):
|
|
|
173
162
|
|
|
174
163
|
Represents a cryptographic hash of the code and initial configuration
|
|
175
164
|
running inside the TEE. Used to verify the TEE is running expected code.
|
|
176
|
-
|
|
177
|
-
Attributes:
|
|
178
|
-
platform: TEE platform
|
|
179
165
|
"""
|
|
180
166
|
|
|
181
|
-
def __init__(self, platform: str = "mock"):
|
|
182
|
-
self.platform: Platform = platform # type: ignore[assignment]
|
|
183
|
-
|
|
184
167
|
def __str__(self) -> str:
|
|
185
|
-
return
|
|
168
|
+
return "TEEMeasurement"
|
|
186
169
|
|
|
187
170
|
def __repr__(self) -> str:
|
|
188
|
-
return
|
|
171
|
+
return "MeasurementType()"
|
|
189
172
|
|
|
190
173
|
def __eq__(self, other: object) -> bool:
|
|
191
|
-
|
|
192
|
-
return False
|
|
193
|
-
return self.platform == other.platform
|
|
174
|
+
return isinstance(other, MeasurementType)
|
|
194
175
|
|
|
195
176
|
def __hash__(self) -> int:
|
|
196
|
-
return hash(
|
|
177
|
+
return hash("MeasurementType")
|
|
197
178
|
|
|
198
179
|
# --- Serde methods ---
|
|
199
180
|
_serde_kind: ClassVar[str] = "tee.MeasurementType"
|
|
200
181
|
|
|
201
182
|
def to_json(self) -> dict[str, Any]:
|
|
202
|
-
return {
|
|
183
|
+
return {}
|
|
203
184
|
|
|
204
185
|
@classmethod
|
|
205
186
|
def from_json(cls, data: dict[str, Any]) -> MeasurementType:
|
|
206
|
-
return cls(
|
|
187
|
+
return cls()
|
|
207
188
|
|
|
208
189
|
|
|
209
190
|
# ==============================================================================
|
|
@@ -223,14 +204,11 @@ get_measurement_p = el.Primitive[el.Object]("tee.get_measurement")
|
|
|
223
204
|
@quote_gen_p.def_abstract_eval
|
|
224
205
|
def _quote_gen_ae(
|
|
225
206
|
pk: elt.BaseType,
|
|
226
|
-
*,
|
|
227
|
-
platform: Platform = "mock",
|
|
228
207
|
) -> QuoteType:
|
|
229
208
|
"""Generate a TEE quote binding the provided public key.
|
|
230
209
|
|
|
231
210
|
Args:
|
|
232
211
|
pk: Public key to bind in the quote (must be PublicKeyType from crypto.kem_keygen)
|
|
233
|
-
platform: TEE platform to use
|
|
234
212
|
|
|
235
213
|
Returns:
|
|
236
214
|
QuoteType representing the attestation proof
|
|
@@ -243,7 +221,7 @@ def _quote_gen_ae(
|
|
|
243
221
|
f"quote_gen expects PublicKeyType (from crypto.kem_keygen), "
|
|
244
222
|
f"got {type(pk).__name__}"
|
|
245
223
|
)
|
|
246
|
-
return QuoteType(
|
|
224
|
+
return QuoteType()
|
|
247
225
|
|
|
248
226
|
|
|
249
227
|
@attest_p.def_abstract_eval
|
|
@@ -261,7 +239,7 @@ def _attest_ae(
|
|
|
261
239
|
Returns:
|
|
262
240
|
AttestedKeyType containing the verified public key
|
|
263
241
|
"""
|
|
264
|
-
return AttestedKeyType(
|
|
242
|
+
return AttestedKeyType(curve=expected_curve)
|
|
265
243
|
|
|
266
244
|
|
|
267
245
|
@get_measurement_p.def_abstract_eval
|
|
@@ -276,7 +254,7 @@ def _get_measurement_ae(
|
|
|
276
254
|
Returns:
|
|
277
255
|
MeasurementType containing the code measurement
|
|
278
256
|
"""
|
|
279
|
-
return MeasurementType(
|
|
257
|
+
return MeasurementType()
|
|
280
258
|
|
|
281
259
|
|
|
282
260
|
# ==============================================================================
|
|
@@ -286,7 +264,6 @@ def _get_measurement_ae(
|
|
|
286
264
|
|
|
287
265
|
def quote_gen(
|
|
288
266
|
pk: el.Object,
|
|
289
|
-
platform: Platform = "mock",
|
|
290
267
|
) -> el.Object:
|
|
291
268
|
"""Generate a TEE attestation quote binding the provided public key.
|
|
292
269
|
|
|
@@ -297,7 +274,6 @@ def quote_gen(
|
|
|
297
274
|
|
|
298
275
|
Args:
|
|
299
276
|
pk: Public key to bind (typically from crypto.kem_keygen)
|
|
300
|
-
platform: TEE platform ("mock", "sgx", "tdx", "sev")
|
|
301
277
|
|
|
302
278
|
Returns:
|
|
303
279
|
Object[QuoteType] - The attestation quote
|
|
@@ -306,7 +282,7 @@ def quote_gen(
|
|
|
306
282
|
>>> sk, pk = crypto.kem_keygen("x25519")
|
|
307
283
|
>>> quote = tee.quote_gen(pk) # Bind pk in attestation
|
|
308
284
|
"""
|
|
309
|
-
return quote_gen_p.bind(pk
|
|
285
|
+
return quote_gen_p.bind(pk)
|
|
310
286
|
|
|
311
287
|
|
|
312
288
|
def attest(
|
|
@@ -360,7 +336,6 @@ __all__ = [
|
|
|
360
336
|
"AttestedKeyType",
|
|
361
337
|
"KeyCurve",
|
|
362
338
|
"MeasurementType",
|
|
363
|
-
"Platform",
|
|
364
339
|
"QuoteType",
|
|
365
340
|
"attest",
|
|
366
341
|
"attest_p",
|
|
@@ -91,7 +91,7 @@ mplang/v2/backends/spu_impl.py,sha256=nDmpntXMKlFhaOUMXAOO_-RZTzqGLsgxEvwJuVA6h1
|
|
|
91
91
|
mplang/v2/backends/spu_state.py,sha256=wj876IvNPhKyWISN6WwKBYoaDQFFJ8jemdJUVeH5IfA,4144
|
|
92
92
|
mplang/v2/backends/store_impl.py,sha256=RyhADTNsnnNnwsatAMr7eeewXkVXtfNWA1oFiLXg8H0,2222
|
|
93
93
|
mplang/v2/backends/table_impl.py,sha256=c36gyBCWLQbV3g0hkJeTnMXUqT0nxgu74k2sLondTio,8784
|
|
94
|
-
mplang/v2/backends/tee_impl.py,sha256=
|
|
94
|
+
mplang/v2/backends/tee_impl.py,sha256=Gp-vqqJPtEMNqP7y68tLhL3a-EW3BQwpo_qCJOSHqKs,7044
|
|
95
95
|
mplang/v2/backends/tensor_impl.py,sha256=8f9f4-_e-m4JWGZSbXLmSSHcgPykRBc1sAYrA3OIxEg,18906
|
|
96
96
|
mplang/v2/backends/simp_driver/__init__.py,sha256=ahOPYYvtFVwqxiFxkpSNP8BCTao_MfCXmtt5zsMaJxg,1258
|
|
97
97
|
mplang/v2/backends/simp_driver/http.py,sha256=nl7ny7f8bzhy1ubNIDXhMgA5P_WA8dhhgFNHvcmfSKk,5548
|
|
@@ -115,7 +115,7 @@ mplang/v2/dialects/simp.py,sha256=ON7iegkHp3um5UX8V4Y5I-fGgFJ3YVwmFsXsleiqqUE,32
|
|
|
115
115
|
mplang/v2/dialects/spu.py,sha256=3JO-D394TKNH2VdFDRp5ohmG0uOcOHEs_ivFHbMZIgA,11385
|
|
116
116
|
mplang/v2/dialects/store.py,sha256=RqUBzMAgtEMBmdT8axV5lVCv1hp5w0ZZM0Tu4iOZt-c,2114
|
|
117
117
|
mplang/v2/dialects/table.py,sha256=ax9Yjvcb8jJ8fqNJodMQ_mrS8tf-xECHQFvUKUWPp70,12714
|
|
118
|
-
mplang/v2/dialects/tee.py,sha256=
|
|
118
|
+
mplang/v2/dialects/tee.py,sha256=oj_G8ebhtuz9_HarK8rKoaJNJ9ZkRbqcIxhp3m0xsjQ,10129
|
|
119
119
|
mplang/v2/dialects/tensor.py,sha256=FxPKsiNi2vFb-R2hqRgR7zYYO5LdRu_rdDHfjE3_2Lw,40003
|
|
120
120
|
mplang/v2/edsl/README.md,sha256=viflvdRojOa6Xk_UMRPqpuPGXcPGmdlv2-XR6LO7B58,7592
|
|
121
121
|
mplang/v2/edsl/__init__.py,sha256=YqmtrJXD1NLKS-_Ofnxtiv77muokTZnrAiV7dXUZVyo,2607
|
|
@@ -170,8 +170,8 @@ mplang/v2/runtime/dialect_state.py,sha256=HxO1i4kSOujS2tQzAF9-WmI3nChSaGgupf2_07
|
|
|
170
170
|
mplang/v2/runtime/interpreter.py,sha256=UzrM5oepka6H0YKRZncNXhsuwKVm4pliG5J92fFRZMI,32300
|
|
171
171
|
mplang/v2/runtime/object_store.py,sha256=yT6jtKG2GUEJVmpq3gnQ8mCMvUFYzgBciC5A-J5KRdk,5998
|
|
172
172
|
mplang/v2/runtime/value.py,sha256=CMOxElJP78v7pjasPhEpbxWbSgB2KsLbpPmzz0mQX0E,4317
|
|
173
|
-
mplang_nightly-0.1.
|
|
174
|
-
mplang_nightly-0.1.
|
|
175
|
-
mplang_nightly-0.1.
|
|
176
|
-
mplang_nightly-0.1.
|
|
177
|
-
mplang_nightly-0.1.
|
|
173
|
+
mplang_nightly-0.1.dev260.dist-info/METADATA,sha256=16iSjw54jMsEvkUSk4HqpmDOh6BCd5O6lxAdiRV-GWc,16768
|
|
174
|
+
mplang_nightly-0.1.dev260.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
175
|
+
mplang_nightly-0.1.dev260.dist-info/entry_points.txt,sha256=mG1oJT-GAjQR834a62_QIWb7litzWPPyVnwFqm-rWuY,55
|
|
176
|
+
mplang_nightly-0.1.dev260.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
177
|
+
mplang_nightly-0.1.dev260.dist-info/RECORD,,
|
|
File without changes
|
{mplang_nightly-0.1.dev259.dist-info → mplang_nightly-0.1.dev260.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{mplang_nightly-0.1.dev259.dist-info → mplang_nightly-0.1.dev260.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|