vitnify 0.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.
- vitnify-0.1.0/LICENSE +202 -0
- vitnify-0.1.0/NOTICE +14 -0
- vitnify-0.1.0/PKG-INFO +99 -0
- vitnify-0.1.0/README.md +73 -0
- vitnify-0.1.0/pyproject.toml +42 -0
- vitnify-0.1.0/setup.cfg +4 -0
- vitnify-0.1.0/src/vitnify/__init__.py +0 -0
- vitnify-0.1.0/src/vitnify/_vendor/__init__.py +0 -0
- vitnify-0.1.0/src/vitnify/_vendor/pck/__init__.py +0 -0
- vitnify-0.1.0/src/vitnify/_vendor/pck/cas.py +181 -0
- vitnify-0.1.0/src/vitnify/capability.py +38 -0
- vitnify-0.1.0/src/vitnify/certificate.py +139 -0
- vitnify-0.1.0/src/vitnify/deterministic_llm.py +64 -0
- vitnify-0.1.0/src/vitnify/engine.py +46 -0
- vitnify-0.1.0/src/vitnify/events.py +95 -0
- vitnify-0.1.0/src/vitnify/langgraph_adapter.py +101 -0
- vitnify-0.1.0/src/vitnify/mcp_adapter.py +80 -0
- vitnify-0.1.0/src/vitnify/react.py +93 -0
- vitnify-0.1.0/src/vitnify/replayer.py +44 -0
- vitnify-0.1.0/src/vitnify/viewer.py +230 -0
- vitnify-0.1.0/src/vitnify.egg-info/PKG-INFO +99 -0
- vitnify-0.1.0/src/vitnify.egg-info/SOURCES.txt +31 -0
- vitnify-0.1.0/src/vitnify.egg-info/dependency_links.txt +1 -0
- vitnify-0.1.0/src/vitnify.egg-info/requires.txt +12 -0
- vitnify-0.1.0/src/vitnify.egg-info/top_level.txt +1 -0
- vitnify-0.1.0/tests/test_adapters.py +139 -0
- vitnify-0.1.0/tests/test_attack_matrix.py +208 -0
- vitnify-0.1.0/tests/test_capability.py +92 -0
- vitnify-0.1.0/tests/test_certificate.py +95 -0
- vitnify-0.1.0/tests/test_ed25519.py +61 -0
- vitnify-0.1.0/tests/test_events.py +80 -0
- vitnify-0.1.0/tests/test_l2_recompute.py +60 -0
- vitnify-0.1.0/tests/test_verification.py +107 -0
vitnify-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
vitnify-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
vitnify
|
|
2
|
+
Copyright 2026 vitnify
|
|
3
|
+
|
|
4
|
+
This product includes software developed by vitnify (https://vitnify.com).
|
|
5
|
+
|
|
6
|
+
Portions of this software (the "vitni-tensor" deterministic inference engine and
|
|
7
|
+
the vitnify SDK) are licensed under the Apache License, Version 2.0. See the
|
|
8
|
+
LICENSE file.
|
|
9
|
+
|
|
10
|
+
"vitnify" and "vitnify-verified", and the vitnify logo, are trademarks of vitnify.
|
|
11
|
+
The Apache-2.0 license does not grant rights to use these marks. See TRADEMARKS.md.
|
|
12
|
+
|
|
13
|
+
Third-party components used by vitni-tensor include libm (deterministic math) and
|
|
14
|
+
BLAKE3 (hashing), each distributed under its own license.
|
vitnify-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vitnify
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Execution receipts for AI agents: contain, deterministically reconstruct, and cryptographically certify a run.
|
|
5
|
+
Author: vitnify
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://vitnify.com
|
|
8
|
+
Keywords: ai-agents,security,execution-certificate,deterministic-inference,reproducibility,audit
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Security
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
License-File: NOTICE
|
|
16
|
+
Requires-Dist: blake3>=0.4
|
|
17
|
+
Requires-Dist: cryptography>=41
|
|
18
|
+
Provides-Extra: langgraph
|
|
19
|
+
Requires-Dist: langgraph; extra == "langgraph"
|
|
20
|
+
Requires-Dist: langchain-core; extra == "langgraph"
|
|
21
|
+
Provides-Extra: mcp
|
|
22
|
+
Requires-Dist: mcp; extra == "mcp"
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
<h1 align="center">Vitnify your agents</h1>
|
|
28
|
+
<p align="center"><strong>Logs tell you what your agent did. Vitnify proves it</strong> — a cryptographic,
|
|
29
|
+
independently-reconstructable record of what an agent computed and did.</p>
|
|
30
|
+
|
|
31
|
+
Contain what an agent may do, deterministically reconstruct the model behind every
|
|
32
|
+
decision, and seal the whole run into one **bit-for-bit receipt** anyone can verify
|
|
33
|
+
offline — long after it happened.
|
|
34
|
+
|
|
35
|
+
> **vitnify** *(v.)* — to turn an agent run into a receipt anyone can reproduce and verify, offline.
|
|
36
|
+
|
|
37
|
+
vitnify isn't detection. It gives you the primitives to prove exactly what an agent
|
|
38
|
+
did: a `vitnify-receipt v1` binds the model's computation, the granted capabilities,
|
|
39
|
+
every tool call and result, the entropy, and the order into a single ed25519-signed,
|
|
40
|
+
self-verifying object.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
pip install vitnify
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quickstart
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from vitnify.events import EventLog, Kind
|
|
52
|
+
from vitnify.engine import Engine, prompt_hash
|
|
53
|
+
from vitnify.certificate import issue_certificate, verify_certificate, gen_ed25519
|
|
54
|
+
|
|
55
|
+
eng = Engine("model.gguf", model_id="my-model") # deterministic backend
|
|
56
|
+
log = EventLog()
|
|
57
|
+
|
|
58
|
+
step = eng.run(prompt_tokens=[1, 2, 3], n_new=20) # a model step
|
|
59
|
+
log.append_llm_call(prompt_hash([1, 2, 3]), step["tokens"], seed=0,
|
|
60
|
+
model_digest=step["model_digest"]) # bind the model computation
|
|
61
|
+
log.append(Kind.TOOL_CALL, {"tool": "read_docs", "decision": "allow"})
|
|
62
|
+
log.append(Kind.TOOL_CALL, {"tool": "send_email", "decision": "deny"}) # ungranted → blocked
|
|
63
|
+
|
|
64
|
+
priv, pub = gen_ed25519()
|
|
65
|
+
cert, _ = issue_certificate("program_hash", ["read_docs"], log, priv=priv)
|
|
66
|
+
|
|
67
|
+
verify_certificate(cert, log) # level 1: offline integrity — no model, no secret
|
|
68
|
+
# level 2: re-run each step through the engine; every model_digest reproduces bit-for-bit
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
See [`vitnify-receipt-v1.md`](vitnify-receipt-v1.md) for the receipt format, and
|
|
72
|
+
`examples/demo_receipt_e2e.py` for the full loop.
|
|
73
|
+
|
|
74
|
+
## What you get
|
|
75
|
+
|
|
76
|
+
- **Capability containment** — ungranted tools are structurally unreachable.
|
|
77
|
+
- **Deterministic replay** — re-run any past run and get the identical result.
|
|
78
|
+
- **Bit-for-bit receipts** — the model's exact computation, bound and signed.
|
|
79
|
+
- **Offline verification** — anyone verifies with no model, network, or secret.
|
|
80
|
+
- **Drop-in** — wraps existing **LangGraph** and **MCP** agents (`pip install vitnify[langgraph]` / `[mcp]`).
|
|
81
|
+
|
|
82
|
+
The deterministic engine is [`vitni-tensor`](https://github.com/vitnify/vitni-tensor);
|
|
83
|
+
the `vitni-receipt` binary is the model backend (point `VITNI_RECEIPT_BIN` at it).
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
Apache-2.0. **"vitnify"** and **"vitnify-verified"** are trademarks — see
|
|
88
|
+
[TRADEMARKS.md](TRADEMARKS.md). A fork may use the code, but not the name or issue
|
|
89
|
+
vitnify-verified receipts.
|
|
90
|
+
|
|
91
|
+
## Part of Vitnify
|
|
92
|
+
|
|
93
|
+
This SDK is one of three open repos:
|
|
94
|
+
|
|
95
|
+
- **[vitni-tensor](https://github.com/vitnify/vitni-tensor)** — the deterministic,
|
|
96
|
+
`no_std` engine that produces the bit-identical model-computation digest this SDK binds.
|
|
97
|
+
- **[vitnify-receipt-spec](https://github.com/vitnify/vitnify-receipt-spec)** — the
|
|
98
|
+
canonical `vitnify-receipt v1` format the SDK implements.
|
|
99
|
+
- **[vitnify.com](https://vitnify.com)** — the project.
|
vitnify-0.1.0/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<h1 align="center">Vitnify your agents</h1>
|
|
2
|
+
<p align="center"><strong>Logs tell you what your agent did. Vitnify proves it</strong> — a cryptographic,
|
|
3
|
+
independently-reconstructable record of what an agent computed and did.</p>
|
|
4
|
+
|
|
5
|
+
Contain what an agent may do, deterministically reconstruct the model behind every
|
|
6
|
+
decision, and seal the whole run into one **bit-for-bit receipt** anyone can verify
|
|
7
|
+
offline — long after it happened.
|
|
8
|
+
|
|
9
|
+
> **vitnify** *(v.)* — to turn an agent run into a receipt anyone can reproduce and verify, offline.
|
|
10
|
+
|
|
11
|
+
vitnify isn't detection. It gives you the primitives to prove exactly what an agent
|
|
12
|
+
did: a `vitnify-receipt v1` binds the model's computation, the granted capabilities,
|
|
13
|
+
every tool call and result, the entropy, and the order into a single ed25519-signed,
|
|
14
|
+
self-verifying object.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
pip install vitnify
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from vitnify.events import EventLog, Kind
|
|
26
|
+
from vitnify.engine import Engine, prompt_hash
|
|
27
|
+
from vitnify.certificate import issue_certificate, verify_certificate, gen_ed25519
|
|
28
|
+
|
|
29
|
+
eng = Engine("model.gguf", model_id="my-model") # deterministic backend
|
|
30
|
+
log = EventLog()
|
|
31
|
+
|
|
32
|
+
step = eng.run(prompt_tokens=[1, 2, 3], n_new=20) # a model step
|
|
33
|
+
log.append_llm_call(prompt_hash([1, 2, 3]), step["tokens"], seed=0,
|
|
34
|
+
model_digest=step["model_digest"]) # bind the model computation
|
|
35
|
+
log.append(Kind.TOOL_CALL, {"tool": "read_docs", "decision": "allow"})
|
|
36
|
+
log.append(Kind.TOOL_CALL, {"tool": "send_email", "decision": "deny"}) # ungranted → blocked
|
|
37
|
+
|
|
38
|
+
priv, pub = gen_ed25519()
|
|
39
|
+
cert, _ = issue_certificate("program_hash", ["read_docs"], log, priv=priv)
|
|
40
|
+
|
|
41
|
+
verify_certificate(cert, log) # level 1: offline integrity — no model, no secret
|
|
42
|
+
# level 2: re-run each step through the engine; every model_digest reproduces bit-for-bit
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
See [`vitnify-receipt-v1.md`](vitnify-receipt-v1.md) for the receipt format, and
|
|
46
|
+
`examples/demo_receipt_e2e.py` for the full loop.
|
|
47
|
+
|
|
48
|
+
## What you get
|
|
49
|
+
|
|
50
|
+
- **Capability containment** — ungranted tools are structurally unreachable.
|
|
51
|
+
- **Deterministic replay** — re-run any past run and get the identical result.
|
|
52
|
+
- **Bit-for-bit receipts** — the model's exact computation, bound and signed.
|
|
53
|
+
- **Offline verification** — anyone verifies with no model, network, or secret.
|
|
54
|
+
- **Drop-in** — wraps existing **LangGraph** and **MCP** agents (`pip install vitnify[langgraph]` / `[mcp]`).
|
|
55
|
+
|
|
56
|
+
The deterministic engine is [`vitni-tensor`](https://github.com/vitnify/vitni-tensor);
|
|
57
|
+
the `vitni-receipt` binary is the model backend (point `VITNI_RECEIPT_BIN` at it).
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
Apache-2.0. **"vitnify"** and **"vitnify-verified"** are trademarks — see
|
|
62
|
+
[TRADEMARKS.md](TRADEMARKS.md). A fork may use the code, but not the name or issue
|
|
63
|
+
vitnify-verified receipts.
|
|
64
|
+
|
|
65
|
+
## Part of Vitnify
|
|
66
|
+
|
|
67
|
+
This SDK is one of three open repos:
|
|
68
|
+
|
|
69
|
+
- **[vitni-tensor](https://github.com/vitnify/vitni-tensor)** — the deterministic,
|
|
70
|
+
`no_std` engine that produces the bit-identical model-computation digest this SDK binds.
|
|
71
|
+
- **[vitnify-receipt-spec](https://github.com/vitnify/vitnify-receipt-spec)** — the
|
|
72
|
+
canonical `vitnify-receipt v1` format the SDK implements.
|
|
73
|
+
- **[vitnify.com](https://vitnify.com)** — the project.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vitnify"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Execution receipts for AI agents: contain, deterministically reconstruct, and cryptographically certify a run."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "Apache-2.0" }
|
|
12
|
+
authors = [{ name = "vitnify" }]
|
|
13
|
+
keywords = ["ai-agents", "security", "execution-certificate", "deterministic-inference", "reproducibility", "audit"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"License :: OSI Approved :: Apache Software License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Topic :: Security",
|
|
18
|
+
]
|
|
19
|
+
dependencies = ["blake3>=0.4", "cryptography>=41"]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
langgraph = ["langgraph", "langchain-core"]
|
|
23
|
+
mcp = ["mcp"]
|
|
24
|
+
dev = ["pytest>=7"]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://vitnify.com"
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.package-data]
|
|
33
|
+
"vitnify._vendor.pck" = ["*.py"]
|
|
34
|
+
|
|
35
|
+
[tool.pytest.ini_options]
|
|
36
|
+
testpaths = ["tests"]
|
|
37
|
+
pythonpath = ["src"]
|
|
38
|
+
addopts = "-ra"
|
|
39
|
+
markers = [
|
|
40
|
+
"l2: level-2 recomputation tests (need VITNI_GGUF + VITNI_RECEIPT_BIN)",
|
|
41
|
+
"adapter: framework adapter tests (need optional deps: langgraph/mcp)",
|
|
42
|
+
]
|
vitnify-0.1.0/setup.cfg
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""Content-addressed store + Merkle ledger — the provenance backbone of PCK.
|
|
2
|
+
|
|
3
|
+
Every source chunk is addressed by its cryptographic hash. A Merkle tree over those
|
|
4
|
+
hashes yields a single ``root`` that attests the whole corpus. Any single chunk can
|
|
5
|
+
then carry an *inclusion proof*: a short path of sibling hashes that recomputes the
|
|
6
|
+
root. The guarantees this buys, and why they matter for AI answers:
|
|
7
|
+
|
|
8
|
+
* **Tamper-evidence** — change one byte of one chunk and the root changes.
|
|
9
|
+
* **Independent verifiability** — anyone holding the root can check a chunk's proof
|
|
10
|
+
without trusting the party that produced it (no model, no server, no secret key).
|
|
11
|
+
* **Fabrication is uncredentialed** — a made-up "source" has no leaf in the tree, so
|
|
12
|
+
it cannot produce a valid proof. This is the cryptographic half of catching a
|
|
13
|
+
hallucination: a grounded claim points at a chunk with a valid proof; an invented
|
|
14
|
+
one cannot.
|
|
15
|
+
|
|
16
|
+
This mirrors the BLAKE3 + Merkle design of a native runtime's ``cas_store`` (whose real
|
|
17
|
+
Rust code is exercised in ``research/pck_provenance/``); here we keep a dependency-light
|
|
18
|
+
pure-Python implementation that uses ``blake3`` when available and falls back to
|
|
19
|
+
``hashlib.blake2b`` otherwise. The wire format of a proof is identical either way.
|
|
20
|
+
"""
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import hashlib
|
|
24
|
+
from dataclasses import dataclass, field
|
|
25
|
+
from typing import Optional
|
|
26
|
+
|
|
27
|
+
try: # BLAKE3 if the user has it (matches the substrate); else a stdlib fallback.
|
|
28
|
+
import blake3 as _blake3 # type: ignore
|
|
29
|
+
|
|
30
|
+
_HASH_NAME = "blake3"
|
|
31
|
+
|
|
32
|
+
def _digest(b: bytes) -> str:
|
|
33
|
+
return _blake3.blake3(b).hexdigest()
|
|
34
|
+
except Exception: # pragma: no cover - depends on environment
|
|
35
|
+
_HASH_NAME = "blake2b-256"
|
|
36
|
+
|
|
37
|
+
def _digest(b: bytes) -> str:
|
|
38
|
+
return hashlib.blake2b(b, digest_size=32).hexdigest()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
HASH_NAME = _HASH_NAME
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def hash_bytes(b: bytes) -> str:
|
|
45
|
+
"""Content address of raw bytes (hex)."""
|
|
46
|
+
return _digest(b)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def hash_text(s: str) -> str:
|
|
50
|
+
"""Content address of a text chunk (UTF-8, hex)."""
|
|
51
|
+
return _digest(s.encode("utf-8"))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _hash_pair(left: str, right: str) -> str:
|
|
55
|
+
"""Internal Merkle node = hash of the concatenated child hex digests."""
|
|
56
|
+
return _digest((left + right).encode("utf-8"))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# --- inclusion proof -------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
@dataclass(frozen=True)
|
|
62
|
+
class ProofStep:
|
|
63
|
+
"""One level of a Merkle inclusion path."""
|
|
64
|
+
|
|
65
|
+
sibling: str # hex digest of the sibling node
|
|
66
|
+
on_right: bool # True if the *current* node is the right child at this level
|
|
67
|
+
|
|
68
|
+
def to_json(self) -> dict:
|
|
69
|
+
return {"sibling": self.sibling, "on_right": self.on_right}
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
def from_json(d: dict) -> "ProofStep":
|
|
73
|
+
return ProofStep(sibling=d["sibling"], on_right=bool(d["on_right"]))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass(frozen=True)
|
|
77
|
+
class InclusionProof:
|
|
78
|
+
"""A self-contained proof that ``leaf`` is committed under ``root``.
|
|
79
|
+
|
|
80
|
+
Carries everything a third party needs to re-verify against a *published* root:
|
|
81
|
+
the leaf hash, the sibling path, and the index. No tree, server, or key required.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
leaf: str
|
|
85
|
+
index: int
|
|
86
|
+
path: list[ProofStep]
|
|
87
|
+
hash_name: str = HASH_NAME
|
|
88
|
+
|
|
89
|
+
def verify(self, root: str) -> bool:
|
|
90
|
+
return verify_proof(self.leaf, self.path, root)
|
|
91
|
+
|
|
92
|
+
def to_json(self) -> dict:
|
|
93
|
+
return {
|
|
94
|
+
"leaf": self.leaf,
|
|
95
|
+
"index": self.index,
|
|
96
|
+
"hash": self.hash_name,
|
|
97
|
+
"path": [s.to_json() for s in self.path],
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@staticmethod
|
|
101
|
+
def from_json(d: dict) -> "InclusionProof":
|
|
102
|
+
return InclusionProof(
|
|
103
|
+
leaf=d["leaf"],
|
|
104
|
+
index=int(d["index"]),
|
|
105
|
+
path=[ProofStep.from_json(s) for s in d["path"]],
|
|
106
|
+
hash_name=d.get("hash", HASH_NAME),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def verify_proof(leaf: str, path: list[ProofStep], root: str) -> bool:
|
|
111
|
+
"""Recompute the root from ``leaf`` and ``path``; True iff it equals ``root``."""
|
|
112
|
+
h = leaf
|
|
113
|
+
for step in path:
|
|
114
|
+
h = _hash_pair(step.sibling, h) if step.on_right else _hash_pair(h, step.sibling)
|
|
115
|
+
return h == root
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# --- the tree / store ------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
@dataclass
|
|
121
|
+
class MerkleCAS:
|
|
122
|
+
"""Content-addressed store with a Merkle commitment over its chunks.
|
|
123
|
+
|
|
124
|
+
Odd layers duplicate the final node (Bitcoin-style), so a proof always exists for
|
|
125
|
+
every leaf. Construction is deterministic in the chunk order.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
chunks: list[str]
|
|
129
|
+
leaves: list[str] = field(default_factory=list)
|
|
130
|
+
layers: list[list[str]] = field(default_factory=list)
|
|
131
|
+
_index_of_hash: dict[str, int] = field(default_factory=dict)
|
|
132
|
+
|
|
133
|
+
def __post_init__(self) -> None:
|
|
134
|
+
if not self.chunks:
|
|
135
|
+
raise ValueError("MerkleCAS requires at least one chunk")
|
|
136
|
+
self.leaves = [hash_text(c) for c in self.chunks]
|
|
137
|
+
# first occurrence wins if a chunk repeats
|
|
138
|
+
for i, h in enumerate(self.leaves):
|
|
139
|
+
self._index_of_hash.setdefault(h, i)
|
|
140
|
+
self.layers = self._build(self.leaves)
|
|
141
|
+
|
|
142
|
+
@staticmethod
|
|
143
|
+
def _build(leaves: list[str]) -> list[list[str]]:
|
|
144
|
+
layers = [leaves[:]]
|
|
145
|
+
while len(layers[-1]) > 1:
|
|
146
|
+
cur = layers[-1]
|
|
147
|
+
nxt = [
|
|
148
|
+
_hash_pair(cur[i], cur[i + 1] if i + 1 < len(cur) else cur[i])
|
|
149
|
+
for i in range(0, len(cur), 2)
|
|
150
|
+
]
|
|
151
|
+
layers.append(nxt)
|
|
152
|
+
return layers
|
|
153
|
+
|
|
154
|
+
@property
|
|
155
|
+
def root(self) -> str:
|
|
156
|
+
return self.layers[-1][0]
|
|
157
|
+
|
|
158
|
+
def index_of(self, chunk_or_hash: str) -> Optional[int]:
|
|
159
|
+
"""Index of a chunk by its raw text or by its hash; None if absent."""
|
|
160
|
+
if chunk_or_hash in self._index_of_hash:
|
|
161
|
+
return self._index_of_hash[chunk_or_hash]
|
|
162
|
+
return self._index_of_hash.get(hash_text(chunk_or_hash))
|
|
163
|
+
|
|
164
|
+
def contains(self, chunk_or_hash: str) -> bool:
|
|
165
|
+
return self.index_of(chunk_or_hash) is not None
|
|
166
|
+
|
|
167
|
+
def prove_index(self, idx: int) -> InclusionProof:
|
|
168
|
+
if not 0 <= idx < len(self.leaves):
|
|
169
|
+
raise IndexError(idx)
|
|
170
|
+
path: list[ProofStep] = []
|
|
171
|
+
i = idx
|
|
172
|
+
for layer in self.layers[:-1]:
|
|
173
|
+
sib = i ^ 1 if (i ^ 1) < len(layer) else i # duplicated node is its own sibling
|
|
174
|
+
path.append(ProofStep(sibling=layer[sib], on_right=bool(i & 1)))
|
|
175
|
+
i //= 2
|
|
176
|
+
return InclusionProof(leaf=self.leaves[idx], index=idx, path=path)
|
|
177
|
+
|
|
178
|
+
def prove(self, chunk_or_hash: str) -> Optional[InclusionProof]:
|
|
179
|
+
"""Inclusion proof for a chunk (by text or hash); None if not in the corpus."""
|
|
180
|
+
idx = self.index_of(chunk_or_hash)
|
|
181
|
+
return None if idx is None else self.prove_index(idx)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Userspace, kernel-free capability broker (adapted from the PoC).
|
|
2
|
+
Containment by construction: every side-effecting tool call routes through here,
|
|
3
|
+
and a tool the run wasn't granted is simply unreachable -- a jailbreak that reaches
|
|
4
|
+
an ungranted tool hits a wall, not a classifier. Each call is recorded to the event
|
|
5
|
+
log (with its result, so replay can re-inject it). No ML, no score, no bypass.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
import hashlib
|
|
9
|
+
from .events import EventLog, Kind
|
|
10
|
+
|
|
11
|
+
def _rh(x) -> str:
|
|
12
|
+
return hashlib.blake2b(repr(x).encode(), digest_size=16).hexdigest()
|
|
13
|
+
|
|
14
|
+
class Broker:
|
|
15
|
+
def __init__(self, capabilities, tools: dict, log: EventLog, replay=None):
|
|
16
|
+
self.caps = set(capabilities)
|
|
17
|
+
self.tools = tools
|
|
18
|
+
self.log = log
|
|
19
|
+
self.replay = replay # if set: list of recorded tool results to re-inject
|
|
20
|
+
|
|
21
|
+
def call(self, tool: str, *args):
|
|
22
|
+
allowed = tool in self.caps
|
|
23
|
+
if not allowed:
|
|
24
|
+
self.log.append(Kind.TOOL_CALL, {"tool": tool, "args": list(args), "decision": "DENY"})
|
|
25
|
+
return False, None
|
|
26
|
+
if self.replay is not None:
|
|
27
|
+
# external effect: DO NOT re-run the live tool; serve the recorded result
|
|
28
|
+
result = self.replay.pop(0)
|
|
29
|
+
else:
|
|
30
|
+
result = self.tools[tool](*args)
|
|
31
|
+
self.log.append(Kind.TOOL_CALL, {"tool": tool, "args": list(args),
|
|
32
|
+
"decision": "ALLOW", "result": result, "result_hash": _rh(result)})
|
|
33
|
+
return True, result
|
|
34
|
+
|
|
35
|
+
def recorded_tool_results(log: EventLog):
|
|
36
|
+
"""Extract the ordered list of ALLOW tool results, to feed a replay Broker."""
|
|
37
|
+
return [e.payload["result"] for e in log.events
|
|
38
|
+
if e.kind == Kind.TOOL_CALL.value and e.payload.get("decision") == "ALLOW"]
|