modelsign 1.2.0__tar.gz → 1.3.0__tar.gz
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.
- {modelsign-1.2.0 → modelsign-1.3.0}/.github/workflows/ci.yml +1 -1
- {modelsign-1.2.0 → modelsign-1.3.0}/CHANGELOG.md +20 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/PKG-INFO +48 -3
- {modelsign-1.2.0 → modelsign-1.3.0}/README.md +45 -2
- modelsign-1.3.0/docs/attestation.md +108 -0
- modelsign-1.3.0/docs/aws-kms.md +93 -0
- modelsign-1.3.0/docs/reviews/2026-12-03-v1.3.0.md +47 -0
- modelsign-1.3.0/docs/superpowers/plans/2026-12-03-kms.md +11 -0
- modelsign-1.3.0/docs/superpowers/specs/2026-12-03-kms-design.md +37 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/pyproject.toml +5 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/__init__.py +1 -1
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/api.py +32 -2
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/approvals.py +13 -3
- modelsign-1.3.0/src/modelsign/attest.py +392 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/cli.py +113 -8
- modelsign-1.3.0/src/modelsign/crypto/aws_kms.py +80 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/crypto/keys.py +41 -7
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/crypto/sign.py +15 -3
- modelsign-1.3.0/src/modelsign/crypto/signers.py +28 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/sig.py +19 -3
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign.egg-info/PKG-INFO +48 -3
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign.egg-info/SOURCES.txt +11 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign.egg-info/requires.txt +3 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_api.py +22 -0
- modelsign-1.3.0/tests/test_attest.py +277 -0
- modelsign-1.3.0/tests/test_digest_binding_review.py +42 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_keys.py +49 -0
- modelsign-1.3.0/tests/test_kms.py +224 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_timestamps.py +44 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/.github/FUNDING.yml +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/.gitignore +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/LICENSE +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/action.yml +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/docs/security-policy-follow-ons.md +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/docs/superpowers/plans/2026-12-03-rfc3161.md +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/docs/superpowers/specs/2026-12-03-rfc3161-design.md +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/docs/timestamps.md +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/setup.cfg +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/crypto/__init__.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/crypto/verify.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/formats/__init__.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/formats/directory.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/formats/single.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/guard.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/identity/__init__.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/identity/canonical.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/identity/card.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/lineage.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/middleware/__init__.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/middleware/response.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/oms.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign/timestamps.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign.egg-info/dependency_links.txt +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign.egg-info/entry_points.txt +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/src/modelsign.egg-info/top_level.txt +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/conftest.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_approvals.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_canonical.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_card.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_cli.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_formats.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_guard.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_integration.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_lineage.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_middleware.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_oms.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_sig.py +0 -0
- {modelsign-1.2.0 → modelsign-1.3.0}/tests/test_sign_verify.py +0 -0
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.3.0 (2026-12-03)
|
|
4
|
+
|
|
5
|
+
- Optional AWS KMS Ed25519 signing for models and approvals; pinned key/algorithm,
|
|
6
|
+
local verification of responses, offline verification, optional SDK dependency.
|
|
7
|
+
Experimental: tested through the SDK boundary, not against a live AWS key.
|
|
8
|
+
- Reject malformed attestation schemas and handle invalid Unicode as a controlled error.
|
|
9
|
+
- Malformed signature metadata fails verification instead of raising during digest generation.
|
|
10
|
+
- Key generation refuses incomplete or mismatched pairs, uses exclusive creation,
|
|
11
|
+
and restricts private-key permissions from the moment of creation.
|
|
12
|
+
- Keyring aliases cannot escape their directory; writes validate keys, reject symlink
|
|
13
|
+
destinations, and atomically replace entries without modifying hardlinked files.
|
|
14
|
+
|
|
15
|
+
- Runtime attestations (`modelsign.attest`): a serving process signs, per output,
|
|
16
|
+
a statement naming the verified model's signature digest and the output's hash.
|
|
17
|
+
- `VerifyResult.signature_digest` and `signer_key` (the key that verified), set on success.
|
|
18
|
+
- Attestations bind the verifying key, computed hash and identity hash; the
|
|
19
|
+
signature digest is carried as a label only, since it spans unauthenticated fields.
|
|
20
|
+
- `modelsign verify-attestation` for checking one against an output and a `.sig`.
|
|
21
|
+
- An attestation is a claim by the attestor key's holder, not proof of computation.
|
|
22
|
+
|
|
3
23
|
## v1.2.0 (2026-12-03)
|
|
4
24
|
|
|
5
25
|
- Optional RFC 3161 timestamps binding a model signature and its current approval chain.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: modelsign
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Sign AI models with identity. Verify anywhere. Part of the AURE Provenance stack by Constant Systems.
|
|
5
5
|
Author-email: James Kerr <qj@constantqj.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -24,6 +24,8 @@ Provides-Extra: middleware
|
|
|
24
24
|
Requires-Dist: fastapi>=0.100; extra == "middleware"
|
|
25
25
|
Provides-Extra: timestamp
|
|
26
26
|
Requires-Dist: asn1crypto>=1.5.1; extra == "timestamp"
|
|
27
|
+
Provides-Extra: aws-kms
|
|
28
|
+
Requires-Dist: boto3>=1.40.0; extra == "aws-kms"
|
|
27
29
|
Provides-Extra: dev
|
|
28
30
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
31
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
@@ -214,6 +216,41 @@ them, and `--min-approvals` counts **distinct** approvers: one person in two
|
|
|
214
216
|
roles is one person. Pinning specific approvers (`require_approval(keys=...)`)
|
|
215
217
|
takes public key PEM paths or key bytes, not fingerprints.
|
|
216
218
|
|
|
219
|
+
## Runtime attestations
|
|
220
|
+
|
|
221
|
+
A model signature says what the weights are, not which weights answered a
|
|
222
|
+
request. A serving process can close that gap by signing, for each output, a
|
|
223
|
+
statement that names the model it verified at load:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from modelsign.guard import require_verified
|
|
227
|
+
from modelsign.attest import Attestor, verify_attestation
|
|
228
|
+
|
|
229
|
+
result = require_verified("./model", pubkey="vendor.pem")
|
|
230
|
+
attestor = Attestor(result, key="serving.pem") # refuses an unverified model
|
|
231
|
+
|
|
232
|
+
attestation = attestor.attest(response_body, request=request_body) # log it, or return it
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
modelsign verify-attestation att.json --pubkey serving_pub.pem \
|
|
237
|
+
--output response.bin --model-sig model.sig --model-pubkey vendor.pem
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The statement carries what verification established about the model — the key
|
|
241
|
+
it verified under, the weights' hash and the hash of the identity card — plus
|
|
242
|
+
the SHA-256 of the output and optionally of the request, a nonce and the
|
|
243
|
+
attestor's key. `--model-pubkey` is what ties the attested model to a signer
|
|
244
|
+
you trust; `--model-sig` alone compares a label. It holds hashes
|
|
245
|
+
only, never the content. See [docs/attestation.md](docs/attestation.md) for
|
|
246
|
+
the exact format.
|
|
247
|
+
|
|
248
|
+
Be precise about what this proves: an attestation is a signed **claim by
|
|
249
|
+
whoever holds the serving key** that this output came from that model, and
|
|
250
|
+
evidence that neither was altered afterwards. It is not proof the computation
|
|
251
|
+
happened, which needs trusted hardware, and `issued_at` is the server's own
|
|
252
|
+
clock.
|
|
253
|
+
|
|
217
254
|
## OpenSSF Model Signing interoperability
|
|
218
255
|
|
|
219
256
|
```bash
|
|
@@ -332,6 +369,14 @@ Apache 2.0
|
|
|
332
369
|
Optional timestamps bind the model signature and current approval chain to a
|
|
333
370
|
trusted TSA time. See [the timestamp guide](docs/timestamps.md) for installation,
|
|
334
371
|
`--timestamp`, `--require-timestamp`, explicit CA trust and offline verification.
|
|
335
|
-
Install with `pip install "modelsign[timestamp]==1.
|
|
372
|
+
Install with `pip install "modelsign[timestamp]==1.3.0"` and OpenSSL 3. `signed_at` remains
|
|
336
373
|
self-reported; timestamps do not implement key revocation or prevent replay of
|
|
337
|
-
older valid releases.
|
|
374
|
+
older valid releases.
|
|
375
|
+
|
|
376
|
+
## AWS KMS signing (experimental, v1.3.0)
|
|
377
|
+
|
|
378
|
+
An optional AWS KMS backend signs through an existing pure-Ed25519 key while
|
|
379
|
+
keeping verification offline. See [the KMS guide](docs/aws-kms.md) for the signer
|
|
380
|
+
interface, optional SDK extra, IAM requirements and 4,096-byte signing-message
|
|
381
|
+
limit. This backend has SDK-contract tests, not live AWS validation, and is
|
|
382
|
+
available through `pip install "modelsign[aws-kms]==1.3.0"`.
|
|
@@ -182,6 +182,41 @@ them, and `--min-approvals` counts **distinct** approvers: one person in two
|
|
|
182
182
|
roles is one person. Pinning specific approvers (`require_approval(keys=...)`)
|
|
183
183
|
takes public key PEM paths or key bytes, not fingerprints.
|
|
184
184
|
|
|
185
|
+
## Runtime attestations
|
|
186
|
+
|
|
187
|
+
A model signature says what the weights are, not which weights answered a
|
|
188
|
+
request. A serving process can close that gap by signing, for each output, a
|
|
189
|
+
statement that names the model it verified at load:
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from modelsign.guard import require_verified
|
|
193
|
+
from modelsign.attest import Attestor, verify_attestation
|
|
194
|
+
|
|
195
|
+
result = require_verified("./model", pubkey="vendor.pem")
|
|
196
|
+
attestor = Attestor(result, key="serving.pem") # refuses an unverified model
|
|
197
|
+
|
|
198
|
+
attestation = attestor.attest(response_body, request=request_body) # log it, or return it
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
modelsign verify-attestation att.json --pubkey serving_pub.pem \
|
|
203
|
+
--output response.bin --model-sig model.sig --model-pubkey vendor.pem
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The statement carries what verification established about the model — the key
|
|
207
|
+
it verified under, the weights' hash and the hash of the identity card — plus
|
|
208
|
+
the SHA-256 of the output and optionally of the request, a nonce and the
|
|
209
|
+
attestor's key. `--model-pubkey` is what ties the attested model to a signer
|
|
210
|
+
you trust; `--model-sig` alone compares a label. It holds hashes
|
|
211
|
+
only, never the content. See [docs/attestation.md](docs/attestation.md) for
|
|
212
|
+
the exact format.
|
|
213
|
+
|
|
214
|
+
Be precise about what this proves: an attestation is a signed **claim by
|
|
215
|
+
whoever holds the serving key** that this output came from that model, and
|
|
216
|
+
evidence that neither was altered afterwards. It is not proof the computation
|
|
217
|
+
happened, which needs trusted hardware, and `issued_at` is the server's own
|
|
218
|
+
clock.
|
|
219
|
+
|
|
185
220
|
## OpenSSF Model Signing interoperability
|
|
186
221
|
|
|
187
222
|
```bash
|
|
@@ -300,6 +335,14 @@ Apache 2.0
|
|
|
300
335
|
Optional timestamps bind the model signature and current approval chain to a
|
|
301
336
|
trusted TSA time. See [the timestamp guide](docs/timestamps.md) for installation,
|
|
302
337
|
`--timestamp`, `--require-timestamp`, explicit CA trust and offline verification.
|
|
303
|
-
Install with `pip install "modelsign[timestamp]==1.
|
|
338
|
+
Install with `pip install "modelsign[timestamp]==1.3.0"` and OpenSSL 3. `signed_at` remains
|
|
304
339
|
self-reported; timestamps do not implement key revocation or prevent replay of
|
|
305
|
-
older valid releases.
|
|
340
|
+
older valid releases.
|
|
341
|
+
|
|
342
|
+
## AWS KMS signing (experimental, v1.3.0)
|
|
343
|
+
|
|
344
|
+
An optional AWS KMS backend signs through an existing pure-Ed25519 key while
|
|
345
|
+
keeping verification offline. See [the KMS guide](docs/aws-kms.md) for the signer
|
|
346
|
+
interface, optional SDK extra, IAM requirements and 4,096-byte signing-message
|
|
347
|
+
limit. This backend has SDK-contract tests, not live AWS validation, and is
|
|
348
|
+
available through `pip install "modelsign[aws-kms]==1.3.0"`.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Runtime attestations
|
|
2
|
+
|
|
3
|
+
`modelsign.attest` binds a served output to the signed model behind it.
|
|
4
|
+
|
|
5
|
+
## Making one
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from modelsign.guard import require_verified
|
|
9
|
+
from modelsign.attest import Attestor
|
|
10
|
+
|
|
11
|
+
result = require_verified("./model", pubkey="vendor.pem")
|
|
12
|
+
attestor = Attestor(result, key="serving.pem")
|
|
13
|
+
attestation = attestor.attest(response_body, request=request_body)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`Attestor` is built from a `VerifyResult` and refuses one that did not verify,
|
|
17
|
+
one that verified only against its own embedded key (`allow_untrusted=True`
|
|
18
|
+
opts out, and the statement then records `"trust": "embedded"`), and one with
|
|
19
|
+
no modelsign signature digest, such as an OMS bundle. Use a serving key that
|
|
20
|
+
is not the model-signing key: the two make different claims.
|
|
21
|
+
|
|
22
|
+
## Format
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"statement": {
|
|
27
|
+
"type": "modelsign-attestation",
|
|
28
|
+
"version": 1,
|
|
29
|
+
"model": {
|
|
30
|
+
"signer_key": "<base64 raw Ed25519 key the model verified under>",
|
|
31
|
+
"sha256": "sha256:<model or manifest hash, as computed>",
|
|
32
|
+
"identity_sha256": "sha256:<canonical JSON of the signed identity card>",
|
|
33
|
+
"name": "<name from the signed identity card>",
|
|
34
|
+
"trust": "pubkey | keyring | embedded",
|
|
35
|
+
"signature_digest": "sha256:<sig_digest of the model's .sig>"
|
|
36
|
+
},
|
|
37
|
+
"output_sha256": "sha256:<hex>",
|
|
38
|
+
"request_sha256": "sha256:<hex>",
|
|
39
|
+
"issued_at": "2026-12-03T17:00:00Z",
|
|
40
|
+
"nonce": "<32 hex chars>",
|
|
41
|
+
"attestor_key": "<base64 raw Ed25519 public key>"
|
|
42
|
+
},
|
|
43
|
+
"signature": "<base64 Ed25519 signature>"
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The signature is over `b"modelsign-attestation-v1\x00" + canonical_json(statement)`,
|
|
48
|
+
with RFC 8785 canonical JSON. `request_sha256` is present only when a request
|
|
49
|
+
was given.
|
|
50
|
+
|
|
51
|
+
`signer_key`, `sha256` and `identity_sha256` are the values verification
|
|
52
|
+
established: the key that did the verifying (not the one embedded in the
|
|
53
|
+
`.sig`), the hash computed from the bytes on disk, and the identity card the
|
|
54
|
+
signature covers. `signature_digest` is the digest lineage and approvals use.
|
|
55
|
+
It locates the `.sig`, but it also spans fields the model signature does not
|
|
56
|
+
authenticate (`signed_at`, the embedded public key, the `file` label, the
|
|
57
|
+
manifest listing), so someone able to edit the `.sig` can change it without
|
|
58
|
+
breaking verification. Treat it as a label, not as the binding.
|
|
59
|
+
|
|
60
|
+
Content is hashed as follows: `bytes` as they are, `str` as UTF-8, and any
|
|
61
|
+
other JSON value as its canonical encoding. The verifier must supply the same
|
|
62
|
+
form the server hashed.
|
|
63
|
+
|
|
64
|
+
## Checking one
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from modelsign.attest import verify_attestation
|
|
68
|
+
|
|
69
|
+
r = verify_attestation(attestation, pubkey="serving_pub.pem",
|
|
70
|
+
output=response_body, request=request_body,
|
|
71
|
+
model_sig="model.sig", model_pubkey="vendor.pem")
|
|
72
|
+
r.verified, r.output_checked, r.request_checked, r.model_checked, r.signer_checked
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
modelsign verify-attestation att.json --pubkey serving_pub.pem \
|
|
77
|
+
--output response.bin --request request.bin \
|
|
78
|
+
--model-sig model.sig --model-pubkey vendor.pem --json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The key inside the attestation is never used to verify it; it must equal the
|
|
82
|
+
key you supply, compared on whole key bytes, and a non-canonical base64
|
|
83
|
+
encoding is refused. A bad attestation is a falsy result rather than an
|
|
84
|
+
exception. The signature alone shows the attestor made *some* statement, so
|
|
85
|
+
the result records which of output, request, model and signer were actually
|
|
86
|
+
compared. `model_sig` alone is compared as a label; with `model_pubkey` the
|
|
87
|
+
attested signer must be that key and the `.sig` must verify under it.
|
|
88
|
+
The CLI reads `--output` and `--request` as raw bytes.
|
|
89
|
+
|
|
90
|
+
## What it does and does not establish
|
|
91
|
+
|
|
92
|
+
Established, given trust in the attestor key: its holder stated that this
|
|
93
|
+
output (and request) came from the model with this signature digest, and
|
|
94
|
+
neither the statement nor the hashed content has changed since.
|
|
95
|
+
|
|
96
|
+
Not established:
|
|
97
|
+
|
|
98
|
+
- that the computation happened as claimed. Whoever holds the serving key can
|
|
99
|
+
sign any statement; this format supplies no independent proof of execution.
|
|
100
|
+
- when it happened. `issued_at` is the attestor's own clock.
|
|
101
|
+
- that the model's signature is itself trustworthy. Check the `.sig` with
|
|
102
|
+
`modelsign verify` under your own key and approval policy.
|
|
103
|
+
- uniqueness. The nonce makes two attestations of one output distinct; it does
|
|
104
|
+
not stop an attestation from being presented twice.
|
|
105
|
+
|
|
106
|
+
Verification validates required v1 fields, digest encodings, nonce shape, and
|
|
107
|
+
the UTC timestamp syntax even for a signature-only check. Timestamp syntax
|
|
108
|
+
validation does not establish freshness or trust in the serving clock.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# AWS KMS signing (experimental)
|
|
2
|
+
|
|
3
|
+
Install with `pip install 'modelsign[aws-kms]==1.3.0'`. This backend has
|
|
4
|
+
SDK-contract tests but has not been validated against a live AWS key.
|
|
5
|
+
It uses an **existing** AWS KMS
|
|
6
|
+
`ECC_NIST_EDWARDS25519` / `SIGN_VERIFY` key and the `ED25519_SHA_512` algorithm.
|
|
7
|
+
It does not create keys, alter IAM, upload PEM keys, or fall back to a local key.
|
|
8
|
+
|
|
9
|
+
Authentication follows boto3's normal credential chain (for example a configured
|
|
10
|
+
profile, environment, or workload role). Use an approved account and region.
|
|
11
|
+
The principal needs `kms:GetPublicKey` and `kms:Sign` on the selected key.
|
|
12
|
+
AWS charges and regional algorithm availability are governed by your AWS account.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
modelsign sign model.safetensors --name Example \
|
|
16
|
+
--kms-key-id arn:aws:kms:REGION:ACCOUNT:key/KEY-ID --aws-region REGION
|
|
17
|
+
modelsign approve model.safetensors --role release \
|
|
18
|
+
--kms-key-id arn:aws:kms:REGION:ACCOUNT:key/APPROVER-KEY-ID --aws-region REGION
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`--key` and `--kms-key-id` are mutually exclusive. `--aws-region` requires the KMS
|
|
22
|
+
option; otherwise the SDK can choose a region from your configuration. Aliases
|
|
23
|
+
are accepted, but resolved once to a key ARN: each signer instance pins that ARN
|
|
24
|
+
and its exported public key, so alias retargeting does not change the instance.
|
|
25
|
+
|
|
26
|
+
The existing timestamp flags can be combined with KMS signing; install both
|
|
27
|
+
extras with `pip install 'modelsign[aws-kms,timestamp]==1.3.0'` and provide the TSA CA bundle.
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from modelsign.api import sign_model
|
|
31
|
+
from modelsign.approvals import approve
|
|
32
|
+
from modelsign.crypto.aws_kms import AwsKmsSigner
|
|
33
|
+
|
|
34
|
+
signer = AwsKmsSigner("alias/modelsign", region_name="us-east-1")
|
|
35
|
+
sign_model("model.safetensors", name="Example", signer=signer)
|
|
36
|
+
approve("model.safetensors", role="release", signer=signer)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Public key and verification
|
|
40
|
+
|
|
41
|
+
Obtain and authenticate the public key through your deployment's trusted channel.
|
|
42
|
+
For example, an administrator using their authenticated AWS account can export it:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from pathlib import Path
|
|
46
|
+
from cryptography.hazmat.primitives import serialization
|
|
47
|
+
from modelsign.crypto.aws_kms import AwsKmsSigner
|
|
48
|
+
|
|
49
|
+
signer = AwsKmsSigner("YOUR_KEY_ARN", region_name="YOUR_REGION")
|
|
50
|
+
Path("publisher-public.pem").write_bytes(signer.public_key().public_bytes(
|
|
51
|
+
serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo))
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Distribute that public key through an independently trusted channel. Verifiers
|
|
55
|
+
use the existing command, offline and without boto3 or AWS credentials:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
modelsign verify model.safetensors --pubkey publisher-public.pem
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
An ARN is not a cryptographic trust anchor. Neither the ARN nor credentials are
|
|
62
|
+
automatically added to the identity card. KMS signs the exact ModelSign message:
|
|
63
|
+
the model hash and identity-card contents (or approval fields) go to AWS; model
|
|
64
|
+
weights and the signing private key do not leave their respective locations.
|
|
65
|
+
|
|
66
|
+
## Compatibility and failure behavior
|
|
67
|
+
|
|
68
|
+
The signer interface exposes `public_key()` and `sign(message)` using pure Ed25519.
|
|
69
|
+
Local PEM keys and loaded Ed25519 keys remain supported. Model signature format,
|
|
70
|
+
approval messages, lineage, timestamp binding and offline verification stay the
|
|
71
|
+
same. Each returned signature is checked locally against the key embedded in the
|
|
72
|
+
result before a file is written.
|
|
73
|
+
|
|
74
|
+
AWS accepts at most **4,096 bytes** in RAW mode. That limit applies to the full
|
|
75
|
+
ModelSign signing message, including the identity card, not the model file.
|
|
76
|
+
Large cards are rejected with a clear error. This backend never substitutes a
|
|
77
|
+
prehashed message or Ed25519ph, which would break existing verification.
|
|
78
|
+
|
|
79
|
+
Unsupported keys, unexpected response key/algorithm, invalid returned signatures,
|
|
80
|
+
and service failures fail closed. Existing signature files are preserved on
|
|
81
|
+
signing or timestamp-request failure. SDK clients created by this backend use
|
|
82
|
+
5-second connect and 15-second read timeouts with at most two attempts; caller-
|
|
83
|
+
supplied SDK clients retain their own configuration.
|
|
84
|
+
|
|
85
|
+
## Test status
|
|
86
|
+
|
|
87
|
+
The implementation is tested using botocore Stubber with exact request parameters
|
|
88
|
+
and real local Ed25519 signatures returned at the SDK boundary. This exercises
|
|
89
|
+
local verification and policy, but **is not a live AWS KMS interoperability test**.
|
|
90
|
+
No production AWS account or key has been provisioned or used for this branch.
|
|
91
|
+
|
|
92
|
+
References: [AWS Sign](https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html),
|
|
93
|
+
[AWS GetPublicKey](https://docs.aws.amazon.com/kms/latest/APIReference/API_GetPublicKey.html).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# v1.3.0 release review
|
|
2
|
+
|
|
3
|
+
Scope: combined runtime attestations, optional AWS KMS signing, timestamp composition,
|
|
4
|
+
malformed-input handling, and the key-management paths used by these features.
|
|
5
|
+
|
|
6
|
+
## Findings resolved
|
|
7
|
+
|
|
8
|
+
- Attestation verification accepted signed malformed statements with missing or invalid
|
|
9
|
+
required hashes, nonce, clock syntax, trust label, or non-integer version. These now fail.
|
|
10
|
+
- Lone-surrogate output text escaped the content-error boundary. It now produces a
|
|
11
|
+
controlled error on creation and a failed verification result on checking.
|
|
12
|
+
- Canonicalization of unsigned model-signature metadata could raise after successful
|
|
13
|
+
cryptographic verification. Envelope canonicalization now runs inside the malformed-input handler.
|
|
14
|
+
- Key generation could overwrite one half of an existing pair. Incomplete/mismatched
|
|
15
|
+
pairs now fail without replacement; creation is exclusive, with private mode 0600.
|
|
16
|
+
- Keyring aliases allowed path traversal. Aliases now permit only a leading ASCII
|
|
17
|
+
letter/digit followed by letters/digits, underscore, dot, or hyphen.
|
|
18
|
+
- Keyring writes followed destination symlinks/hardlinks. Symlinks are rejected;
|
|
19
|
+
validated PEMs are atomically replaced, preserving outside hardlinked files.
|
|
20
|
+
|
|
21
|
+
Regression tests reproduced failures before fixes. An independent read-only review
|
|
22
|
+
found the malformed-metadata exception; the follow-up review found no additional
|
|
23
|
+
important issues in the reviewed changes.
|
|
24
|
+
|
|
25
|
+
- Signature-reader field types are checked before use; numeric hashes and malformed
|
|
26
|
+
identity/approval/timestamp containers fail instead of crashing or passing through.
|
|
27
|
+
|
|
28
|
+
## Verification and performance
|
|
29
|
+
|
|
30
|
+
The integrated end-to-end test covers KMS signing and approval (SDK stub with real
|
|
31
|
+
Ed25519 signatures), RFC 3161 timestamps from a local test authority, verified model
|
|
32
|
+
load, output/request attestation, and independent signer checks. Altered content
|
|
33
|
+
and wrong keys are rejected. No model bytes or keys are sent to live AWS.
|
|
34
|
+
|
|
35
|
+
A local Python 3.12 benchmark performed five rounds of 1,000 attest+verify operations
|
|
36
|
+
on a 1 KiB output. Median round-average: 0.113 ms per operation pair. This excludes
|
|
37
|
+
network calls and model inference and is not a cross-platform performance guarantee.
|
|
38
|
+
No cryptographic checks were removed for performance.
|
|
39
|
+
|
|
40
|
+
## Boundaries
|
|
41
|
+
|
|
42
|
+
This is a bounded source/test review, not a claim that all possible bugs are exhausted.
|
|
43
|
+
The AWS backend remains experimental pending live interoperability validation.
|
|
44
|
+
Serving attestations are signed claims, with no execution proof, freshness policy,
|
|
45
|
+
or replay-prevention state. Caller-owned mutable verification results are not a
|
|
46
|
+
security boundary against code already executing in the serving process. No C2PA,
|
|
47
|
+
revocation feed, transparency log, or monotonic rollback policy is added here.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# KMS implementation plan
|
|
2
|
+
|
|
3
|
+
Spec: ../specs/2026-12-03-kms-design.md
|
|
4
|
+
|
|
5
|
+
- [x] Write failing tests for signer API/approval and AWS SDK contract.
|
|
6
|
+
- [x] Add signer protocol/local resolution and optional AwsKmsSigner; verify returned signatures locally.
|
|
7
|
+
- [x] Add explicit API signer and mutually exclusive CLI AWS options; keep verification offline.
|
|
8
|
+
- [x] Run all tests/type checks, package validation, independent review and fix important findings.
|
|
9
|
+
- [x] Document setup/limitations, commit and push a separate draft PR. Do not publish this backend as a tested live AWS integration.
|
|
10
|
+
|
|
11
|
+
Validation: 277 tests passed; mypy passed for 23 source files; wheel and source archive passed twine check; independent review found no important defects. AWS responses are stubbed; no live AWS account/key was used.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# KMS signing design
|
|
2
|
+
|
|
3
|
+
Scope: provider-neutral Ed25519 signer interface plus an optional AWS KMS backend,
|
|
4
|
+
on a separate branch after RFC 3161. No cloud key creation, IAM changes, automatic
|
|
5
|
+
PEM upload, remote verification dependency, KMS encryption or new signature format.
|
|
6
|
+
AWS is the default selected by Codex after asking for a provider preference.
|
|
7
|
+
|
|
8
|
+
A signer exposes `public_key() -> Ed25519PublicKey` and `sign(message: bytes) -> bytes`.
|
|
9
|
+
Existing loaded Ed25519 keys satisfy this interface; PEM paths keep working. The
|
|
10
|
+
API accepts an explicit `signer` argument mutually exclusive with `key`. The CLI
|
|
11
|
+
exposes `--kms-key-id` and optional `--aws-region` on sign and approve, mutually
|
|
12
|
+
exclusive with local --key. boto3 is an optional `aws-kms` extra, imported only when
|
|
13
|
+
creating an AWS client. Authentication uses the SDK's normal credential chain.
|
|
14
|
+
|
|
15
|
+
AWS backend: GetPublicKey must describe SIGN_VERIFY / ECC_NIST_EDWARDS25519 with
|
|
16
|
+
ED25519_SHA_512 support and valid Ed25519 SPKI. Resolve aliases once, pin the returned
|
|
17
|
+
key ARN, and use that ARN for every Sign call. Sign with MessageType RAW and
|
|
18
|
+
ED25519_SHA_512 only. Never prehash or use Ed25519ph as a workaround for the 4096-byte
|
|
19
|
+
AWS limit: reject oversized ModelSign messages. Require matching response ARN and
|
|
20
|
+
algorithm, then verify the returned signature locally against the pinned key before
|
|
21
|
+
accepting it. Network errors fail closed; no fallback to a local key.
|
|
22
|
+
|
|
23
|
+
Publish only the existing public key/signature fields. A KMS ARN is not a trust
|
|
24
|
+
anchor and is not automatically embedded in the signed identity. Verification stays
|
|
25
|
+
offline with existing trusted public-key policy; it needs neither AWS credentials
|
|
26
|
+
nor boto3. Keep approval messages and timestamp integration identical.
|
|
27
|
+
|
|
28
|
+
Validation: native keys and remote signer agree on messages; real cryptographic
|
|
29
|
+
signatures returned via botocore Stubber, with exact AWS request parameters; API,
|
|
30
|
+
CLI, approve and timestamp composition; alias resolution, wrong key/algorithm/SPKI,
|
|
31
|
+
service denial, missing SDK, invalid returned signature, message size boundary,
|
|
32
|
+
mutually exclusive key selection and preservation of files on failure. A stubbed
|
|
33
|
+
SDK test is not a live AWS integration test. No live account/key is configured or
|
|
34
|
+
created without explicit authorization.
|
|
35
|
+
|
|
36
|
+
References: https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html and
|
|
37
|
+
https://docs.aws.amazon.com/kms/latest/APIReference/API_GetPublicKey.html
|
|
@@ -27,6 +27,7 @@ dependencies = [
|
|
|
27
27
|
[project.optional-dependencies]
|
|
28
28
|
middleware = ["fastapi>=0.100"]
|
|
29
29
|
timestamp = ["asn1crypto>=1.5.1"]
|
|
30
|
+
aws-kms = ["boto3>=1.40.0"]
|
|
30
31
|
dev = ["pytest>=7.0", "pytest-cov", "mypy"]
|
|
31
32
|
|
|
32
33
|
[project.scripts]
|
|
@@ -62,3 +63,7 @@ testpaths = ["tests"]
|
|
|
62
63
|
[[tool.mypy.overrides]]
|
|
63
64
|
module = ["asn1crypto.*"]
|
|
64
65
|
ignore_missing_imports = true
|
|
66
|
+
|
|
67
|
+
[[tool.mypy.overrides]]
|
|
68
|
+
module = ["boto3.*", "botocore.*"]
|
|
69
|
+
ignore_missing_imports = true
|
|
@@ -36,6 +36,7 @@ from modelsign.formats.single import hash_file
|
|
|
36
36
|
from modelsign.identity.canonical import canonical_json
|
|
37
37
|
from modelsign.identity.card import ModelCard, validate_card
|
|
38
38
|
from modelsign.sig import SigFile, read_sig, sig_digest, write_sig
|
|
39
|
+
from modelsign.crypto.signers import Ed25519Signer, validate_signer
|
|
39
40
|
|
|
40
41
|
DEFAULT_KEY_DIR = Path.home() / ".modelsign"
|
|
41
42
|
|
|
@@ -89,6 +90,24 @@ class VerifyResult:
|
|
|
89
90
|
timestamp: Optional[dict] = None
|
|
90
91
|
"""Verified TSA result, or None when timestamp policy was not checked."""
|
|
91
92
|
|
|
93
|
+
signature_digest: Optional[str] = None
|
|
94
|
+
"""Digest of the signature that verified (``sig_digest``), set on success.
|
|
95
|
+
|
|
96
|
+
It identifies the ``.sig`` as presented, and that includes fields the
|
|
97
|
+
signature does not authenticate: ``signed_at``, the embedded public key,
|
|
98
|
+
the ``file`` label and the manifest listing. Someone who can edit the
|
|
99
|
+
``.sig`` can change this digest without breaking verification, so use it
|
|
100
|
+
to find a signature, and rely on ``signer_key``, ``sha256`` and
|
|
101
|
+
``identity`` for what was actually checked.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
signer_key: Optional[str] = None
|
|
105
|
+
"""Base64 raw bytes of the key the signature verified under, on success.
|
|
106
|
+
|
|
107
|
+
This is the key that did the verifying — the caller's or the keyring's —
|
|
108
|
+
never the one embedded in the ``.sig``, unless ``trust`` is ``embedded``.
|
|
109
|
+
"""
|
|
110
|
+
|
|
92
111
|
@property
|
|
93
112
|
def trusted(self) -> bool:
|
|
94
113
|
"""True only when the signing identity was checked against a known key."""
|
|
@@ -155,6 +174,7 @@ def sign_model(
|
|
|
155
174
|
card: ModelCard | dict | None = None,
|
|
156
175
|
name: str | None = None,
|
|
157
176
|
key: Ed25519PrivateKey | Path | str | None = None,
|
|
177
|
+
signer: Ed25519Signer | None = None,
|
|
158
178
|
sig_path: Path | str | None = None,
|
|
159
179
|
parent: Path | str | SigFile | None = None,
|
|
160
180
|
write: bool = True,
|
|
@@ -165,6 +185,8 @@ def sign_model(
|
|
|
165
185
|
|
|
166
186
|
Provide either ``card`` (full identity) or ``name``. ``key`` may be a
|
|
167
187
|
loaded private key or a path to a PEM; it defaults to the keygen location.
|
|
188
|
+
Alternatively provide an Ed25519 ``signer`` backend, mutually exclusive with
|
|
189
|
+
``key``. Verification remains offline against the resulting public key.
|
|
168
190
|
|
|
169
191
|
``parent`` is the signature of the model this one was derived from; its
|
|
170
192
|
digest is recorded in the card as ``parent_signature``, which
|
|
@@ -178,7 +200,12 @@ def sign_model(
|
|
|
178
200
|
if not model_path.exists():
|
|
179
201
|
raise VerifyError(f"model not found: {model_path}")
|
|
180
202
|
|
|
181
|
-
|
|
203
|
+
private_key: Ed25519Signer
|
|
204
|
+
if signer is not None:
|
|
205
|
+
if key is not None:
|
|
206
|
+
raise VerifyError("key and signer are mutually exclusive")
|
|
207
|
+
private_key = validate_signer(signer)
|
|
208
|
+
elif isinstance(key, Ed25519PrivateKey):
|
|
182
209
|
private_key = key
|
|
183
210
|
else:
|
|
184
211
|
priv_path = Path(key).expanduser() if key is not None else DEFAULT_KEY_DIR / "private.pem"
|
|
@@ -216,7 +243,7 @@ def sign_model(
|
|
|
216
243
|
modelsign_version="2.0",
|
|
217
244
|
file=model_path.name,
|
|
218
245
|
sha256=f"sha256:{model_hash}",
|
|
219
|
-
signature=base64.b64encode(sign_bytes(message, private_key)).decode("ascii"),
|
|
246
|
+
signature=base64.b64encode(sign_bytes(message, private_key, public_key=pub_key)).decode("ascii"),
|
|
220
247
|
algorithm="ed25519",
|
|
221
248
|
signed_at=time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
|
222
249
|
public_key=base64.b64encode(public_key_to_bytes(pub_key)).decode("ascii"),
|
|
@@ -299,6 +326,7 @@ def verify_model(
|
|
|
299
326
|
# failed verification rather than an exception the caller must anticipate.
|
|
300
327
|
try:
|
|
301
328
|
sig = read_sig(sig_file, validate_fingerprint=True)
|
|
329
|
+
envelope_digest = sig_digest(sig)
|
|
302
330
|
except Exception as e:
|
|
303
331
|
return VerifyResult(
|
|
304
332
|
verified=False,
|
|
@@ -461,6 +489,8 @@ def verify_model(
|
|
|
461
489
|
return VerifyResult(
|
|
462
490
|
verified=True,
|
|
463
491
|
timestamp=timestamp_result,
|
|
492
|
+
signature_digest=envelope_digest,
|
|
493
|
+
signer_key=base64.b64encode(public_key_to_bytes(key)).decode("ascii"),
|
|
464
494
|
model=str(model_path),
|
|
465
495
|
sha256=f"sha256:{model_hash}",
|
|
466
496
|
fingerprint=fingerprint,
|
|
@@ -47,6 +47,7 @@ from modelsign.crypto.sign import _length_prefixed, sign_bytes
|
|
|
47
47
|
from modelsign.crypto.verify import verify_bytes
|
|
48
48
|
from modelsign.identity.canonical import canonical_json
|
|
49
49
|
from modelsign.sig import SigFile, read_sig, sig_digest, write_sig
|
|
50
|
+
from modelsign.crypto.signers import Ed25519Signer, validate_signer
|
|
50
51
|
|
|
51
52
|
__all__ = [
|
|
52
53
|
"Approval",
|
|
@@ -136,7 +137,8 @@ class Approval:
|
|
|
136
137
|
def approve(
|
|
137
138
|
model_path: Path | str,
|
|
138
139
|
*,
|
|
139
|
-
key: Ed25519PrivateKey | Path | str,
|
|
140
|
+
key: Ed25519PrivateKey | Path | str | None = None,
|
|
141
|
+
signer: Ed25519Signer | None = None,
|
|
140
142
|
role: str,
|
|
141
143
|
approver: str = "",
|
|
142
144
|
sig_path: Path | str | None = None,
|
|
@@ -162,7 +164,15 @@ def approve(
|
|
|
162
164
|
sig = read_sig(sig_file)
|
|
163
165
|
digest = sig_digest(sig)
|
|
164
166
|
|
|
165
|
-
private_key
|
|
167
|
+
private_key: Ed25519Signer
|
|
168
|
+
if signer is not None:
|
|
169
|
+
if key is not None:
|
|
170
|
+
raise ApprovalError("key and signer are mutually exclusive")
|
|
171
|
+
private_key = validate_signer(signer)
|
|
172
|
+
elif key is not None:
|
|
173
|
+
private_key = key if isinstance(key, Ed25519PrivateKey) else load_private_key(Path(key))
|
|
174
|
+
else:
|
|
175
|
+
raise ApprovalError("provide key or signer for approval")
|
|
166
176
|
public_key = private_key.public_key()
|
|
167
177
|
approved_at = when or time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
|
168
178
|
|
|
@@ -198,7 +208,7 @@ def approve(
|
|
|
198
208
|
"prev": prev_digest,
|
|
199
209
|
"public_key": base64.b64encode(public_key_to_bytes(public_key)).decode("ascii"),
|
|
200
210
|
"key_fingerprint": fingerprint,
|
|
201
|
-
"signature": base64.b64encode(sign_bytes(message, private_key)).decode("ascii"),
|
|
211
|
+
"signature": base64.b64encode(sign_bytes(message, private_key, public_key=public_key)).decode("ascii"),
|
|
202
212
|
}
|
|
203
213
|
existing.append(record)
|
|
204
214
|
sig.approvals = existing
|