voltry-evidence-schema 1.0.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.
- voltry_evidence_schema-1.0.0/.gitignore +50 -0
- voltry_evidence_schema-1.0.0/CHANGELOG.md +19 -0
- voltry_evidence_schema-1.0.0/LICENSE +201 -0
- voltry_evidence_schema-1.0.0/PKG-INFO +76 -0
- voltry_evidence_schema-1.0.0/README.md +58 -0
- voltry_evidence_schema-1.0.0/evidence_schema/__init__.py +107 -0
- voltry_evidence_schema-1.0.0/evidence_schema/canonicalize.py +60 -0
- voltry_evidence_schema-1.0.0/evidence_schema/demo.py +76 -0
- voltry_evidence_schema-1.0.0/evidence_schema/enums.py +83 -0
- voltry_evidence_schema-1.0.0/evidence_schema/jsonschema.py +59 -0
- voltry_evidence_schema-1.0.0/evidence_schema/models.py +565 -0
- voltry_evidence_schema-1.0.0/evidence_schema/py.typed +0 -0
- voltry_evidence_schema-1.0.0/evidence_schema/samples.py +143 -0
- voltry_evidence_schema-1.0.0/evidence_schema/sign.py +128 -0
- voltry_evidence_schema-1.0.0/evidence_schema/types.py +57 -0
- voltry_evidence_schema-1.0.0/evidence_schema/version.py +39 -0
- voltry_evidence_schema-1.0.0/pyproject.toml +62 -0
- voltry_evidence_schema-1.0.0/schema/evidence_bundle.schema.json +1698 -0
- voltry_evidence_schema-1.0.0/tests/conftest.py +25 -0
- voltry_evidence_schema-1.0.0/tests/test_canonical.py +212 -0
- voltry_evidence_schema-1.0.0/tests/test_demo.py +22 -0
- voltry_evidence_schema-1.0.0/tests/test_jsonschema.py +75 -0
- voltry_evidence_schema-1.0.0/tests/test_models.py +124 -0
- voltry_evidence_schema-1.0.0/tests/test_schema_artifact.py +27 -0
- voltry_evidence_schema-1.0.0/tests/test_sign_verify.py +117 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# --- OS / editor ---
|
|
2
|
+
.DS_Store
|
|
3
|
+
*.swp
|
|
4
|
+
.idea/
|
|
5
|
+
.vscode/
|
|
6
|
+
|
|
7
|
+
# --- Python ---
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.eggs/
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.ruff_cache/
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
.coverage.*
|
|
17
|
+
coverage.xml
|
|
18
|
+
htmlcov/
|
|
19
|
+
.venv/
|
|
20
|
+
venv/
|
|
21
|
+
dist/
|
|
22
|
+
build/
|
|
23
|
+
|
|
24
|
+
# --- Node / TS ---
|
|
25
|
+
node_modules/
|
|
26
|
+
.next/
|
|
27
|
+
.turbo/
|
|
28
|
+
*.tsbuildinfo
|
|
29
|
+
out/
|
|
30
|
+
|
|
31
|
+
# --- Generated token outputs are committed? No — regenerated in CI ---
|
|
32
|
+
packages/tokens/dist/
|
|
33
|
+
apps/web/.next/
|
|
34
|
+
|
|
35
|
+
# --- Local secrets (never committed; enforced by hooks) ---
|
|
36
|
+
.env
|
|
37
|
+
.env.*
|
|
38
|
+
*.pem
|
|
39
|
+
*.key
|
|
40
|
+
|
|
41
|
+
# --- SBOM / scan artifacts (regenerated in CI) ---
|
|
42
|
+
sbom*.json
|
|
43
|
+
sbom*.xml
|
|
44
|
+
trivy-results.*
|
|
45
|
+
|
|
46
|
+
# Next.js generated
|
|
47
|
+
next-env.d.ts
|
|
48
|
+
|
|
49
|
+
# hypothesis example database
|
|
50
|
+
.hypothesis/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `voltry-evidence-schema` are documented here. The
|
|
4
|
+
format follows Keep a Changelog; versioning is semantic, and the distribution
|
|
5
|
+
version is the schema version.
|
|
6
|
+
|
|
7
|
+
## [1.0.0] - 2026-07-02
|
|
8
|
+
|
|
9
|
+
First public release.
|
|
10
|
+
|
|
11
|
+
- Typed evidence bundle models (identity, measured, functional, raw reads,
|
|
12
|
+
environment, provenance, signature), captured wide.
|
|
13
|
+
- RFC 8785 (JCS) canonical serialization as the single path to signable bytes.
|
|
14
|
+
- ECDSA P-384 / SHA-384 sign and verify over canonical bytes.
|
|
15
|
+
- Generated JSON Schema for cross-language consumers
|
|
16
|
+
(`evidence-schema-jsonschema`).
|
|
17
|
+
- Python 3.10 through 3.13. Typed (`py.typed`).
|
|
18
|
+
- Distribution renamed to `voltry-evidence-schema`; the import name remains
|
|
19
|
+
`evidence_schema`.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Voltry
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: voltry-evidence-schema
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Voltry evidence bundle — THE contract. Typed models, RFC 8785 canonical serialization, ECDSA P-384 sign/verify, generated JSON Schema.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: cryptography<50,>=44
|
|
15
|
+
Requires-Dist: pydantic<3,>=2.11
|
|
16
|
+
Requires-Dist: rfc8785<0.2,>=0.1.4
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# voltry-evidence-schema
|
|
20
|
+
|
|
21
|
+
The Voltry evidence bundle: the signed contract behind every Voltry Probe scan
|
|
22
|
+
and certificate.
|
|
23
|
+
|
|
24
|
+
Note the naming: the PyPI distribution is `voltry-evidence-schema`, the Python
|
|
25
|
+
package you import is `evidence_schema`.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install voltry-evidence-schema
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import evidence_schema
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## What it provides
|
|
36
|
+
|
|
37
|
+
- Typed pydantic v2 models (`EvidenceBundle` and its blocks). Measured facts
|
|
38
|
+
and modeled estimates are distinct types by construction; there is no single
|
|
39
|
+
score anywhere in the schema, and no price field exists.
|
|
40
|
+
- One canonical serializer: RFC 8785 (JCS) over the bundle minus its
|
|
41
|
+
signature. This is the only path to signable bytes.
|
|
42
|
+
- ECDSA P-384 (secp384r1) with SHA-384 sign and verify over those canonical
|
|
43
|
+
bytes.
|
|
44
|
+
- A generated JSON Schema for cross-language consumers.
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import json
|
|
50
|
+
from evidence_schema import EvidenceBundle, verify_bundle
|
|
51
|
+
|
|
52
|
+
bundle = EvidenceBundle.model_validate(json.load(open("bundle.json")))
|
|
53
|
+
print(verify_bundle(bundle)) # True only if the signature covers these exact bytes
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Command line:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Round-trip demo: build, canonicalize, sign, verify, tamper, verify fails
|
|
60
|
+
python -m evidence_schema.demo
|
|
61
|
+
|
|
62
|
+
# Emit the JSON Schema for non-Python consumers
|
|
63
|
+
evidence-schema-jsonschema -o evidence_bundle.schema.json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Stability
|
|
67
|
+
|
|
68
|
+
The schema is versioned semantically and the 1.x line is frozen wide: a bundle
|
|
69
|
+
captured today remains valid and replayable indefinitely. Additive fields are
|
|
70
|
+
minor versions; anything breaking is a major version with a migration path.
|
|
71
|
+
Canonical bytes are covered by golden-vector tests on every supported Python
|
|
72
|
+
version (3.10 through 3.13).
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
Apache-2.0.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# voltry-evidence-schema
|
|
2
|
+
|
|
3
|
+
The Voltry evidence bundle: the signed contract behind every Voltry Probe scan
|
|
4
|
+
and certificate.
|
|
5
|
+
|
|
6
|
+
Note the naming: the PyPI distribution is `voltry-evidence-schema`, the Python
|
|
7
|
+
package you import is `evidence_schema`.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install voltry-evidence-schema
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import evidence_schema
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What it provides
|
|
18
|
+
|
|
19
|
+
- Typed pydantic v2 models (`EvidenceBundle` and its blocks). Measured facts
|
|
20
|
+
and modeled estimates are distinct types by construction; there is no single
|
|
21
|
+
score anywhere in the schema, and no price field exists.
|
|
22
|
+
- One canonical serializer: RFC 8785 (JCS) over the bundle minus its
|
|
23
|
+
signature. This is the only path to signable bytes.
|
|
24
|
+
- ECDSA P-384 (secp384r1) with SHA-384 sign and verify over those canonical
|
|
25
|
+
bytes.
|
|
26
|
+
- A generated JSON Schema for cross-language consumers.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import json
|
|
32
|
+
from evidence_schema import EvidenceBundle, verify_bundle
|
|
33
|
+
|
|
34
|
+
bundle = EvidenceBundle.model_validate(json.load(open("bundle.json")))
|
|
35
|
+
print(verify_bundle(bundle)) # True only if the signature covers these exact bytes
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Command line:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Round-trip demo: build, canonicalize, sign, verify, tamper, verify fails
|
|
42
|
+
python -m evidence_schema.demo
|
|
43
|
+
|
|
44
|
+
# Emit the JSON Schema for non-Python consumers
|
|
45
|
+
evidence-schema-jsonschema -o evidence_bundle.schema.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Stability
|
|
49
|
+
|
|
50
|
+
The schema is versioned semantically and the 1.x line is frozen wide: a bundle
|
|
51
|
+
captured today remains valid and replayable indefinitely. Additive fields are
|
|
52
|
+
minor versions; anything breaking is a major version with a migration path.
|
|
53
|
+
Canonical bytes are covered by golden-vector tests on every supported Python
|
|
54
|
+
version (3.10 through 3.13).
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
Apache-2.0.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Voltry evidence-schema — the signed evidence-bundle contract.
|
|
2
|
+
|
|
3
|
+
Public API: the typed models, the single canonical serializer, and ECDSA P-384
|
|
4
|
+
sign/verify. Everything that produces or consumes a bundle imports from here and never
|
|
5
|
+
re-implements the contract.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from .canonicalize import CanonicalizationError, canonical_bytes, canonical_json, canonical_payload
|
|
11
|
+
from .enums import (
|
|
12
|
+
AttestationVerdict,
|
|
13
|
+
GateResult,
|
|
14
|
+
History,
|
|
15
|
+
IdentityScheme,
|
|
16
|
+
RunMode,
|
|
17
|
+
Tier,
|
|
18
|
+
)
|
|
19
|
+
from .jsonschema import generate_json_schema, json_schema_str
|
|
20
|
+
from .models import (
|
|
21
|
+
SPARE_ROW_CAP,
|
|
22
|
+
AgentInfo,
|
|
23
|
+
Attestation,
|
|
24
|
+
ClockPower,
|
|
25
|
+
DeterministicGates,
|
|
26
|
+
EccCounters,
|
|
27
|
+
EnvironmentBlock,
|
|
28
|
+
EvidenceBundle,
|
|
29
|
+
FunctionalBlock,
|
|
30
|
+
IdentityBlock,
|
|
31
|
+
MeasuredBlock,
|
|
32
|
+
NvLinkStatus,
|
|
33
|
+
PageRetirement,
|
|
34
|
+
PcieStatus,
|
|
35
|
+
ProvenanceBlock,
|
|
36
|
+
RawPayload,
|
|
37
|
+
RawReads,
|
|
38
|
+
Sanitization,
|
|
39
|
+
Signature,
|
|
40
|
+
SpareRows,
|
|
41
|
+
StabilitySignals,
|
|
42
|
+
Thermals,
|
|
43
|
+
XidEvent,
|
|
44
|
+
)
|
|
45
|
+
from .sign import (
|
|
46
|
+
generate_keypair,
|
|
47
|
+
load_public_key_spki_b64,
|
|
48
|
+
public_key_to_spki_b64,
|
|
49
|
+
sign_bundle,
|
|
50
|
+
verify_bundle,
|
|
51
|
+
)
|
|
52
|
+
from .version import CANONICALIZATION_SCHEME, SCHEMA_VERSION, SIGNATURE_ALGORITHM
|
|
53
|
+
|
|
54
|
+
__version__ = SCHEMA_VERSION
|
|
55
|
+
|
|
56
|
+
__all__ = [
|
|
57
|
+
# version
|
|
58
|
+
"SCHEMA_VERSION",
|
|
59
|
+
"CANONICALIZATION_SCHEME",
|
|
60
|
+
"SIGNATURE_ALGORITHM",
|
|
61
|
+
"__version__",
|
|
62
|
+
# enums
|
|
63
|
+
"Tier",
|
|
64
|
+
"History",
|
|
65
|
+
"IdentityScheme",
|
|
66
|
+
"RunMode",
|
|
67
|
+
"GateResult",
|
|
68
|
+
"AttestationVerdict",
|
|
69
|
+
# models
|
|
70
|
+
"SPARE_ROW_CAP",
|
|
71
|
+
"EvidenceBundle",
|
|
72
|
+
"AgentInfo",
|
|
73
|
+
"DeterministicGates",
|
|
74
|
+
"Attestation",
|
|
75
|
+
"IdentityBlock",
|
|
76
|
+
"EccCounters",
|
|
77
|
+
"XidEvent",
|
|
78
|
+
"PageRetirement",
|
|
79
|
+
"SpareRows",
|
|
80
|
+
"StabilitySignals",
|
|
81
|
+
"Thermals",
|
|
82
|
+
"ClockPower",
|
|
83
|
+
"NvLinkStatus",
|
|
84
|
+
"PcieStatus",
|
|
85
|
+
"MeasuredBlock",
|
|
86
|
+
"Sanitization",
|
|
87
|
+
"FunctionalBlock",
|
|
88
|
+
"RawPayload",
|
|
89
|
+
"RawReads",
|
|
90
|
+
"EnvironmentBlock",
|
|
91
|
+
"ProvenanceBlock",
|
|
92
|
+
"Signature",
|
|
93
|
+
# canonicalize
|
|
94
|
+
"canonical_bytes",
|
|
95
|
+
"canonical_json",
|
|
96
|
+
"canonical_payload",
|
|
97
|
+
"CanonicalizationError",
|
|
98
|
+
# sign
|
|
99
|
+
"generate_keypair",
|
|
100
|
+
"sign_bundle",
|
|
101
|
+
"verify_bundle",
|
|
102
|
+
"public_key_to_spki_b64",
|
|
103
|
+
"load_public_key_spki_b64",
|
|
104
|
+
# jsonschema
|
|
105
|
+
"generate_json_schema",
|
|
106
|
+
"json_schema_str",
|
|
107
|
+
]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""The single canonical serializer — the **only** path to signable bytes.
|
|
2
|
+
|
|
3
|
+
Canonicalization scheme: **RFC 8785 (JSON Canonicalization Scheme)** applied to the
|
|
4
|
+
bundle's JSON projection with the ``signature`` field excluded. RFC 8785 fixes object
|
|
5
|
+
key ordering (lexicographic on UTF-16 code units), number formatting (shortest
|
|
6
|
+
round-trip ECMAScript form), string escaping, and whitespace — so the same logical
|
|
7
|
+
bundle yields identical bytes across runs, processes, and languages.
|
|
8
|
+
|
|
9
|
+
Frozen rules (recorded in ``docs/adr/0002-evidence-schema-freeze.md``):
|
|
10
|
+
|
|
11
|
+
1. Serialize ``EvidenceBundle.model_dump(mode="json", exclude={"signature"})`` — i.e.
|
|
12
|
+
the full schema projection (defaults included, nulls included) minus the signature.
|
|
13
|
+
2. Feed that to ``rfc8785.dumps`` to obtain the canonical bytes.
|
|
14
|
+
3. Sign/verify operate on these bytes only. Bare ``json.dumps`` in the signing path is
|
|
15
|
+
forbidden (and blocked by a hook).
|
|
16
|
+
|
|
17
|
+
The signature is excluded because a signature cannot cover itself; everything else in
|
|
18
|
+
the bundle is covered, so tampering with any other field changes the canonical bytes
|
|
19
|
+
and breaks verification.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import rfc8785
|
|
25
|
+
|
|
26
|
+
from .models import EvidenceBundle
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class CanonicalizationError(ValueError):
|
|
30
|
+
"""Raised when a bundle cannot be canonicalized (e.g. an out-of-domain number)."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def canonical_payload(bundle: EvidenceBundle) -> dict:
|
|
34
|
+
"""The JSON projection that gets canonicalized: full schema minus the signature."""
|
|
35
|
+
return bundle.model_dump(mode="json", exclude={"signature"})
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def canonical_bytes(bundle: EvidenceBundle) -> bytes:
|
|
39
|
+
"""Return the canonical (RFC 8785) bytes of ``bundle`` — the signable representation.
|
|
40
|
+
|
|
41
|
+
Raises :class:`CanonicalizationError` if the bundle contains a value outside the
|
|
42
|
+
RFC 8785 domain (notably an integer above 2**53 that slipped past the typed
|
|
43
|
+
bounds — such data must be captured verbatim in ``raw_reads`` instead).
|
|
44
|
+
"""
|
|
45
|
+
payload = canonical_payload(bundle)
|
|
46
|
+
try:
|
|
47
|
+
return rfc8785.dumps(payload)
|
|
48
|
+
except Exception as exc: # noqa: BLE001 — re-raised as a typed, explicit error.
|
|
49
|
+
raise CanonicalizationError(
|
|
50
|
+
f"bundle is not canonicalizable under RFC 8785: {exc}. "
|
|
51
|
+
"Large/opaque values must be captured verbatim in raw_reads, not as JSON numbers."
|
|
52
|
+
) from exc
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def canonical_json(bundle: EvidenceBundle) -> str:
|
|
56
|
+
"""The canonical bytes decoded as a UTF-8 string (for debugging/inspection only)."""
|
|
57
|
+
return canonical_bytes(bundle).decode("utf-8")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
__all__ = ["CanonicalizationError", "canonical_payload", "canonical_bytes", "canonical_json"]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""``python -m evidence_schema.demo`` — round-trip the contract end to end.
|
|
2
|
+
|
|
3
|
+
Builds a sample bundle, canonicalizes it, signs it (ephemeral key), verifies it,
|
|
4
|
+
tampers a field, verifies that verification now fails, and prints the JSON Schema. This
|
|
5
|
+
is the Stage 1 "Show" deliverable; it uses only simulated data and an ephemeral key.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
from typing import TextIO
|
|
12
|
+
|
|
13
|
+
from .canonicalize import canonical_bytes
|
|
14
|
+
from .jsonschema import json_schema_str
|
|
15
|
+
from .samples import worked_example_a_bundle
|
|
16
|
+
from .sign import generate_keypair, sign_bundle, verify_bundle
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def run(out: TextIO = sys.stdout) -> bool:
|
|
20
|
+
"""Run the round-trip demo, writing a narrative to ``out``. Returns True on success."""
|
|
21
|
+
|
|
22
|
+
def line(msg: str = "") -> None:
|
|
23
|
+
out.write(msg + "\n")
|
|
24
|
+
|
|
25
|
+
bundle = worked_example_a_bundle()
|
|
26
|
+
sr = bundle.measured.spare_rows
|
|
27
|
+
exposure = "ASSESSED" if bundle.provenance.exposure_assessed else "NOT ASSESSED"
|
|
28
|
+
line("Voltry evidence-schema demo")
|
|
29
|
+
line("=" * 40)
|
|
30
|
+
line(f"schema_version : {bundle.schema_version}")
|
|
31
|
+
line(f"bundle_id : {bundle.bundle_id}")
|
|
32
|
+
line(f"device : {bundle.identity.device_part} ({bundle.provenance.tier})")
|
|
33
|
+
line(f"spare rows : {sr.remaining}/{sr.cap} remaining")
|
|
34
|
+
line(f"exposure : {exposure}")
|
|
35
|
+
|
|
36
|
+
payload = canonical_bytes(bundle)
|
|
37
|
+
line(f"\ncanonical bytes: {len(payload)} bytes")
|
|
38
|
+
line(f"canonical head : {payload[:72].decode('utf-8')}...")
|
|
39
|
+
|
|
40
|
+
private_key = generate_keypair()
|
|
41
|
+
signed = sign_bundle(bundle, private_key, signer="operator")
|
|
42
|
+
sig = signed.signature
|
|
43
|
+
line(f"\nsigned : algorithm={sig.algorithm} canon={sig.canonicalization}")
|
|
44
|
+
|
|
45
|
+
ok = verify_bundle(signed)
|
|
46
|
+
line(f"verify : {'PASS' if ok else 'FAIL'}")
|
|
47
|
+
if not ok: # pragma: no cover - defensive: only fires on a contract regression
|
|
48
|
+
line("UNEXPECTED: a freshly signed bundle failed to verify")
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
# Tamper: change a measured fact without re-signing → canonical bytes change → verify fails.
|
|
52
|
+
tampered = signed.model_copy(deep=True)
|
|
53
|
+
tampered.measured.spare_rows.remaining = 1
|
|
54
|
+
tampered_ok = verify_bundle(tampered)
|
|
55
|
+
line("tamper : set spare_rows.remaining 509 -> 1")
|
|
56
|
+
line(f"verify(tamper) : {'PASS (BUG!)' if tampered_ok else 'FAIL (correct — tamper detected)'}")
|
|
57
|
+
if tampered_ok: # pragma: no cover - defensive: only fires on a contract regression
|
|
58
|
+
line("UNEXPECTED: tampered bundle still verified")
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
line("\nJSON Schema")
|
|
62
|
+
line("-" * 40)
|
|
63
|
+
line(json_schema_str())
|
|
64
|
+
return True
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def main(argv: list[str] | None = None) -> int:
|
|
68
|
+
"""Entry point. Returns 0 on a successful round-trip, 1 otherwise."""
|
|
69
|
+
return 0 if run() else 1
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__": # pragma: no cover - script entry; main() is tested directly
|
|
73
|
+
raise SystemExit(main())
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
__all__ = ["run", "main"]
|