modelsign 1.0.4__tar.gz → 1.1.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.1.0/.github/FUNDING.yml +3 -0
- modelsign-1.1.0/.github/workflows/ci.yml +108 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/.gitignore +3 -0
- modelsign-1.1.0/PKG-INFO +326 -0
- modelsign-1.1.0/README.md +296 -0
- modelsign-1.1.0/action.yml +83 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/pyproject.toml +16 -1
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/__init__.py +15 -1
- modelsign-1.1.0/src/modelsign/api.py +446 -0
- modelsign-1.1.0/src/modelsign/approvals.py +418 -0
- modelsign-1.1.0/src/modelsign/cli.py +626 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/crypto/keys.py +23 -12
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/crypto/sign.py +31 -0
- modelsign-1.1.0/src/modelsign/formats/directory.py +70 -0
- modelsign-1.1.0/src/modelsign/guard.py +442 -0
- modelsign-1.1.0/src/modelsign/lineage.py +275 -0
- modelsign-1.1.0/src/modelsign/oms.py +487 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/sig.py +28 -2
- modelsign-1.1.0/src/modelsign.egg-info/PKG-INFO +326 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign.egg-info/SOURCES.txt +12 -0
- modelsign-1.1.0/tests/conftest.py +94 -0
- modelsign-1.1.0/tests/test_api.py +366 -0
- modelsign-1.1.0/tests/test_approvals.py +432 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_cli.py +141 -4
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_formats.py +33 -0
- modelsign-1.1.0/tests/test_guard.py +660 -0
- modelsign-1.1.0/tests/test_lineage.py +313 -0
- modelsign-1.1.0/tests/test_oms.py +328 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_sig.py +3 -3
- modelsign-1.0.4/.github/workflows/ci.yml +0 -51
- modelsign-1.0.4/PKG-INFO +0 -151
- modelsign-1.0.4/README.md +0 -121
- modelsign-1.0.4/src/modelsign/cli.py +0 -453
- modelsign-1.0.4/src/modelsign/formats/directory.py +0 -33
- modelsign-1.0.4/src/modelsign.egg-info/PKG-INFO +0 -151
- modelsign-1.0.4/tests/conftest.py +0 -45
- {modelsign-1.0.4 → modelsign-1.1.0}/CHANGELOG.md +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/LICENSE +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/setup.cfg +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/crypto/__init__.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/crypto/verify.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/formats/__init__.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/formats/single.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/identity/__init__.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/identity/canonical.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/identity/card.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/middleware/__init__.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign/middleware/response.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign.egg-info/dependency_links.txt +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign.egg-info/entry_points.txt +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign.egg-info/requires.txt +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/src/modelsign.egg-info/top_level.txt +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_canonical.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_card.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_integration.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_keys.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_middleware.py +0 -0
- {modelsign-1.0.4 → modelsign-1.1.0}/tests/test_sign_verify.py +0 -0
|
@@ -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]"
|
|
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
|
modelsign-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modelsign
|
|
3
|
+
Version: 1.1.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: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
28
|
+
Requires-Dist: mypy; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# modelsign
|
|
32
|
+
|
|
33
|
+
[](https://github.com/QuantQJ/modelsign/actions/workflows/ci.yml)
|
|
34
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
35
|
+
[](https://www.python.org/downloads/)
|
|
36
|
+
[](https://buymeacoffee.com/qjkerr1)
|
|
37
|
+
[](https://github.com/sponsors/QuantQJ)
|
|
38
|
+
|
|
39
|
+
**Unsigned model weights fail to load.**
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install modelsign
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Fail closed at load time
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import modelsign.guard as guard
|
|
53
|
+
|
|
54
|
+
guard.install(pubkey="~/keys/vendor.pem") # or set MODELSIGN_PUBKEY
|
|
55
|
+
|
|
56
|
+
from transformers import AutoModel
|
|
57
|
+
AutoModel.from_pretrained("acme/llama-8b") # LoadBlocked unless it verifies
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
One hook covers `transformers`, `sentence-transformers`, `diffusers` and vLLM, because they all download through `huggingface_hub`. The guard:
|
|
61
|
+
|
|
62
|
+
- fetches `MODEL.sig` from the same repo as the weights rather than hoping it is already on disk;
|
|
63
|
+
- refuses a download with **no** signature (`allow_unsigned=True` if you must);
|
|
64
|
+
- 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`);
|
|
65
|
+
- requires a key you already trust, not merely the one embedded in the signature (`allow_embedded=True` opts out);
|
|
66
|
+
- also guards `PreTrainedModel.from_pretrained` for a **local path**, which downloads nothing and so never reaches the Hub hooks (`cover_local=False` opts out);
|
|
67
|
+
- rejects a modelsign 1.x signature of a single file, whose filename is not covered by the signature (`allow_unbound_names=True` opts out);
|
|
68
|
+
- accepts an OMS bundle on equal footing when you pass `oms_pubkey=` (or `MODELSIGN_OMS_PUBKEY`).
|
|
69
|
+
|
|
70
|
+
To check a path yourself:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from modelsign.guard import require_verified, LoadBlocked
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
result = require_verified("./model.safetensors", pubkey="vendor.pem")
|
|
77
|
+
except LoadBlocked as e:
|
|
78
|
+
...
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Sign and verify
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
modelsign keygen # Ed25519 keypair
|
|
85
|
+
modelsign sign model.safetensors --name "My-Llama-8B-v1"
|
|
86
|
+
modelsign verify model.safetensors --pubkey public.pem
|
|
87
|
+
modelsign inspect model.safetensors.sig
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
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.
|
|
91
|
+
|
|
92
|
+
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:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
modelsign verify ./model --pubkey vendor.pem # identity + integrity
|
|
96
|
+
modelsign verify ./model --allow-embedded-key # integrity only, and says so
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
A directory signature may be stored inside the directory it signs — the
|
|
100
|
+
conventional name is `modelsign.sig`, which travels with a published repo. It
|
|
101
|
+
is left out of its own manifest, the way OMS leaves out its bundle.
|
|
102
|
+
|
|
103
|
+
### Signature format
|
|
104
|
+
|
|
105
|
+
New signatures are **modelsign 2.0**, which puts the file's name inside the
|
|
106
|
+
signed message. In 1.x the name lived in an unauthenticated `file` field, so
|
|
107
|
+
two separately-signed files could be presented under each other's names by
|
|
108
|
+
editing that field. A directory signature does not need this — its manifest
|
|
109
|
+
hash already covers every relative path, which is also why a snapshot
|
|
110
|
+
verifies under whatever directory name it lands in.
|
|
111
|
+
|
|
112
|
+
A single-file signature authenticates the file's **basename**, not the path it
|
|
113
|
+
sits at — a publisher signing one file cannot know where a consumer will place
|
|
114
|
+
it. So prefer a directory signature for a multi-file model: the guard refuses
|
|
115
|
+
a snapshot whose per-file signatures share a basename across directories,
|
|
116
|
+
because those files would be interchangeable.
|
|
117
|
+
|
|
118
|
+
`VerifyResult.name_bound` says whether the model's own name is signed, and
|
|
119
|
+
`paths_bound` whether its internal layout is — a single file has the first, a
|
|
120
|
+
directory the second, and they are not the same property.
|
|
121
|
+
Rejecting 1.x is the **default** in `verify_model`, in `modelsign verify` and
|
|
122
|
+
in the guard; `require_name_binding=False` or `--allow-unbound-name` opts out,
|
|
123
|
+
for old signatures you cannot re-sign.
|
|
124
|
+
|
|
125
|
+
## Python API
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from modelsign import sign_model, verify_model
|
|
129
|
+
|
|
130
|
+
sign_model("model.safetensors", name="My-Llama-8B-v1", key="private.pem")
|
|
131
|
+
|
|
132
|
+
result = verify_model("model.safetensors", pubkey="public.pem")
|
|
133
|
+
result.verified # the signature is valid and the bytes are unchanged
|
|
134
|
+
result.trusted # ...and the signer was checked against a key you already had
|
|
135
|
+
result.identity # the signed identity card
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`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`.
|
|
139
|
+
|
|
140
|
+
## Lineage
|
|
141
|
+
|
|
142
|
+
A signed card can record `parent_signature`, the digest of the signature of
|
|
143
|
+
the model this one came from. That turns a pile of signatures into a chain,
|
|
144
|
+
and every link is checked rather than taken on trust:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
modelsign sign sft.safetensors --name "Llama-3.1-8B-SFT" --parent base.safetensors.sig
|
|
148
|
+
modelsign lineage dpo.safetensors --search ./registry --pubkey vendor.pem --require-complete
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
LINEAGE VERIFIED dpo.safetensors (3 link(s))
|
|
153
|
+
[ok ] Llama-3.1-8B-DPO
|
|
154
|
+
key ed25519:31d87c0f (bytes + signature)
|
|
155
|
+
[ok ] Llama-3.1-8B-SFT
|
|
156
|
+
key ed25519:31d87c0f (signature only)
|
|
157
|
+
[ok ] Llama-3.1-8B-Base
|
|
158
|
+
key ed25519:31d87c0f (signature only)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
An ancestor's weights are usually long gone, and that is fine — a signature
|
|
162
|
+
records the hash it was made over, so the signature verifies from the `.sig`
|
|
163
|
+
alone. Be precise about what that proves: the ancestor's card and digest are
|
|
164
|
+
authentic and unmodified, **not** that any file on this machine is that
|
|
165
|
+
ancestor. The digest is taken over canonical JSON, so reformatting a `.sig`
|
|
166
|
+
cannot break a chain pointing at it.
|
|
167
|
+
|
|
168
|
+
Without `--require-complete`, a chain that runs out of findable ancestors is
|
|
169
|
+
reported as verified but incomplete rather than failed.
|
|
170
|
+
|
|
171
|
+
## Approvals
|
|
172
|
+
|
|
173
|
+
A signature says who built a model. Deployment usually needs a second claim —
|
|
174
|
+
that someone signed off on releasing it:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
modelsign approve ./model --key rm.pem --role release-manager --approver "J. Kerr"
|
|
178
|
+
modelsign verify ./model --pubkey vendor.pem \
|
|
179
|
+
--require-approval release-manager --approver-key rm_pub.pem
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
VERIFIED model.safetensors
|
|
184
|
+
Name: Llama-8B-rc1
|
|
185
|
+
Key: ed25519:743322af (TRUSTED (--pubkey))
|
|
186
|
+
Approved: release-manager — J. Kerr (2026-10-31T14:51:25Z)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
An approval is a separate signature over the digest of the model's signature,
|
|
190
|
+
its own fields, its position in the sequence, and **the digest of the approval
|
|
191
|
+
before it**. That chain is what makes tampering visible:
|
|
192
|
+
|
|
193
|
+
| | detected |
|
|
194
|
+
|---|---|
|
|
195
|
+
| Editing any approval | yes — that approval stops verifying |
|
|
196
|
+
| Removing or reordering one that has another after it | yes — every later approval committed to its exact bytes and to its own index |
|
|
197
|
+
| Removing a **trailing** approval, or all of them | **no** |
|
|
198
|
+
|
|
199
|
+
The last row is irreducible from inside the file: nothing in a `.sig` counts
|
|
200
|
+
how many approvals belong there, and the model's own signature cannot help
|
|
201
|
+
because approvals are appended after it was made. The answer is policy at
|
|
202
|
+
verification time — `--require-approval`, `--min-approvals` — or an external
|
|
203
|
+
anchor such as a transparency log, not a cleverer signature.
|
|
204
|
+
|
|
205
|
+
Identity is compared on **whole key bytes** throughout — never the
|
|
206
|
+
8-character display fingerprint (32 bits is cheap to collide), and never the
|
|
207
|
+
base64 string, since base64 leaves unused bits and one key has four encodings
|
|
208
|
+
that all decode alike. A non-canonical encoding is refused rather than counted.
|
|
209
|
+
|
|
210
|
+
Every role passed to `--require-approval` must be satisfied, not merely one of
|
|
211
|
+
them, and `--min-approvals` counts **distinct** approvers: one person in two
|
|
212
|
+
roles is one person. Pinning specific approvers (`require_approval(keys=...)`)
|
|
213
|
+
takes public key PEM paths or key bytes, not fingerprints.
|
|
214
|
+
|
|
215
|
+
## OpenSSF Model Signing interoperability
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
modelsign oms keygen # ECDSA P-256 (OMS rejects Ed25519)
|
|
219
|
+
modelsign oms export ./model --key oms_private.pem --out ./model/model.sig
|
|
220
|
+
modelsign oms verify ./model --pubkey oms_public.pem
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
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.
|
|
224
|
+
|
|
225
|
+
`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.
|
|
226
|
+
|
|
227
|
+
A directory signature covers every file in the directory, so writing an OMS
|
|
228
|
+
bundle into a directory you have already signed with `modelsign sign` will
|
|
229
|
+
invalidate that signature. Either keep the bundle outside the directory, or
|
|
230
|
+
sign the directory after writing it.
|
|
231
|
+
|
|
232
|
+
## Identity cards
|
|
233
|
+
|
|
234
|
+
A signature covers an identity card as well as the bytes, so changing a claim invalidates the signature:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"name": "Llama-3.1-8B-Chat-QJ",
|
|
239
|
+
"base_model": "meta-llama/Llama-3.1-8B-Instruct",
|
|
240
|
+
"architecture": "LlamaForCausalLM",
|
|
241
|
+
"creator": "ConstantQJ",
|
|
242
|
+
"license": "Llama 3.1 Community",
|
|
243
|
+
"intended_use": "Chat assistant",
|
|
244
|
+
"training": {"dataset": "custom-chat-v2", "epochs": 3, "hardware": "DGX Spark GB10"},
|
|
245
|
+
"eval_metrics": {"mmlu": 0.68, "humaneval": 0.53}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
modelsign sign model.safetensors --identity card.json
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
| Field | Required | Description |
|
|
254
|
+
|---|---|---|
|
|
255
|
+
| `name` | Yes | Model name |
|
|
256
|
+
| `architecture` | No | Model class (e.g. `LlamaForCausalLM`) |
|
|
257
|
+
| `base_model` | No | Parent model name or path |
|
|
258
|
+
| `parent_signature` | No | Hash of the parent's `.sig` (provenance chain) |
|
|
259
|
+
| `version` | No | Semantic version |
|
|
260
|
+
| `creator` | No | Person or organization |
|
|
261
|
+
| `license` | No | SPDX identifier or name |
|
|
262
|
+
| `intended_use` | No | What the model is for |
|
|
263
|
+
| `restrictions` | No | What it should not be used for |
|
|
264
|
+
| `training` | No | `{dataset, dataset_hash, epochs, hardware}` |
|
|
265
|
+
| `quantization` | No | Method (e.g. `GPTQ-4bit`) |
|
|
266
|
+
| `eval_metrics` | No | Benchmark results (`{mmlu: 0.68}`) |
|
|
267
|
+
| `extra` | No | Any additional metadata |
|
|
268
|
+
|
|
269
|
+
## Use it in CI
|
|
270
|
+
|
|
271
|
+
Signing earns its keep where a build refuses to proceed. The bundled action
|
|
272
|
+
installs `modelsign` and fails the job on an unverified model:
|
|
273
|
+
|
|
274
|
+
```yaml
|
|
275
|
+
- uses: QuantQJ/modelsign@v1
|
|
276
|
+
with:
|
|
277
|
+
model: ./model
|
|
278
|
+
pubkey: ./keys/vendor.pem
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
For a repository signed with OpenSSF Model Signing:
|
|
282
|
+
|
|
283
|
+
```yaml
|
|
284
|
+
- uses: QuantQJ/modelsign@v1
|
|
285
|
+
with:
|
|
286
|
+
model: ./model
|
|
287
|
+
oms-pubkey: ./keys/oms_public.pem
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
If `modelsign` is already on `PATH` and no `version` is pinned, the action uses
|
|
291
|
+
it rather than installing another copy.
|
|
292
|
+
|
|
293
|
+
## How it compares
|
|
294
|
+
|
|
295
|
+
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.
|
|
296
|
+
|
|
297
|
+
| | modelsign | OpenSSF Model Signing |
|
|
298
|
+
|---|---|---|
|
|
299
|
+
| Format | own `.sig`, plus OMS bundles both ways | OMS sigstore bundle |
|
|
300
|
+
| Signing methods | Ed25519 key; ECDSA P-256 for OMS output | Sigstore (default), private key, certificate, PKCS #11 |
|
|
301
|
+
| Transparency log | no | optional — used by Sigstore signing, not by key signing |
|
|
302
|
+
| Works offline | yes | yes, with `sign key` |
|
|
303
|
+
| Signed payload | file manifest **and** an identity card (base model, license, eval metrics) | file manifest; model-card fields are listed as future work |
|
|
304
|
+
| Verification at model load | yes, via `guard.install()` | not provided |
|
|
305
|
+
| Kubernetes admission | no | yes, via the sigstore Model Validation Operator |
|
|
306
|
+
| CI identity | no | yes — GitHub Actions, GitLab CI, GCP, Buildkite workload identity |
|
|
307
|
+
|
|
308
|
+
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.
|
|
309
|
+
|
|
310
|
+
## What it protects against
|
|
311
|
+
|
|
312
|
+
- Post-signing **tampering** with model weights
|
|
313
|
+
- **Substitution** of one model for another
|
|
314
|
+
- **Metadata swap** — changing an identity claim invalidates the signature
|
|
315
|
+
- **Smuggling** — an unsigned file added beside signed ones
|
|
316
|
+
|
|
317
|
+
## What it does not cover
|
|
318
|
+
|
|
319
|
+
- Key compromise — your key, your responsibility
|
|
320
|
+
- Model safety, fairness, or legal compliance
|
|
321
|
+
- Cryptographic timestamping; `signed_at` is metadata, not proof (no RFC 3161 timestamp)
|
|
322
|
+
- Pickle and deserialization attacks inside a correctly signed file
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
Apache 2.0
|