trooth 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.
trooth-0.1.0/LICENSE ADDED
@@ -0,0 +1,70 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
+
17
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
+
19
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
+
23
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
+
25
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
+
27
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
+
29
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
+
31
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
+
35
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
+
37
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
+
39
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
40
+
41
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42
+
43
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ Copyright (c) 2026 Trooth, LLC
58
+
59
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use the files in this
60
+ verifier/ folder except in compliance with the License. You may obtain a copy of the License at
61
+
62
+ http://www.apache.org/licenses/LICENSE-2.0
63
+
64
+ Unless required by applicable law or agreed to in writing, software distributed under the License is
65
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
66
+ implied. See the License for the specific language governing permissions and limitations under the
67
+ License.
68
+
69
+ This license covers the verifier/ folder only. Every other file in this repository is proprietary to
70
+ Trooth, LLC (LicenseRef-Trooth-Proprietary) unless its own header says otherwise.
trooth-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.4
2
+ Name: trooth
3
+ Version: 0.1.0
4
+ Summary: Read a company's Semanto signed copy and check it: signatures, keys, DNS binding, page proofs and the public log.
5
+ Author: Trooth, LLC
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://trooth.co/docs/semanto
8
+ Project-URL: Documentation, https://trooth.co/docs/semanto
9
+ Project-URL: Source, https://github.com/troothllc/trooth-semanto-worker/tree/main/verifier/python
10
+ Project-URL: Issues, https://github.com/troothllc/trooth-semanto-worker/issues
11
+ Project-URL: Changelog, https://github.com/troothllc/trooth-semanto-worker/releases
12
+ Keywords: semanto,trooth,signatures,rfc9421,web-bot-auth,transparency-log,ai-agents
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Topic :: Security :: Cryptography
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: cryptography>=41
23
+ Provides-Extra: langchain
24
+ Requires-Dist: langchain-core>=0.3; extra == "langchain"
25
+ Provides-Extra: llama-index
26
+ Requires-Dist: llama-index-core>=0.12; extra == "llama-index"
27
+ Provides-Extra: openai-agents
28
+ Requires-Dist: openai-agents>=0.2; extra == "openai-agents"
29
+ Dynamic: license-file
30
+
31
+ <!-- SPDX-License-Identifier: Apache-2.0 -->
32
+ <!-- Copyright (c) 2026 Trooth, LLC -->
33
+
34
+ # trooth (Python)
35
+
36
+ Read a company's Semanto signed copy and check it: the file, a page proof, a signed response or the public log, offline. Standard library plus `cryptography` (for Ed25519). Python 3.11 or newer.
37
+
38
+ ```
39
+ pip install trooth # the checks, SemantoClient and the semanto-verify command
40
+ pip install "trooth[langchain]" # plus trooth.integrations.langchain.SemantoLoader
41
+ pip install "trooth[llama-index]" # plus trooth.integrations.llama_index.SemantoReader
42
+ pip install "trooth[openai-agents]" # plus trooth.integrations.openai_agents.semanto_read_tool
43
+ ```
44
+
45
+ Every release is built and published by GitHub Actions through PyPI Trusted Publishing, with no stored token, and carries PEP 740 attestations that tie each file to the workflow run that built it.
46
+
47
+ Without installing: `PYTHONPATH=verifier/python python3 -m trooth_semanto_verify file verifier/test-vectors/v1/semanto.json --pages verifier/test-vectors/v1/pages`
48
+
49
+ ## Commands
50
+
51
+ ```
52
+ semanto-verify file <semanto.json> [--pages <dir>] [--keys <keys.json>] [--now <iso>] [--revocations <file>]
53
+ semanto-verify page <url> [--trooth <base>] [--now <iso>]
54
+ semanto-verify response <url> [--keys <keys.json>]
55
+ semanto-verify log --from <n> --to <m> [--log <url>] [--keys <keys.json>]
56
+ ```
57
+
58
+ `file` needs no network when `--keys` is given or a `keys.json` sits beside the file. Pages are read from `<dir>/<page id>.md`. Exit code 0 means every check passed; 1 means at least one failed.
59
+
60
+ ## Library
61
+
62
+ ```python
63
+ import json, trooth_semanto_verify as V
64
+
65
+ file = json.load(open("semanto.json"))
66
+ keys = [json.load(open("acme-keys.json")), json.load(open("trooth-keys.json"))]
67
+ result = V.verify_semanto(file, {"https://acme.com/security": open("security.md", "rb").read()}, keys)
68
+ for check in result["checks"]:
69
+ print("ok " if check["ok"] else "FAIL", check["name"], check["detail"])
70
+ ```
71
+
72
+ The functions and the reason codes are the same as the JavaScript and Go kits: `verify_semanto`, `verify_page_proof`, `verify_response`, `verify_web_bot_auth_request`, `verify_tree_head`, `verify_inclusion_in_log`, `verify_consistency`, `verify_checkpoint`, `verify_offer`, `verify_revocation_list`, `state_of`, plus `canonicalize` (RFC 8785), the RFC 6962 primitives and `verify_jws`.
73
+
74
+ Canonical JSON here supports integers exactly. A non-integer float raises `CanonicalizeError` with a message saying to use minor units or a string, because Semanto never signs one.
75
+
76
+ ## Tests
77
+
78
+ `python3 -m pytest` runs every shared vector in `verifier/test-vectors/v1` (positive and negative), the RFC 6962 known roots, the RFC 8785 cases, the state rules and the command line.
79
+
80
+ ## SemantoClient
81
+
82
+ ```python
83
+ from trooth_semanto_verify.client import SemantoClient
84
+ r = SemantoClient().read("https://acme.com/pricing")
85
+ print(r["ok"], r["dns"], r["reason"])
86
+ ```
87
+
88
+ It fetches with the standard library (pass `fetch=` to use your own), checks the response signature and the domain's `_trooth-keys` TXT record over DNS over HTTPS, and keeps key sets and DNS answers five minutes.
trooth-0.1.0/README.md ADDED
@@ -0,0 +1,58 @@
1
+ <!-- SPDX-License-Identifier: Apache-2.0 -->
2
+ <!-- Copyright (c) 2026 Trooth, LLC -->
3
+
4
+ # trooth (Python)
5
+
6
+ Read a company's Semanto signed copy and check it: the file, a page proof, a signed response or the public log, offline. Standard library plus `cryptography` (for Ed25519). Python 3.11 or newer.
7
+
8
+ ```
9
+ pip install trooth # the checks, SemantoClient and the semanto-verify command
10
+ pip install "trooth[langchain]" # plus trooth.integrations.langchain.SemantoLoader
11
+ pip install "trooth[llama-index]" # plus trooth.integrations.llama_index.SemantoReader
12
+ pip install "trooth[openai-agents]" # plus trooth.integrations.openai_agents.semanto_read_tool
13
+ ```
14
+
15
+ Every release is built and published by GitHub Actions through PyPI Trusted Publishing, with no stored token, and carries PEP 740 attestations that tie each file to the workflow run that built it.
16
+
17
+ Without installing: `PYTHONPATH=verifier/python python3 -m trooth_semanto_verify file verifier/test-vectors/v1/semanto.json --pages verifier/test-vectors/v1/pages`
18
+
19
+ ## Commands
20
+
21
+ ```
22
+ semanto-verify file <semanto.json> [--pages <dir>] [--keys <keys.json>] [--now <iso>] [--revocations <file>]
23
+ semanto-verify page <url> [--trooth <base>] [--now <iso>]
24
+ semanto-verify response <url> [--keys <keys.json>]
25
+ semanto-verify log --from <n> --to <m> [--log <url>] [--keys <keys.json>]
26
+ ```
27
+
28
+ `file` needs no network when `--keys` is given or a `keys.json` sits beside the file. Pages are read from `<dir>/<page id>.md`. Exit code 0 means every check passed; 1 means at least one failed.
29
+
30
+ ## Library
31
+
32
+ ```python
33
+ import json, trooth_semanto_verify as V
34
+
35
+ file = json.load(open("semanto.json"))
36
+ keys = [json.load(open("acme-keys.json")), json.load(open("trooth-keys.json"))]
37
+ result = V.verify_semanto(file, {"https://acme.com/security": open("security.md", "rb").read()}, keys)
38
+ for check in result["checks"]:
39
+ print("ok " if check["ok"] else "FAIL", check["name"], check["detail"])
40
+ ```
41
+
42
+ The functions and the reason codes are the same as the JavaScript and Go kits: `verify_semanto`, `verify_page_proof`, `verify_response`, `verify_web_bot_auth_request`, `verify_tree_head`, `verify_inclusion_in_log`, `verify_consistency`, `verify_checkpoint`, `verify_offer`, `verify_revocation_list`, `state_of`, plus `canonicalize` (RFC 8785), the RFC 6962 primitives and `verify_jws`.
43
+
44
+ Canonical JSON here supports integers exactly. A non-integer float raises `CanonicalizeError` with a message saying to use minor units or a string, because Semanto never signs one.
45
+
46
+ ## Tests
47
+
48
+ `python3 -m pytest` runs every shared vector in `verifier/test-vectors/v1` (positive and negative), the RFC 6962 known roots, the RFC 8785 cases, the state rules and the command line.
49
+
50
+ ## SemantoClient
51
+
52
+ ```python
53
+ from trooth_semanto_verify.client import SemantoClient
54
+ r = SemantoClient().read("https://acme.com/pricing")
55
+ print(r["ok"], r["dns"], r["reason"])
56
+ ```
57
+
58
+ It fetches with the standard library (pass `fetch=` to use your own), checks the response signature and the domain's `_trooth-keys` TXT record over DNS over HTTPS, and keeps key sets and DNS answers five minutes.
@@ -0,0 +1,52 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2026 Trooth, LLC
3
+ #
4
+ # The one Python distribution Trooth publishes, as `trooth` on PyPI. Released by
5
+ # .github/workflows/publish-pypi.yml through PyPI Trusted Publishing (no token is
6
+ # stored anywhere), with PEP 740 attestations. Framework integrations are extras,
7
+ # so the base install needs only `cryptography`.
8
+
9
+ [build-system]
10
+ requires = ["setuptools>=77"]
11
+ build-backend = "setuptools.build_meta"
12
+
13
+ [project]
14
+ name = "trooth"
15
+ version = "0.1.0"
16
+ description = "Read a company's Semanto signed copy and check it: signatures, keys, DNS binding, page proofs and the public log."
17
+ readme = "README.md"
18
+ requires-python = ">=3.11"
19
+ license = "Apache-2.0"
20
+ license-files = ["LICENSE"]
21
+ authors = [{ name = "Trooth, LLC" }]
22
+ keywords = ["semanto", "trooth", "signatures", "rfc9421", "web-bot-auth", "transparency-log", "ai-agents"]
23
+ classifiers = [
24
+ "Development Status :: 4 - Beta",
25
+ "Intended Audience :: Developers",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3 :: Only",
29
+ "Topic :: Security :: Cryptography",
30
+ ]
31
+ dependencies = ["cryptography>=41"]
32
+
33
+ [project.optional-dependencies]
34
+ langchain = ["langchain-core>=0.3"]
35
+ llama-index = ["llama-index-core>=0.12"]
36
+ openai-agents = ["openai-agents>=0.2"]
37
+
38
+ [project.urls]
39
+ Homepage = "https://trooth.co/docs/semanto"
40
+ Documentation = "https://trooth.co/docs/semanto"
41
+ Source = "https://github.com/troothllc/trooth-semanto-worker/tree/main/verifier/python"
42
+ Issues = "https://github.com/troothllc/trooth-semanto-worker/issues"
43
+ Changelog = "https://github.com/troothllc/trooth-semanto-worker/releases"
44
+
45
+ [project.scripts]
46
+ semanto-verify = "trooth_semanto_verify.cli:main"
47
+
48
+ [tool.setuptools.packages.find]
49
+ include = ["trooth_semanto_verify*", "trooth*"]
50
+
51
+ [tool.pytest.ini_options]
52
+ testpaths = ["."]
trooth-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,14 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2026 Trooth, LLC
3
+ """Trooth for Python: read a company's Semanto signed copy and check it.
4
+
5
+ from trooth import SemantoClient
6
+ r = SemantoClient().read("https://acme.com/pricing")
7
+
8
+ The checks themselves live in trooth_semanto_verify (the same functions and reason codes as the JavaScript and Go
9
+ kits). Framework integrations are optional extras: trooth[langchain], trooth[llama-index], trooth[openai-agents].
10
+ """
11
+ from trooth_semanto_verify.client import SemantoClient
12
+
13
+ __version__ = "0.1.0"
14
+ __all__ = ["SemantoClient", "__version__"]
@@ -0,0 +1,16 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2026 Trooth, LLC
3
+ """Framework integrations, each behind its own extra so the base install pulls in no framework."""
4
+
5
+
6
+ def metadata_of(url: str, r: dict) -> dict:
7
+ """The Semanto fields every integration puts beside the text."""
8
+ return {
9
+ "source": url,
10
+ "semanto_ok": bool(r["ok"]),
11
+ "semanto_reason": r.get("reason"),
12
+ "semanto_version": r.get("version"),
13
+ "semanto_signed_by": r.get("signed_by"),
14
+ "semanto_keyid": r.get("keyid"),
15
+ "semanto_dns": r.get("dns"),
16
+ }
@@ -0,0 +1,33 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2026 Trooth, LLC
3
+ """LangChain document loader (pip install "trooth[langchain]")."""
4
+ from __future__ import annotations
5
+
6
+ from typing import Any, Iterator, List, Optional, Sequence
7
+
8
+ from langchain_core.document_loaders import BaseLoader
9
+ from langchain_core.documents import Document
10
+ from trooth_semanto_verify.client import SemantoClient
11
+
12
+ from . import metadata_of
13
+
14
+
15
+ class SemantoLoader(BaseLoader):
16
+ """Load pages as markdown from a company's domain, each checked against its signature."""
17
+
18
+ def __init__(self, urls: Sequence[str], client: Optional[Any] = None, only_signed: bool = False):
19
+ self.urls = list(urls)
20
+ self.client = client or SemantoClient()
21
+ self.only_signed = only_signed
22
+ self.skipped: List[dict] = []
23
+
24
+ def lazy_load(self) -> Iterator[Document]:
25
+ for url in self.urls:
26
+ r = self.client.read(url)
27
+ if self.only_signed and not r["ok"]:
28
+ self.skipped.append({"url": url, "reason": r.get("reason")})
29
+ continue
30
+ yield Document(page_content=r["text"], metadata=metadata_of(url, r))
31
+
32
+
33
+ __all__ = ["SemantoLoader"]
@@ -0,0 +1,34 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2026 Trooth, LLC
3
+ """LlamaIndex reader (pip install "trooth[llama-index]")."""
4
+ from __future__ import annotations
5
+
6
+ from typing import Any, List, Optional
7
+
8
+ from llama_index.core.readers.base import BaseReader
9
+ from llama_index.core.schema import Document
10
+ from trooth_semanto_verify.client import SemantoClient
11
+
12
+ from . import metadata_of
13
+
14
+
15
+ class SemantoReader(BaseReader):
16
+ """Read pages as markdown from a company's domain, each checked against its signature."""
17
+
18
+ def __init__(self, client: Optional[Any] = None, only_signed: bool = False):
19
+ self.client = client or SemantoClient()
20
+ self.only_signed = only_signed
21
+ self.skipped: List[dict] = []
22
+
23
+ def load_data(self, urls: List[str]) -> List[Document]: # type: ignore[override]
24
+ out: List[Document] = []
25
+ for url in urls:
26
+ r = self.client.read(url)
27
+ if self.only_signed and not r["ok"]:
28
+ self.skipped.append({"url": url, "reason": r.get("reason")})
29
+ continue
30
+ out.append(Document(text=r["text"], metadata=metadata_of(url, r)))
31
+ return out
32
+
33
+
34
+ __all__ = ["SemantoReader"]
@@ -0,0 +1,44 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2026 Trooth, LLC
3
+ """A function tool for the OpenAI Agents SDK (pip install "trooth[openai-agents]")."""
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ from typing import Any, Optional
8
+
9
+ from agents import FunctionTool, function_tool
10
+ from trooth_semanto_verify.client import SemantoClient
11
+
12
+
13
+ def read_as_json(client: Any, url: str, max_chars: int = 20_000) -> str:
14
+ """The tool's answer: whether the copy checked out, and the text, as one JSON string."""
15
+ r = client.read(url)
16
+ text = r["text"]
17
+ return json.dumps({
18
+ "url": url,
19
+ "ok": bool(r["ok"]),
20
+ "reason": r.get("reason"),
21
+ "version": r.get("version"),
22
+ "signed_by": r.get("signed_by") or ("company" if r.get("keyid") else None),
23
+ "dns": r.get("dns"),
24
+ "text": text[:max_chars],
25
+ "cut": len(text) > max_chars,
26
+ })
27
+
28
+
29
+ def semanto_read_tool(client: Optional[Any] = None, max_chars: int = 20_000) -> FunctionTool:
30
+ c = client or SemantoClient()
31
+
32
+ @function_tool(name_override="semanto_read")
33
+ def semanto_read(url: str) -> str:
34
+ """Read a page from a company's website as its signed Semanto copy, and say whether the signature checked out.
35
+
36
+ Args:
37
+ url: The page's address on the company's own domain, for example https://acme.com/pricing.
38
+ """
39
+ return read_as_json(c, url, max_chars)
40
+
41
+ return semanto_read
42
+
43
+
44
+ __all__ = ["semanto_read_tool", "read_as_json"]
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.4
2
+ Name: trooth
3
+ Version: 0.1.0
4
+ Summary: Read a company's Semanto signed copy and check it: signatures, keys, DNS binding, page proofs and the public log.
5
+ Author: Trooth, LLC
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://trooth.co/docs/semanto
8
+ Project-URL: Documentation, https://trooth.co/docs/semanto
9
+ Project-URL: Source, https://github.com/troothllc/trooth-semanto-worker/tree/main/verifier/python
10
+ Project-URL: Issues, https://github.com/troothllc/trooth-semanto-worker/issues
11
+ Project-URL: Changelog, https://github.com/troothllc/trooth-semanto-worker/releases
12
+ Keywords: semanto,trooth,signatures,rfc9421,web-bot-auth,transparency-log,ai-agents
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Topic :: Security :: Cryptography
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: cryptography>=41
23
+ Provides-Extra: langchain
24
+ Requires-Dist: langchain-core>=0.3; extra == "langchain"
25
+ Provides-Extra: llama-index
26
+ Requires-Dist: llama-index-core>=0.12; extra == "llama-index"
27
+ Provides-Extra: openai-agents
28
+ Requires-Dist: openai-agents>=0.2; extra == "openai-agents"
29
+ Dynamic: license-file
30
+
31
+ <!-- SPDX-License-Identifier: Apache-2.0 -->
32
+ <!-- Copyright (c) 2026 Trooth, LLC -->
33
+
34
+ # trooth (Python)
35
+
36
+ Read a company's Semanto signed copy and check it: the file, a page proof, a signed response or the public log, offline. Standard library plus `cryptography` (for Ed25519). Python 3.11 or newer.
37
+
38
+ ```
39
+ pip install trooth # the checks, SemantoClient and the semanto-verify command
40
+ pip install "trooth[langchain]" # plus trooth.integrations.langchain.SemantoLoader
41
+ pip install "trooth[llama-index]" # plus trooth.integrations.llama_index.SemantoReader
42
+ pip install "trooth[openai-agents]" # plus trooth.integrations.openai_agents.semanto_read_tool
43
+ ```
44
+
45
+ Every release is built and published by GitHub Actions through PyPI Trusted Publishing, with no stored token, and carries PEP 740 attestations that tie each file to the workflow run that built it.
46
+
47
+ Without installing: `PYTHONPATH=verifier/python python3 -m trooth_semanto_verify file verifier/test-vectors/v1/semanto.json --pages verifier/test-vectors/v1/pages`
48
+
49
+ ## Commands
50
+
51
+ ```
52
+ semanto-verify file <semanto.json> [--pages <dir>] [--keys <keys.json>] [--now <iso>] [--revocations <file>]
53
+ semanto-verify page <url> [--trooth <base>] [--now <iso>]
54
+ semanto-verify response <url> [--keys <keys.json>]
55
+ semanto-verify log --from <n> --to <m> [--log <url>] [--keys <keys.json>]
56
+ ```
57
+
58
+ `file` needs no network when `--keys` is given or a `keys.json` sits beside the file. Pages are read from `<dir>/<page id>.md`. Exit code 0 means every check passed; 1 means at least one failed.
59
+
60
+ ## Library
61
+
62
+ ```python
63
+ import json, trooth_semanto_verify as V
64
+
65
+ file = json.load(open("semanto.json"))
66
+ keys = [json.load(open("acme-keys.json")), json.load(open("trooth-keys.json"))]
67
+ result = V.verify_semanto(file, {"https://acme.com/security": open("security.md", "rb").read()}, keys)
68
+ for check in result["checks"]:
69
+ print("ok " if check["ok"] else "FAIL", check["name"], check["detail"])
70
+ ```
71
+
72
+ The functions and the reason codes are the same as the JavaScript and Go kits: `verify_semanto`, `verify_page_proof`, `verify_response`, `verify_web_bot_auth_request`, `verify_tree_head`, `verify_inclusion_in_log`, `verify_consistency`, `verify_checkpoint`, `verify_offer`, `verify_revocation_list`, `state_of`, plus `canonicalize` (RFC 8785), the RFC 6962 primitives and `verify_jws`.
73
+
74
+ Canonical JSON here supports integers exactly. A non-integer float raises `CanonicalizeError` with a message saying to use minor units or a string, because Semanto never signs one.
75
+
76
+ ## Tests
77
+
78
+ `python3 -m pytest` runs every shared vector in `verifier/test-vectors/v1` (positive and negative), the RFC 6962 known roots, the RFC 8785 cases, the state rules and the command line.
79
+
80
+ ## SemantoClient
81
+
82
+ ```python
83
+ from trooth_semanto_verify.client import SemantoClient
84
+ r = SemantoClient().read("https://acme.com/pricing")
85
+ print(r["ok"], r["dns"], r["reason"])
86
+ ```
87
+
88
+ It fetches with the standard library (pass `fetch=` to use your own), checks the response signature and the domain's `_trooth-keys` TXT record over DNS over HTTPS, and keeps key sets and DNS answers five minutes.
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ trooth/__init__.py
5
+ trooth.egg-info/PKG-INFO
6
+ trooth.egg-info/SOURCES.txt
7
+ trooth.egg-info/dependency_links.txt
8
+ trooth.egg-info/entry_points.txt
9
+ trooth.egg-info/requires.txt
10
+ trooth.egg-info/top_level.txt
11
+ trooth/integrations/__init__.py
12
+ trooth/integrations/langchain.py
13
+ trooth/integrations/llama_index.py
14
+ trooth/integrations/openai_agents.py
15
+ trooth_semanto_verify/__init__.py
16
+ trooth_semanto_verify/__main__.py
17
+ trooth_semanto_verify/canonical.py
18
+ trooth_semanto_verify/cli.py
19
+ trooth_semanto_verify/client.py
20
+ trooth_semanto_verify/httpsig.py
21
+ trooth_semanto_verify/jws.py
22
+ trooth_semanto_verify/merkle.py
23
+ trooth_semanto_verify/verify.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ semanto-verify = trooth_semanto_verify.cli:main
@@ -0,0 +1,10 @@
1
+ cryptography>=41
2
+
3
+ [langchain]
4
+ langchain-core>=0.3
5
+
6
+ [llama-index]
7
+ llama-index-core>=0.12
8
+
9
+ [openai-agents]
10
+ openai-agents>=0.2
@@ -0,0 +1,2 @@
1
+ trooth
2
+ trooth_semanto_verify