modelsign 1.0.4__tar.gz → 1.2.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.
Files changed (64) hide show
  1. modelsign-1.2.0/.github/FUNDING.yml +3 -0
  2. modelsign-1.2.0/.github/workflows/ci.yml +108 -0
  3. {modelsign-1.0.4 → modelsign-1.2.0}/.gitignore +3 -0
  4. {modelsign-1.0.4 → modelsign-1.2.0}/CHANGELOG.md +11 -0
  5. modelsign-1.2.0/PKG-INFO +337 -0
  6. modelsign-1.2.0/README.md +305 -0
  7. modelsign-1.2.0/action.yml +83 -0
  8. modelsign-1.2.0/docs/security-policy-follow-ons.md +30 -0
  9. modelsign-1.2.0/docs/superpowers/plans/2026-12-03-rfc3161.md +29 -0
  10. modelsign-1.2.0/docs/superpowers/specs/2026-12-03-rfc3161-design.md +31 -0
  11. modelsign-1.2.0/docs/timestamps.md +108 -0
  12. {modelsign-1.0.4 → modelsign-1.2.0}/pyproject.toml +21 -1
  13. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/__init__.py +15 -1
  14. modelsign-1.2.0/src/modelsign/api.py +473 -0
  15. modelsign-1.2.0/src/modelsign/approvals.py +424 -0
  16. modelsign-1.2.0/src/modelsign/cli.py +642 -0
  17. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/crypto/keys.py +23 -12
  18. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/crypto/sign.py +31 -0
  19. modelsign-1.2.0/src/modelsign/formats/directory.py +70 -0
  20. modelsign-1.2.0/src/modelsign/guard.py +454 -0
  21. modelsign-1.2.0/src/modelsign/lineage.py +275 -0
  22. modelsign-1.2.0/src/modelsign/oms.py +487 -0
  23. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/sig.py +30 -2
  24. modelsign-1.2.0/src/modelsign/timestamps.py +227 -0
  25. modelsign-1.2.0/src/modelsign.egg-info/PKG-INFO +337 -0
  26. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign.egg-info/SOURCES.txt +19 -1
  27. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign.egg-info/requires.txt +3 -0
  28. modelsign-1.2.0/tests/conftest.py +94 -0
  29. modelsign-1.2.0/tests/test_api.py +366 -0
  30. modelsign-1.2.0/tests/test_approvals.py +432 -0
  31. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_cli.py +141 -4
  32. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_formats.py +33 -0
  33. modelsign-1.2.0/tests/test_guard.py +660 -0
  34. modelsign-1.2.0/tests/test_lineage.py +313 -0
  35. modelsign-1.2.0/tests/test_oms.py +328 -0
  36. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_sig.py +3 -3
  37. modelsign-1.2.0/tests/test_timestamps.py +317 -0
  38. modelsign-1.0.4/.github/workflows/ci.yml +0 -51
  39. modelsign-1.0.4/PKG-INFO +0 -151
  40. modelsign-1.0.4/README.md +0 -121
  41. modelsign-1.0.4/src/modelsign/cli.py +0 -453
  42. modelsign-1.0.4/src/modelsign/formats/directory.py +0 -33
  43. modelsign-1.0.4/src/modelsign.egg-info/PKG-INFO +0 -151
  44. modelsign-1.0.4/tests/conftest.py +0 -45
  45. {modelsign-1.0.4 → modelsign-1.2.0}/LICENSE +0 -0
  46. {modelsign-1.0.4 → modelsign-1.2.0}/setup.cfg +0 -0
  47. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/crypto/__init__.py +0 -0
  48. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/crypto/verify.py +0 -0
  49. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/formats/__init__.py +0 -0
  50. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/formats/single.py +0 -0
  51. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/identity/__init__.py +0 -0
  52. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/identity/canonical.py +0 -0
  53. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/identity/card.py +0 -0
  54. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/middleware/__init__.py +0 -0
  55. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign/middleware/response.py +0 -0
  56. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign.egg-info/dependency_links.txt +0 -0
  57. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign.egg-info/entry_points.txt +0 -0
  58. {modelsign-1.0.4 → modelsign-1.2.0}/src/modelsign.egg-info/top_level.txt +0 -0
  59. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_canonical.py +0 -0
  60. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_card.py +0 -0
  61. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_integration.py +0 -0
  62. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_keys.py +0 -0
  63. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_middleware.py +0 -0
  64. {modelsign-1.0.4 → modelsign-1.2.0}/tests/test_sign_verify.py +0 -0
@@ -0,0 +1,3 @@
1
+ # Enables the "Sponsor" button at the top of the repository.
2
+ buy_me_a_coffee: qjkerr1
3
+ github: [QuantQJ]
@@ -0,0 +1,108 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ # Without this a tag push does not match `branches`, so the workflow never
7
+ # ran for a tag and the publish job below was unreachable.
8
+ tags: ['v*']
9
+ pull_request:
10
+ branches: [main]
11
+
12
+ jobs:
13
+ test:
14
+ # ubuntu-latest is Ubuntu 26.04, which has no Python 3.9, so that leg pins
15
+ # an older runner rather than dropping the version pyproject still claims.
16
+ runs-on: ${{ matrix.runner }}
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ include:
21
+ - python-version: "3.9"
22
+ runner: ubuntu-24.04
23
+ - python-version: "3.11"
24
+ runner: ubuntu-latest
25
+ - python-version: "3.12"
26
+ runner: ubuntu-latest
27
+ - python-version: "3.13"
28
+ runner: ubuntu-latest
29
+
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+
33
+ - name: Set up Python ${{ matrix.python-version }}
34
+ uses: actions/setup-python@v5
35
+ with:
36
+ python-version: ${{ matrix.python-version }}
37
+
38
+ - name: Install dependencies
39
+ run: pip install -e ".[dev,timestamp]"
40
+
41
+ - name: Run tests
42
+ run: pytest tests/ -v --tb=short
43
+
44
+ - name: Type check
45
+ run: mypy
46
+
47
+ action:
48
+ needs: test
49
+ runs-on: ubuntu-latest
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+
53
+ - uses: actions/setup-python@v5
54
+ with:
55
+ python-version: "3.12"
56
+
57
+ - name: Install this checkout
58
+ run: pip install -e .
59
+
60
+ - name: Build signed fixtures
61
+ run: |
62
+ # Separate models per format: a modelsign directory signature covers
63
+ # every file in the directory, including a bundle written into it.
64
+ for d in fixture-modelsign fixture-oms; do
65
+ mkdir -p "$d"
66
+ echo "weights" > "$d/model.safetensors"
67
+ echo '{"model_type":"llama"}' > "$d/config.json"
68
+ done
69
+ modelsign keygen --out keys/private.pem
70
+ modelsign sign fixture-modelsign --name "CI-Fixture" --key keys/private.pem
71
+ modelsign oms keygen --dir keys
72
+ modelsign oms export fixture-oms --key keys/oms_private.pem \
73
+ --out fixture-oms/model.sig
74
+
75
+ - name: Action verifies a modelsign signature
76
+ uses: ./
77
+ with:
78
+ model: fixture-modelsign
79
+ pubkey: keys/public.pem
80
+
81
+ - name: Action verifies an OMS bundle
82
+ uses: ./
83
+ with:
84
+ model: fixture-oms
85
+ oms-pubkey: keys/oms_public.pem
86
+
87
+ publish:
88
+ needs: test
89
+ runs-on: ubuntu-latest
90
+ if: startsWith(github.ref, 'refs/tags/v')
91
+ permissions:
92
+ id-token: write
93
+ steps:
94
+ - uses: actions/checkout@v4
95
+
96
+ - name: Set up Python
97
+ uses: actions/setup-python@v5
98
+ with:
99
+ python-version: "3.12"
100
+
101
+ - name: Install build tools
102
+ run: pip install build
103
+
104
+ - name: Build package
105
+ run: python -m build
106
+
107
+ - name: Publish to PyPI
108
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -4,3 +4,6 @@ dist/
4
4
  build/
5
5
  .mypy_cache/
6
6
  *.pyc
7
+
8
+ # local virtualenv
9
+ .venv/
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.2.0 (2026-12-03)
4
+
5
+ - Optional RFC 3161 timestamps binding a model signature and its current approval chain.
6
+ - `sign`/`approve --timestamp URL --tsa-ca FILE`; failures preserve the existing signature.
7
+ - Offline `verify --require-timestamp` and matching direct/installed guard policy.
8
+ - Explicit TSA roots, OpenSSL 3 verification, optional `timestamp` extra.
9
+ - Bounded HTTP responses and a hard total network deadline.
10
+ - Existing model signatures and lineage digests remain compatible.
11
+ - Tested with local test authorities and the external FreeTSA service.
12
+ - Timestamps do not implement revocation, archival validation or rollback prevention.
13
+
3
14
  ## v1.0.0 (2026-03-25)
4
15
 
5
16
  Initial release.
@@ -0,0 +1,337 @@
1
+ Metadata-Version: 2.4
2
+ Name: modelsign
3
+ Version: 1.2.0
4
+ Summary: Sign AI models with identity. Verify anywhere. Part of the AURE Provenance stack by Constant Systems.
5
+ Author-email: James Kerr <qj@constantqj.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://constantsystems.ai/provenance
8
+ Project-URL: Repository, https://github.com/QuantQJ/modelsign
9
+ Project-URL: Issues, https://github.com/QuantQJ/modelsign/issues
10
+ Project-URL: Documentation, https://constantsystems.ai/provenance
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Security :: Cryptography
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: cryptography>=41.0
21
+ Requires-Dist: click>=8.0
22
+ Requires-Dist: rfc8785>=0.1.2
23
+ Provides-Extra: middleware
24
+ Requires-Dist: fastapi>=0.100; extra == "middleware"
25
+ Provides-Extra: timestamp
26
+ Requires-Dist: asn1crypto>=1.5.1; extra == "timestamp"
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: pytest-cov; extra == "dev"
30
+ Requires-Dist: mypy; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # modelsign
34
+
35
+ [![CI](https://github.com/QuantQJ/modelsign/actions/workflows/ci.yml/badge.svg)](https://github.com/QuantQJ/modelsign/actions/workflows/ci.yml)
36
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
37
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
38
+ [![Buy Me a Coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-%E2%98%95-FFDD00?logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/qjkerr1)
39
+ [![GitHub Sponsors](https://img.shields.io/badge/Sponsor-%E2%9D%A4-ea4aaa?logo=github)](https://github.com/sponsors/QuantQJ)
40
+
41
+ **Unsigned model weights fail to load.**
42
+
43
+ A signature nothing checks protects nothing. `modelsign` puts the check in the place every Python ML stack passes through — the Hugging Face Hub download path — so weights that are unsigned, modified, or signed by a key you don't trust raise an exception instead of loading.
44
+
45
+ It reads and writes [OpenSSF Model Signing](https://github.com/google/model-transparency) bundles, so it works in projects that have already standardized on OMS.
46
+
47
+ ```bash
48
+ pip install modelsign
49
+ ```
50
+
51
+ ## Fail closed at load time
52
+
53
+ ```python
54
+ import modelsign.guard as guard
55
+
56
+ guard.install(pubkey="~/keys/vendor.pem") # or set MODELSIGN_PUBKEY
57
+
58
+ from transformers import AutoModel
59
+ AutoModel.from_pretrained("acme/llama-8b") # LoadBlocked unless it verifies
60
+ ```
61
+
62
+ One hook covers `transformers`, `sentence-transformers`, `diffusers` and vLLM, because they all download through `huggingface_hub`. The guard:
63
+
64
+ - fetches `MODEL.sig` from the same repo as the weights rather than hoping it is already on disk;
65
+ - refuses a download with **no** signature (`allow_unsigned=True` if you must);
66
+ - requires a signature over the **whole snapshot** — a directory signature at `modelsign.sig` inside the repo (or `<dir>.sig` beside it), or an OMS bundle at `model.sig` — because per-file signatures cannot say where in a repository a file belongs (`allow_per_file=True` opts into them, and then every file must carry one, so an unsigned `pytorch_model.bin` cannot ride along beside a signed `model.safetensors`);
67
+ - requires a key you already trust, not merely the one embedded in the signature (`allow_embedded=True` opts out);
68
+ - also guards `PreTrainedModel.from_pretrained` for a **local path**, which downloads nothing and so never reaches the Hub hooks (`cover_local=False` opts out);
69
+ - rejects a modelsign 1.x signature of a single file, whose filename is not covered by the signature (`allow_unbound_names=True` opts out);
70
+ - accepts an OMS bundle on equal footing when you pass `oms_pubkey=` (or `MODELSIGN_OMS_PUBKEY`).
71
+
72
+ To check a path yourself:
73
+
74
+ ```python
75
+ from modelsign.guard import require_verified, LoadBlocked
76
+
77
+ try:
78
+ result = require_verified("./model.safetensors", pubkey="vendor.pem")
79
+ except LoadBlocked as e:
80
+ ...
81
+ ```
82
+
83
+ ## Sign and verify
84
+
85
+ ```bash
86
+ modelsign keygen # Ed25519 keypair
87
+ modelsign sign model.safetensors --name "My-Llama-8B-v1"
88
+ modelsign verify model.safetensors --pubkey public.pem
89
+ modelsign inspect model.safetensors.sig
90
+ ```
91
+
92
+ Signing a directory produces one signature over a manifest of every file, so an added or swapped file breaks verification. That is the form to prefer for a multi-file model.
93
+
94
+ A signature is checked against a key you supply or one already in your keyring. The key embedded in the signature proves the bytes are unchanged and nothing about who signed them, so it is **not** accepted by default:
95
+
96
+ ```bash
97
+ modelsign verify ./model --pubkey vendor.pem # identity + integrity
98
+ modelsign verify ./model --allow-embedded-key # integrity only, and says so
99
+ ```
100
+
101
+ A directory signature may be stored inside the directory it signs — the
102
+ conventional name is `modelsign.sig`, which travels with a published repo. It
103
+ is left out of its own manifest, the way OMS leaves out its bundle.
104
+
105
+ ### Signature format
106
+
107
+ New signatures are **modelsign 2.0**, which puts the file's name inside the
108
+ signed message. In 1.x the name lived in an unauthenticated `file` field, so
109
+ two separately-signed files could be presented under each other's names by
110
+ editing that field. A directory signature does not need this — its manifest
111
+ hash already covers every relative path, which is also why a snapshot
112
+ verifies under whatever directory name it lands in.
113
+
114
+ A single-file signature authenticates the file's **basename**, not the path it
115
+ sits at — a publisher signing one file cannot know where a consumer will place
116
+ it. So prefer a directory signature for a multi-file model: the guard refuses
117
+ a snapshot whose per-file signatures share a basename across directories,
118
+ because those files would be interchangeable.
119
+
120
+ `VerifyResult.name_bound` says whether the model's own name is signed, and
121
+ `paths_bound` whether its internal layout is — a single file has the first, a
122
+ directory the second, and they are not the same property.
123
+ Rejecting 1.x is the **default** in `verify_model`, in `modelsign verify` and
124
+ in the guard; `require_name_binding=False` or `--allow-unbound-name` opts out,
125
+ for old signatures you cannot re-sign.
126
+
127
+ ## Python API
128
+
129
+ ```python
130
+ from modelsign import sign_model, verify_model
131
+
132
+ sign_model("model.safetensors", name="My-Llama-8B-v1", key="private.pem")
133
+
134
+ result = verify_model("model.safetensors", pubkey="public.pem")
135
+ result.verified # the signature is valid and the bytes are unchanged
136
+ result.trusted # ...and the signer was checked against a key you already had
137
+ result.identity # the signed identity card
138
+ ```
139
+
140
+ `verify_model` returns a falsy `VerifyResult` for a failed check and raises `VerifyError` only when the check cannot be attempted. Nothing prints; nothing calls `sys.exit`.
141
+
142
+ ## Lineage
143
+
144
+ A signed card can record `parent_signature`, the digest of the signature of
145
+ the model this one came from. That turns a pile of signatures into a chain,
146
+ and every link is checked rather than taken on trust:
147
+
148
+ ```bash
149
+ modelsign sign sft.safetensors --name "Llama-3.1-8B-SFT" --parent base.safetensors.sig
150
+ modelsign lineage dpo.safetensors --search ./registry --pubkey vendor.pem --require-complete
151
+ ```
152
+
153
+ ```
154
+ LINEAGE VERIFIED dpo.safetensors (3 link(s))
155
+ [ok ] Llama-3.1-8B-DPO
156
+ key ed25519:31d87c0f (bytes + signature)
157
+ [ok ] Llama-3.1-8B-SFT
158
+ key ed25519:31d87c0f (signature only)
159
+ [ok ] Llama-3.1-8B-Base
160
+ key ed25519:31d87c0f (signature only)
161
+ ```
162
+
163
+ An ancestor's weights are usually long gone, and that is fine — a signature
164
+ records the hash it was made over, so the signature verifies from the `.sig`
165
+ alone. Be precise about what that proves: the ancestor's card and digest are
166
+ authentic and unmodified, **not** that any file on this machine is that
167
+ ancestor. The digest is taken over canonical JSON, so reformatting a `.sig`
168
+ cannot break a chain pointing at it.
169
+
170
+ Without `--require-complete`, a chain that runs out of findable ancestors is
171
+ reported as verified but incomplete rather than failed.
172
+
173
+ ## Approvals
174
+
175
+ A signature says who built a model. Deployment usually needs a second claim —
176
+ that someone signed off on releasing it:
177
+
178
+ ```bash
179
+ modelsign approve ./model --key rm.pem --role release-manager --approver "J. Kerr"
180
+ modelsign verify ./model --pubkey vendor.pem \
181
+ --require-approval release-manager --approver-key rm_pub.pem
182
+ ```
183
+
184
+ ```
185
+ VERIFIED model.safetensors
186
+ Name: Llama-8B-rc1
187
+ Key: ed25519:743322af (TRUSTED (--pubkey))
188
+ Approved: release-manager — J. Kerr (2026-10-31T14:51:25Z)
189
+ ```
190
+
191
+ An approval is a separate signature over the digest of the model's signature,
192
+ its own fields, its position in the sequence, and **the digest of the approval
193
+ before it**. That chain is what makes tampering visible:
194
+
195
+ | | detected |
196
+ |---|---|
197
+ | Editing any approval | yes — that approval stops verifying |
198
+ | Removing or reordering one that has another after it | yes — every later approval committed to its exact bytes and to its own index |
199
+ | Removing a **trailing** approval, or all of them | **no** |
200
+
201
+ The last row is irreducible from inside the file: nothing in a `.sig` counts
202
+ how many approvals belong there, and the model's own signature cannot help
203
+ because approvals are appended after it was made. The answer is policy at
204
+ verification time — `--require-approval`, `--min-approvals` — or an external
205
+ anchor such as a transparency log, not a cleverer signature.
206
+
207
+ Identity is compared on **whole key bytes** throughout — never the
208
+ 8-character display fingerprint (32 bits is cheap to collide), and never the
209
+ base64 string, since base64 leaves unused bits and one key has four encodings
210
+ that all decode alike. A non-canonical encoding is refused rather than counted.
211
+
212
+ Every role passed to `--require-approval` must be satisfied, not merely one of
213
+ them, and `--min-approvals` counts **distinct** approvers: one person in two
214
+ roles is one person. Pinning specific approvers (`require_approval(keys=...)`)
215
+ takes public key PEM paths or key bytes, not fingerprints.
216
+
217
+ ## OpenSSF Model Signing interoperability
218
+
219
+ ```bash
220
+ modelsign oms keygen # ECDSA P-256 (OMS rejects Ed25519)
221
+ modelsign oms export ./model --key oms_private.pem --out ./model/model.sig
222
+ modelsign oms verify ./model --pubkey oms_public.pem
223
+ ```
224
+
225
+ Bundles written by `modelsign oms export` verify with the `model-signing` CLI, and bundles written by `model-signing sign key` verify here. Both directions are covered by tests, including golden digests captured from `model-signing`'s own output.
226
+
227
+ `modelsign`'s OMS verification is stricter in one respect: a file on disk that is **not** in the signed manifest fails the check, rather than being ignored.
228
+
229
+ A directory signature covers every file in the directory, so writing an OMS
230
+ bundle into a directory you have already signed with `modelsign sign` will
231
+ invalidate that signature. Either keep the bundle outside the directory, or
232
+ sign the directory after writing it.
233
+
234
+ ## Identity cards
235
+
236
+ A signature covers an identity card as well as the bytes, so changing a claim invalidates the signature:
237
+
238
+ ```json
239
+ {
240
+ "name": "Llama-3.1-8B-Chat-QJ",
241
+ "base_model": "meta-llama/Llama-3.1-8B-Instruct",
242
+ "architecture": "LlamaForCausalLM",
243
+ "creator": "ConstantQJ",
244
+ "license": "Llama 3.1 Community",
245
+ "intended_use": "Chat assistant",
246
+ "training": {"dataset": "custom-chat-v2", "epochs": 3, "hardware": "DGX Spark GB10"},
247
+ "eval_metrics": {"mmlu": 0.68, "humaneval": 0.53}
248
+ }
249
+ ```
250
+
251
+ ```bash
252
+ modelsign sign model.safetensors --identity card.json
253
+ ```
254
+
255
+ | Field | Required | Description |
256
+ |---|---|---|
257
+ | `name` | Yes | Model name |
258
+ | `architecture` | No | Model class (e.g. `LlamaForCausalLM`) |
259
+ | `base_model` | No | Parent model name or path |
260
+ | `parent_signature` | No | Hash of the parent's `.sig` (provenance chain) |
261
+ | `version` | No | Semantic version |
262
+ | `creator` | No | Person or organization |
263
+ | `license` | No | SPDX identifier or name |
264
+ | `intended_use` | No | What the model is for |
265
+ | `restrictions` | No | What it should not be used for |
266
+ | `training` | No | `{dataset, dataset_hash, epochs, hardware}` |
267
+ | `quantization` | No | Method (e.g. `GPTQ-4bit`) |
268
+ | `eval_metrics` | No | Benchmark results (`{mmlu: 0.68}`) |
269
+ | `extra` | No | Any additional metadata |
270
+
271
+ ## Use it in CI
272
+
273
+ Signing earns its keep where a build refuses to proceed. The bundled action
274
+ installs `modelsign` and fails the job on an unverified model:
275
+
276
+ ```yaml
277
+ - uses: QuantQJ/modelsign@v1
278
+ with:
279
+ model: ./model
280
+ pubkey: ./keys/vendor.pem
281
+ ```
282
+
283
+ For a repository signed with OpenSSF Model Signing:
284
+
285
+ ```yaml
286
+ - uses: QuantQJ/modelsign@v1
287
+ with:
288
+ model: ./model
289
+ oms-pubkey: ./keys/oms_public.pem
290
+ ```
291
+
292
+ If `modelsign` is already on `PATH` and no `version` is pinned, the action uses
293
+ it rather than installing another copy.
294
+
295
+ ## How it compares
296
+
297
+ OMS is the OpenSSF specification and the thing to standardize on. `modelsign` reads and writes it; the differences are in what else each one does.
298
+
299
+ | | modelsign | OpenSSF Model Signing |
300
+ |---|---|---|
301
+ | Format | own `.sig`, plus OMS bundles both ways | OMS sigstore bundle |
302
+ | Signing methods | Ed25519 key; ECDSA P-256 for OMS output | Sigstore (default), private key, certificate, PKCS #11 |
303
+ | Transparency log | no | optional — used by Sigstore signing, not by key signing |
304
+ | Works offline | yes | yes, with `sign key` |
305
+ | Signed payload | file manifest **and** an identity card (base model, license, eval metrics) | file manifest; model-card fields are listed as future work |
306
+ | Verification at model load | yes, via `guard.install()` | not provided |
307
+ | Kubernetes admission | no | yes, via the sigstore Model Validation Operator |
308
+ | CI identity | no | yes — GitHub Actions, GitLab CI, GCP, Buildkite workload identity |
309
+
310
+ Use OMS when you need keyless signing tied to a CI identity, a transparency log, or cluster admission control. Use `modelsign` when you need load-time enforcement, a signed identity card, or signing in a place that cannot reach Sigstore.
311
+
312
+ ## What it protects against
313
+
314
+ - Post-signing **tampering** with model weights
315
+ - **Substitution** of one model for another
316
+ - **Metadata swap** — changing an identity claim invalidates the signature
317
+ - **Smuggling** — an unsigned file added beside signed ones
318
+
319
+ ## What it does not cover
320
+
321
+ - Key compromise — your key, your responsibility
322
+ - Model safety, fairness, or legal compliance
323
+ - Revocation and historical archive validation; `signed_at` remains metadata. Optional RFC 3161 envelope timestamps are described below.
324
+ - Pickle and deserialization attacks inside a correctly signed file
325
+
326
+ ## License
327
+
328
+ Apache 2.0
329
+
330
+ ## RFC 3161 timestamps (v1.2.0)
331
+
332
+ Optional timestamps bind the model signature and current approval chain to a
333
+ trusted TSA time. See [the timestamp guide](docs/timestamps.md) for installation,
334
+ `--timestamp`, `--require-timestamp`, explicit CA trust and offline verification.
335
+ Install with `pip install "modelsign[timestamp]==1.2.0"` and OpenSSL 3. `signed_at` remains
336
+ self-reported; timestamps do not implement key revocation or prevent replay of
337
+ older valid releases. KMS signing is separate work.