llm-sign 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.
Files changed (52) hide show
  1. llm_sign-0.1.0/LICENSE +202 -0
  2. llm_sign-0.1.0/PKG-INFO +190 -0
  3. llm_sign-0.1.0/README.md +159 -0
  4. llm_sign-0.1.0/pyproject.toml +61 -0
  5. llm_sign-0.1.0/setup.cfg +4 -0
  6. llm_sign-0.1.0/src/llm_sign/__init__.py +73 -0
  7. llm_sign-0.1.0/src/llm_sign/_b64.py +3 -0
  8. llm_sign-0.1.0/src/llm_sign/blocks.py +3 -0
  9. llm_sign-0.1.0/src/llm_sign/cli.py +102 -0
  10. llm_sign-0.1.0/src/llm_sign/client/__init__.py +466 -0
  11. llm_sign-0.1.0/src/llm_sign/core/__init__.py +39 -0
  12. llm_sign-0.1.0/src/llm_sign/core/base64.py +14 -0
  13. llm_sign-0.1.0/src/llm_sign/core/blocks.py +389 -0
  14. llm_sign-0.1.0/src/llm_sign/core/crypto.py +223 -0
  15. llm_sign-0.1.0/src/llm_sign/core/encoding.py +95 -0
  16. llm_sign-0.1.0/src/llm_sign/core/errors.py +17 -0
  17. llm_sign-0.1.0/src/llm_sign/core/profiles.py +12 -0
  18. llm_sign-0.1.0/src/llm_sign/encoding.py +3 -0
  19. llm_sign-0.1.0/src/llm_sign/errors.py +3 -0
  20. llm_sign-0.1.0/src/llm_sign/keys/__init__.py +21 -0
  21. llm_sign-0.1.0/src/llm_sign/keys/ed25519.py +58 -0
  22. llm_sign-0.1.0/src/llm_sign/keys/x509.py +336 -0
  23. llm_sign-0.1.0/src/llm_sign/openai.py +3 -0
  24. llm_sign-0.1.0/src/llm_sign/pki.py +3 -0
  25. llm_sign-0.1.0/src/llm_sign/platforms/__init__.py +16 -0
  26. llm_sign-0.1.0/src/llm_sign/platforms/base.py +38 -0
  27. llm_sign-0.1.0/src/llm_sign/platforms/codex_cli.py +13 -0
  28. llm_sign-0.1.0/src/llm_sign/platforms/kimi_cli.py +8 -0
  29. llm_sign-0.1.0/src/llm_sign/platforms/openai_compatible.py +83 -0
  30. llm_sign-0.1.0/src/llm_sign/platforms/vllm.py +8 -0
  31. llm_sign-0.1.0/src/llm_sign/profiles/__init__.py +5 -0
  32. llm_sign-0.1.0/src/llm_sign/profiles/canonical_json.py +82 -0
  33. llm_sign-0.1.0/src/llm_sign/profiles/openai_chat.py +169 -0
  34. llm_sign-0.1.0/src/llm_sign/server/__init__.py +164 -0
  35. llm_sign-0.1.0/src/llm_sign/vendor/__init__.py +7 -0
  36. llm_sign-0.1.0/src/llm_sign/vendor/tls.py +97 -0
  37. llm_sign-0.1.0/src/llm_sign/verifier.py +84 -0
  38. llm_sign-0.1.0/src/llm_sign.egg-info/PKG-INFO +190 -0
  39. llm_sign-0.1.0/src/llm_sign.egg-info/SOURCES.txt +50 -0
  40. llm_sign-0.1.0/src/llm_sign.egg-info/dependency_links.txt +1 -0
  41. llm_sign-0.1.0/src/llm_sign.egg-info/entry_points.txt +2 -0
  42. llm_sign-0.1.0/src/llm_sign.egg-info/requires.txt +4 -0
  43. llm_sign-0.1.0/src/llm_sign.egg-info/top_level.txt +1 -0
  44. llm_sign-0.1.0/tests/test_e2e_signed_client_flow.py +908 -0
  45. llm_sign-0.1.0/tests/test_integration_helpers.py +191 -0
  46. llm_sign-0.1.0/tests/test_openai_profile.py +83 -0
  47. llm_sign-0.1.0/tests/test_pki.py +289 -0
  48. llm_sign-0.1.0/tests/test_platform_artifact.py +134 -0
  49. llm_sign-0.1.0/tests/test_public_api.py +111 -0
  50. llm_sign-0.1.0/tests/test_sign_verify.py +273 -0
  51. llm_sign-0.1.0/tests/test_vendor_tls.py +196 -0
  52. llm_sign-0.1.0/tests/test_version_compatibility.py +132 -0
llm_sign-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.
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: llm-sign
3
+ Version: 0.1.0
4
+ Summary: Provider and client helpers for signed LLM transcript verification
5
+ Author-email: KEXNA <91727108+kexinoh@users.noreply.github.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/kexinoh/llm_sign
8
+ Project-URL: Repository, https://github.com/kexinoh/llm_sign
9
+ Project-URL: Issues, https://github.com/kexinoh/llm_sign/issues
10
+ Keywords: llm,signature,verification,openai,provenance,transcript,cryptography
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Security :: Cryptography
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: cryptography>=42
28
+ Provides-Extra: openai
29
+ Requires-Dist: openai>=1; extra == "openai"
30
+ Dynamic: license-file
31
+
32
+ # llm_sign
33
+
34
+ `llm_sign` defines a provider-signed transcript chain for LLM interactions.
35
+
36
+ The project specifies cryptographic claims over canonicalized LLM interaction
37
+ semantics. The core v1 protocol defines digest construction, block encoding,
38
+ signature semantics, chain validation, verifier failure behavior, and an
39
+ X.509/TLS-style CA profile for authenticating transcript signing keys. It
40
+ deliberately avoids binding the protocol to a transport format, vendor API
41
+ schema, or tokenizer representation.
42
+
43
+ Start here:
44
+
45
+ - [spec/normalization.md](spec/normalization.md)
46
+ - [spec/issuer-pki.md](spec/issuer-pki.md)
47
+ - [docs/artifact.md](docs/artifact.md)
48
+
49
+ ## Package Layout
50
+
51
+ ```text
52
+ src/llm_sign/
53
+ client/ Client-facing verification facade.
54
+ server/ Server/provider-facing signing facade.
55
+ core/ Protocol encoding, block signing, and chain verification.
56
+ profiles/ Canonicalization profiles, including OpenAI Chat Completions.
57
+ keys/ Static Ed25519 and X.509 CA-mode key policies.
58
+ platforms/ Codex CLI, Kimi CLI, vLLM, and OpenAI-compatible adapters.
59
+ vendor/ Backward-compatible provider TLS helpers.
60
+ verifier.py High-level artifact verification API.
61
+ cli.py llm-sign-verify console entry point.
62
+ ```
63
+
64
+ Preferred application entry points are `llm_sign.client.*` for verification and
65
+ `llm_sign.server.*` for signing. Compatibility shims remain at
66
+ `llm_sign.blocks`, `llm_sign.openai`, `llm_sign.keys`, `llm_sign.pki`, and
67
+ `llm_sign.vendor`.
68
+
69
+ For vLLM-style providers, load the same files passed to `vllm serve`:
70
+
71
+ ```python
72
+ import llm_sign
73
+
74
+ credential = llm_sign.server.TLSCertificateCredential.from_files(
75
+ ssl_certfile="/etc/letsencrypt/live/example.com/fullchain.pem",
76
+ ssl_keyfile="/etc/letsencrypt/live/example.com/privkey.pem",
77
+ )
78
+ signer = credential.signer()
79
+ ```
80
+
81
+ The certificate key type determines the default signing suite. The built-in
82
+ suites cover RSA-PSS/SHA-256, P-256 ECDSA/SHA-256, and Ed25519/SHA-256. New
83
+ suites can be registered without changing the chain verification logic.
84
+
85
+ For relay or gateway deployments, the client does not need a manually imported
86
+ supplier public key. The OpenAI-compatible response can include both
87
+ `llm_sign.artifact` and the supplier `llm_sign.certificate_chain`. The verifier
88
+ validates that chain against configured trust anchors and then verifies the
89
+ artifact under the supplier leaf certificate public key. The relay's HTTPS
90
+ certificate authenticates the transport hop only; it is not the supplier signing
91
+ identity.
92
+
93
+ Clients that need backward compatibility with unsigned providers can use
94
+ `llm_sign.client.verify_openai_response_signature(...)`. It returns an optional
95
+ signature report instead of raising when the response has no `llm_sign` data:
96
+ `has_signature` says whether signature data exists, `host_name` is the
97
+ claimed supplier host name, and `valid` is `true`, `false`, or `null` when there was
98
+ no signature to verify.
99
+
100
+ ## Python Usage
101
+
102
+ Install in editable mode:
103
+
104
+ ```sh
105
+ python3 -m pip install -e .
106
+ ```
107
+
108
+ Sign and verify an OpenAI Chat Completions compatible turn:
109
+
110
+ ```python
111
+ import llm_sign
112
+
113
+ keys = llm_sign.server.generate_ed25519_key_pair()
114
+ issuer = "provider.example"
115
+ signer = llm_sign.server.create_signer(
116
+ issuer=issuer,
117
+ key_id=keys.key_id,
118
+ private_key=keys.private_key,
119
+ )
120
+
121
+ request = {
122
+ "model": "gpt-4.1-mini",
123
+ "messages": [{"role": "user", "content": "Say hello"}],
124
+ }
125
+ response = {
126
+ "model": "gpt-4.1-mini",
127
+ "choices": [
128
+ {
129
+ "index": 0,
130
+ "finish_reason": "stop",
131
+ "message": {"role": "assistant", "content": "Hello."},
132
+ }
133
+ ],
134
+ }
135
+
136
+ artifact = llm_sign.server.sign_openai_chat_turn(
137
+ request=request,
138
+ response=response,
139
+ signer=signer,
140
+ )
141
+ result = llm_sign.client.verify_with_public_key(
142
+ artifact,
143
+ issuer=issuer,
144
+ key_id=keys.key_id,
145
+ public_key=keys.public_key,
146
+ )
147
+
148
+ assert result.valid, result.errors
149
+ ```
150
+
151
+ Multi-turn chains can be produced with `llm_sign.server.sign_openai_chat_turns`.
152
+ The tests include a four-block input/output/input/output conversation.
153
+
154
+ ## Examples
155
+
156
+ Runnable examples live in [example/](example/):
157
+
158
+ - `offline_openai_chat_verify.py` verifies a bundled signed OpenAI-compatible
159
+ response without network access.
160
+ - `openai_client_verify.py` calls an OpenAI-compatible endpoint with the OpenAI SDK,
161
+ reports `has_signature`, `host_name`, and `valid`, and continues when the
162
+ endpoint does not yet return `llm_sign` data.
163
+ - `tamper_detection.py` shows payload digest mismatch detection after a signed
164
+ response is modified.
165
+
166
+ Run tests:
167
+
168
+ ```sh
169
+ PYTHONPATH=src python3 -m unittest discover -s tests
170
+ ```
171
+
172
+ Verify a platform artifact with a pinned public key:
173
+
174
+ ```sh
175
+ llm-sign-verify artifact.json \
176
+ --issuer provider.example \
177
+ --public-key provider-ed25519-public.pem
178
+ ```
179
+
180
+ Verify an artifact with a supplier certificate chain. In relay deployments,
181
+ extract this chain from `llm_sign.certificate_chain` in the first signed
182
+ response:
183
+
184
+ ```sh
185
+ llm-sign-verify artifact.json \
186
+ --issuer example.com \
187
+ --certificate-chain supplier-chain.pem \
188
+ --trust-anchor root-ca.pem \
189
+ --tls-server-name-mode
190
+ ```
@@ -0,0 +1,159 @@
1
+ # llm_sign
2
+
3
+ `llm_sign` defines a provider-signed transcript chain for LLM interactions.
4
+
5
+ The project specifies cryptographic claims over canonicalized LLM interaction
6
+ semantics. The core v1 protocol defines digest construction, block encoding,
7
+ signature semantics, chain validation, verifier failure behavior, and an
8
+ X.509/TLS-style CA profile for authenticating transcript signing keys. It
9
+ deliberately avoids binding the protocol to a transport format, vendor API
10
+ schema, or tokenizer representation.
11
+
12
+ Start here:
13
+
14
+ - [spec/normalization.md](spec/normalization.md)
15
+ - [spec/issuer-pki.md](spec/issuer-pki.md)
16
+ - [docs/artifact.md](docs/artifact.md)
17
+
18
+ ## Package Layout
19
+
20
+ ```text
21
+ src/llm_sign/
22
+ client/ Client-facing verification facade.
23
+ server/ Server/provider-facing signing facade.
24
+ core/ Protocol encoding, block signing, and chain verification.
25
+ profiles/ Canonicalization profiles, including OpenAI Chat Completions.
26
+ keys/ Static Ed25519 and X.509 CA-mode key policies.
27
+ platforms/ Codex CLI, Kimi CLI, vLLM, and OpenAI-compatible adapters.
28
+ vendor/ Backward-compatible provider TLS helpers.
29
+ verifier.py High-level artifact verification API.
30
+ cli.py llm-sign-verify console entry point.
31
+ ```
32
+
33
+ Preferred application entry points are `llm_sign.client.*` for verification and
34
+ `llm_sign.server.*` for signing. Compatibility shims remain at
35
+ `llm_sign.blocks`, `llm_sign.openai`, `llm_sign.keys`, `llm_sign.pki`, and
36
+ `llm_sign.vendor`.
37
+
38
+ For vLLM-style providers, load the same files passed to `vllm serve`:
39
+
40
+ ```python
41
+ import llm_sign
42
+
43
+ credential = llm_sign.server.TLSCertificateCredential.from_files(
44
+ ssl_certfile="/etc/letsencrypt/live/example.com/fullchain.pem",
45
+ ssl_keyfile="/etc/letsencrypt/live/example.com/privkey.pem",
46
+ )
47
+ signer = credential.signer()
48
+ ```
49
+
50
+ The certificate key type determines the default signing suite. The built-in
51
+ suites cover RSA-PSS/SHA-256, P-256 ECDSA/SHA-256, and Ed25519/SHA-256. New
52
+ suites can be registered without changing the chain verification logic.
53
+
54
+ For relay or gateway deployments, the client does not need a manually imported
55
+ supplier public key. The OpenAI-compatible response can include both
56
+ `llm_sign.artifact` and the supplier `llm_sign.certificate_chain`. The verifier
57
+ validates that chain against configured trust anchors and then verifies the
58
+ artifact under the supplier leaf certificate public key. The relay's HTTPS
59
+ certificate authenticates the transport hop only; it is not the supplier signing
60
+ identity.
61
+
62
+ Clients that need backward compatibility with unsigned providers can use
63
+ `llm_sign.client.verify_openai_response_signature(...)`. It returns an optional
64
+ signature report instead of raising when the response has no `llm_sign` data:
65
+ `has_signature` says whether signature data exists, `host_name` is the
66
+ claimed supplier host name, and `valid` is `true`, `false`, or `null` when there was
67
+ no signature to verify.
68
+
69
+ ## Python Usage
70
+
71
+ Install in editable mode:
72
+
73
+ ```sh
74
+ python3 -m pip install -e .
75
+ ```
76
+
77
+ Sign and verify an OpenAI Chat Completions compatible turn:
78
+
79
+ ```python
80
+ import llm_sign
81
+
82
+ keys = llm_sign.server.generate_ed25519_key_pair()
83
+ issuer = "provider.example"
84
+ signer = llm_sign.server.create_signer(
85
+ issuer=issuer,
86
+ key_id=keys.key_id,
87
+ private_key=keys.private_key,
88
+ )
89
+
90
+ request = {
91
+ "model": "gpt-4.1-mini",
92
+ "messages": [{"role": "user", "content": "Say hello"}],
93
+ }
94
+ response = {
95
+ "model": "gpt-4.1-mini",
96
+ "choices": [
97
+ {
98
+ "index": 0,
99
+ "finish_reason": "stop",
100
+ "message": {"role": "assistant", "content": "Hello."},
101
+ }
102
+ ],
103
+ }
104
+
105
+ artifact = llm_sign.server.sign_openai_chat_turn(
106
+ request=request,
107
+ response=response,
108
+ signer=signer,
109
+ )
110
+ result = llm_sign.client.verify_with_public_key(
111
+ artifact,
112
+ issuer=issuer,
113
+ key_id=keys.key_id,
114
+ public_key=keys.public_key,
115
+ )
116
+
117
+ assert result.valid, result.errors
118
+ ```
119
+
120
+ Multi-turn chains can be produced with `llm_sign.server.sign_openai_chat_turns`.
121
+ The tests include a four-block input/output/input/output conversation.
122
+
123
+ ## Examples
124
+
125
+ Runnable examples live in [example/](example/):
126
+
127
+ - `offline_openai_chat_verify.py` verifies a bundled signed OpenAI-compatible
128
+ response without network access.
129
+ - `openai_client_verify.py` calls an OpenAI-compatible endpoint with the OpenAI SDK,
130
+ reports `has_signature`, `host_name`, and `valid`, and continues when the
131
+ endpoint does not yet return `llm_sign` data.
132
+ - `tamper_detection.py` shows payload digest mismatch detection after a signed
133
+ response is modified.
134
+
135
+ Run tests:
136
+
137
+ ```sh
138
+ PYTHONPATH=src python3 -m unittest discover -s tests
139
+ ```
140
+
141
+ Verify a platform artifact with a pinned public key:
142
+
143
+ ```sh
144
+ llm-sign-verify artifact.json \
145
+ --issuer provider.example \
146
+ --public-key provider-ed25519-public.pem
147
+ ```
148
+
149
+ Verify an artifact with a supplier certificate chain. In relay deployments,
150
+ extract this chain from `llm_sign.certificate_chain` in the first signed
151
+ response:
152
+
153
+ ```sh
154
+ llm-sign-verify artifact.json \
155
+ --issuer example.com \
156
+ --certificate-chain supplier-chain.pem \
157
+ --trust-anchor root-ca.pem \
158
+ --tls-server-name-mode
159
+ ```
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "llm-sign"
7
+ version = "0.1.0"
8
+ description = "Provider and client helpers for signed LLM transcript verification"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "KEXNA", email = "91727108+kexinoh@users.noreply.github.com" },
15
+ ]
16
+ keywords = [
17
+ "llm",
18
+ "signature",
19
+ "verification",
20
+ "openai",
21
+ "provenance",
22
+ "transcript",
23
+ "cryptography",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Intended Audience :: Developers",
28
+ "Operating System :: OS Independent",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.9",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Topic :: Security :: Cryptography",
37
+ "Topic :: Software Development :: Libraries :: Python Modules",
38
+ "Typing :: Typed",
39
+ ]
40
+ dependencies = [
41
+ "cryptography>=42",
42
+ ]
43
+
44
+ [project.optional-dependencies]
45
+ openai = [
46
+ "openai>=1",
47
+ ]
48
+
49
+ [project.urls]
50
+ Homepage = "https://github.com/kexinoh/llm_sign"
51
+ Repository = "https://github.com/kexinoh/llm_sign"
52
+ Issues = "https://github.com/kexinoh/llm_sign/issues"
53
+
54
+ [project.scripts]
55
+ llm-sign-verify = "llm_sign.cli:main"
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = ["src"]
59
+
60
+ [tool.pytest.ini_options]
61
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,73 @@
1
+ """LLM transcript signing primitives."""
2
+
3
+ from importlib.metadata import PackageNotFoundError as _PkgNotFound
4
+ from importlib.metadata import version as _pkg_version
5
+
6
+ try:
7
+ __version__ = _pkg_version("llm-sign")
8
+ except _PkgNotFound: # pragma: no cover - source checkout without install
9
+ __version__ = "0.0.0+unknown"
10
+
11
+ from . import client, server
12
+ from .core.blocks import (
13
+ Block,
14
+ ChainVerification,
15
+ PayloadState,
16
+ SignedBlock,
17
+ TOOL_RESULT,
18
+ TranscriptSigner,
19
+ VerifiedBlock,
20
+ sign_payload,
21
+ verify_chain,
22
+ )
23
+ from .core.crypto import (
24
+ SignatureSuite,
25
+ infer_suite_for_private_key,
26
+ infer_suite_for_public_key,
27
+ register_signature_suite,
28
+ supported_suite_ids,
29
+ )
30
+ from .keys.ed25519 import Ed25519KeyPair, StaticKeyPolicy
31
+ from .keys.x509 import LLM_SIGN_ISSUER_OID, LLM_SIGN_TRANSCRIPT_EKU_OID, X509KeyPolicy
32
+ from .profiles.openai_chat import (
33
+ OpenAIChatInputProfile,
34
+ OpenAIChatOutputProfile,
35
+ OpenAIToolResultProfile,
36
+ project_openai_chat_request,
37
+ project_openai_chat_response,
38
+ )
39
+ from .vendor import TLSCertificateCredential
40
+ from .verifier import load_signed_blocks, verify_artifact
41
+
42
+ __all__ = [
43
+ "__version__",
44
+ "Block",
45
+ "ChainVerification",
46
+ "Ed25519KeyPair",
47
+ "OpenAIChatInputProfile",
48
+ "OpenAIChatOutputProfile",
49
+ "OpenAIToolResultProfile",
50
+ "PayloadState",
51
+ "SignedBlock",
52
+ "SignatureSuite",
53
+ "StaticKeyPolicy",
54
+ "TOOL_RESULT",
55
+ "TranscriptSigner",
56
+ "TLSCertificateCredential",
57
+ "LLM_SIGN_ISSUER_OID",
58
+ "LLM_SIGN_TRANSCRIPT_EKU_OID",
59
+ "VerifiedBlock",
60
+ "X509KeyPolicy",
61
+ "client",
62
+ "infer_suite_for_private_key",
63
+ "infer_suite_for_public_key",
64
+ "load_signed_blocks",
65
+ "project_openai_chat_request",
66
+ "project_openai_chat_response",
67
+ "sign_payload",
68
+ "register_signature_suite",
69
+ "supported_suite_ids",
70
+ "server",
71
+ "verify_artifact",
72
+ "verify_chain",
73
+ ]