qed-proof 0.1.1__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 (43) hide show
  1. qed_proof-0.1.1/.gitignore +5 -0
  2. qed_proof-0.1.1/CHANGELOG.md +27 -0
  3. qed_proof-0.1.1/LICENSE +202 -0
  4. qed_proof-0.1.1/PKG-INFO +189 -0
  5. qed_proof-0.1.1/README.md +156 -0
  6. qed_proof-0.1.1/pyproject.toml +56 -0
  7. qed_proof-0.1.1/src/qed_proof/__init__.py +42 -0
  8. qed_proof-0.1.1/src/qed_proof/_anchor.py +75 -0
  9. qed_proof-0.1.1/src/qed_proof/_primitives.py +97 -0
  10. qed_proof-0.1.1/src/qed_proof/actions.py +99 -0
  11. qed_proof-0.1.1/src/qed_proof/client.py +350 -0
  12. qed_proof-0.1.1/src/qed_proof/py.typed +0 -0
  13. qed_proof-0.1.1/src/qed_proof/receipt.schema.json +156 -0
  14. qed_proof-0.1.1/src/qed_proof/types.py +118 -0
  15. qed_proof-0.1.1/src/qed_proof/verify.py +131 -0
  16. qed_proof-0.1.1/tests/test_actions.py +50 -0
  17. qed_proof-0.1.1/tests/test_anchor_check.py +66 -0
  18. qed_proof-0.1.1/tests/test_client.py +281 -0
  19. qed_proof-0.1.1/tests/test_conformance.py +27 -0
  20. qed_proof-0.1.1/tests/test_types.py +64 -0
  21. qed_proof-0.1.1/tests/vectors/001-valid-verified.json +47 -0
  22. qed_proof-0.1.1/tests/vectors/002-valid-late.json +48 -0
  23. qed_proof-0.1.1/tests/vectors/003-valid-mismatch.json +48 -0
  24. qed_proof-0.1.1/tests/vectors/004-valid-failed.json +46 -0
  25. qed_proof-0.1.1/tests/vectors/005-valid-unverifiable.json +44 -0
  26. qed_proof-0.1.1/tests/vectors/006-valid-key-b-before-revocation.json +47 -0
  27. qed_proof-0.1.1/tests/vectors/007-tampered-verdict.json +47 -0
  28. qed_proof-0.1.1/tests/vectors/008-wrong-key.json +47 -0
  29. qed_proof-0.1.1/tests/vectors/009-unknown-key.json +47 -0
  30. qed_proof-0.1.1/tests/vectors/010-revoked-key.json +47 -0
  31. qed_proof-0.1.1/tests/vectors/011-bad-claim-digest.json +47 -0
  32. qed_proof-0.1.1/tests/vectors/012-unverifiable-without-reason.json +43 -0
  33. qed_proof-0.1.1/tests/vectors/013-level3-without-attestation.json +47 -0
  34. qed_proof-0.1.1/tests/vectors/014-float-in-body.json +48 -0
  35. qed_proof-0.1.1/tests/vectors/015-unsupported-major-version.json +47 -0
  36. qed_proof-0.1.1/tests/vectors/016-inclusion-first-leaf.json +58 -0
  37. qed_proof-0.1.1/tests/vectors/017-inclusion-last-leaf.json +57 -0
  38. qed_proof-0.1.1/tests/vectors/018-inclusion-middle-leaf.json +58 -0
  39. qed_proof-0.1.1/tests/vectors/019-bad-inclusion-path.json +58 -0
  40. qed_proof-0.1.1/tests/vectors/020-wrong-leaf-index.json +58 -0
  41. qed_proof-0.1.1/tests/vectors/README.md +19 -0
  42. qed_proof-0.1.1/tests/vectors/keys.json +16 -0
  43. qed_proof-0.1.1/tests/vectors/manifest.json +386 -0
@@ -0,0 +1,5 @@
1
+ .venv/
2
+ dist/
3
+ __pycache__/
4
+ .pytest_cache/
5
+ *.egg-info/
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to `qed-proof` are documented here. This project follows
4
+ [Semantic Versioning](https://semver.org/).
5
+
6
+ ## [0.1.1] - 2026-09-27
7
+
8
+ The first version published to PyPI. 0.1.0 was tagged on the public repository but never
9
+ published; 0.1.1 has the same library code, released through the gated trusted-publishing workflow.
10
+
11
+ ## [0.1.0] - 2026-09-26 (never published)
12
+
13
+ Initial release.
14
+
15
+ ### Added
16
+
17
+ - `QedProof` / `AsyncQedProof` clients: `submit_claim`, `get_claim`, `wait_for_verdict`, `list_claims`,
18
+ `iter_claims`, `get_receipt`, `get_keys`, and a `verify` convenience method.
19
+ - `verify_receipt(receipt, keys, rpc_url=None) -> VerifyReport`: a self-contained, offline-capable
20
+ port of the PoAW reference checker (`check.py`, `anchor_check.py` and the `poaw_core` primitives).
21
+ Reproduces all 20 spec conformance vectors exactly.
22
+ - Typed action helpers in `qed_proof.actions` for `github.commit.push`, `github.pr.open`,
23
+ `github.checks.pass`, `x.post.publish`, `slack.message.post` and `http.url.status`.
24
+ - `qed_proof.types`: TypedDicts for the receipt shape, checked against the vendored JSON Schema.
25
+ - Optional `anchor` extra (`eth-abi`, `eth-hash`) for checking a receipt's on-chain EAS anchor against
26
+ a JSON-RPC endpoint.
27
+ - Errors: `QedProofError`, `QedProofRateLimited` (exposes `retry_after`), `QedProofTimeout`.
@@ -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,189 @@
1
+ Metadata-Version: 2.5
2
+ Name: qed-proof
3
+ Version: 0.1.1
4
+ Summary: Python SDK for QED Proof: submit claims, fetch receipts, and verify them offline against the PoAW receipt spec.
5
+ Project-URL: Homepage, https://docs.qedproof.site
6
+ Project-URL: Documentation, https://docs.qedproof.site
7
+ Project-URL: Source, https://github.com/Nuraveda-Labs/qed-proof-python
8
+ Author: Nuraveda Lab
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: cryptography>=43
22
+ Requires-Dist: httpx>=0.27
23
+ Requires-Dist: jsonschema>=4.23
24
+ Requires-Dist: rfc8785==0.1.4
25
+ Provides-Extra: anchor
26
+ Requires-Dist: eth-abi>=5; extra == 'anchor'
27
+ Requires-Dist: eth-hash[pycryptodome]>=0.7; extra == 'anchor'
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'test'
30
+ Requires-Dist: pytest>=8; extra == 'test'
31
+ Requires-Dist: respx>=0.21; extra == 'test'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # qed-proof
35
+
36
+ Copyright 2026 Nuraveda Lab
37
+
38
+ Python SDK for [QED Proof](https://docs.qedproof.site): submit a claim about work your agent did,
39
+ get back an independently-verified receipt, and check that receipt locally — with no further call
40
+ to QED Proof beyond fetching public keys (and, optionally, a public chain RPC for the on-chain
41
+ anchor).
42
+
43
+ A receipt verifies identically here, in the TypeScript SDK, and in the spec's own reference
44
+ `check.py` — this package's `verify_receipt` is a line-for-line port of that tool, proven against
45
+ the same 20-vector conformance suite.
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pip install qed-proof
51
+ # or, if you'll check an on-chain anchor:
52
+ pip install "qed-proof[anchor]"
53
+ ```
54
+
55
+ Requires Python 3.11+.
56
+
57
+ ## Quickstart
58
+
59
+ ```python
60
+ from qed_proof import QedProof, actions
61
+
62
+ qp = QedProof(api_key="qed_sk_...") # or set QED_PROOF_API_KEY
63
+
64
+ claim = qp.submit_claim(
65
+ actions.github_commit_push(target="owner/repo", sha="a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2", branch="main"),
66
+ agent_id="my-agent",
67
+ client_claim_id="deploy-42", # optional: resubmitting the same id returns the same claim (created=False)
68
+ )
69
+
70
+ result = qp.wait_for_verdict(claim.claim_id, timeout=120)
71
+ print(result.verdict) # "verified", "late", "mismatch", "failed" or "unverifiable"
72
+
73
+ receipt = qp.get_receipt(result.receipt_id) # no API key needed — receipts are public
74
+ ```
75
+
76
+ ## List claims
77
+
78
+ ```python
79
+ page = qp.list_claims(limit=50, agent_id="my-agent") # newest first
80
+ for claim in page.claims:
81
+ print(claim.claim_id, claim.state, claim.verdict)
82
+ page.next_cursor # str, or None if this was the last page
83
+
84
+ # or walk every matching claim, following next_cursor automatically:
85
+ for claim in qp.iter_claims(agent_id="my-agent", action="github.commit.push"):
86
+ print(claim.claim_id, claim.verdict)
87
+ ```
88
+
89
+ `limit` (1-200, default 50), `cursor`, `agent_id`, `action`, `verdict` and `state` are all optional
90
+ filters; `list_claims` raises `ValueError` locally if `limit` is out of range, before making a
91
+ request. `iter_claims` takes the same filters plus `page_size` (default 50).
92
+
93
+ ## Verify a receipt
94
+
95
+ A receipt is meant to be checked by anyone, offline, without trusting QED Proof at request time —
96
+ only its published Ed25519 keys.
97
+
98
+ ```python
99
+ from qed_proof import verify_receipt
100
+
101
+ keys = qp.get_keys() # GET /.well-known/poaw-keys.json — no API key needed
102
+ report = verify_receipt(receipt, keys)
103
+
104
+ report.valid # bool — every applicable check passed
105
+ report.verdict # the verdict, or None if invalid
106
+ report.achieved_trust_level # 0, 1 or 2 (2 needs inclusion + an on-chain anchor check)
107
+ report.checks # dict: spec_version, schema, integers_only, key, signature,
108
+ # claim_digest, inclusion, anchor — each True/False or a string
109
+ # reason ("absent", "not_checked_offline", or a failure code)
110
+ report.to_dict() # the same shape as the reference tool's JSON report
111
+ ```
112
+
113
+ Or in one call, using the client's own key fetch:
114
+
115
+ ```python
116
+ report = qp.verify(receipt)
117
+ ```
118
+
119
+ ### Checking the on-chain anchor
120
+
121
+ Some receipts include a Merkle inclusion proof anchored to an EAS attestation on Base. Checking that
122
+ against the chain needs the `anchor` extra and a JSON-RPC URL:
123
+
124
+ ```python
125
+ report = verify_receipt(receipt, keys, rpc_url="https://sepolia.base.org")
126
+ ```
127
+
128
+ Without `rpc_url`, an anchored receipt's `checks["anchor"]` reads `"not_checked_offline"` rather than
129
+ `True` — it's neither proven nor disproven. Any RPC error, decode error or mismatch fails the check
130
+ (`checks["anchor"]` becomes a reason string, e.g. `"root_mismatch"`) — it is never treated as a pass.
131
+ Calling `verify_receipt(..., rpc_url=...)` without the `anchor` extra installed raises a clear
132
+ `ImportError` telling you to `pip install "qed-proof[anchor]"`.
133
+
134
+ ## Self-hosted / a different node
135
+
136
+ Point the client at your own deployment instead of the default `https://api.qedproof.site`:
137
+
138
+ ```python
139
+ qp = QedProof(api_key="...", base_url="https://poaw.internal.example.com")
140
+ ```
141
+
142
+ ## Actions
143
+
144
+ Typed helpers build the `(action, target, params)` triple for the live verifier profiles, validating
145
+ what's cheap to check locally (a receipt's actual verdict is always decided by the destination, never
146
+ by the SDK):
147
+
148
+ ```python
149
+ from qed_proof import actions
150
+
151
+ actions.github_commit_push(target="owner/repo", sha="<40 hex>", branch="main")
152
+ actions.github_pr_open(target="owner/repo", number=42, base="main", head_sha="<40 hex>")
153
+ actions.github_checks_pass(target="owner/repo", sha="<40 hex>")
154
+ actions.x_post_publish(target="@handle", post_id="1234567890", text_sha256="<64 hex>")
155
+ actions.slack_message_post(target="slack://T0123456789/C0123456789", ts="1234567890.123456")
156
+ actions.http_url_status(target="https://example.com", status=200, content_fingerprint="sha256:...")
157
+ ```
158
+
159
+ Pass the result straight to `submit_claim`, or pass `action` (a string) with `target=` / `params=`
160
+ directly for an action this SDK doesn't yet have a helper for.
161
+
162
+ ## Async
163
+
164
+ `AsyncQedProof` mirrors the same surface over `httpx.AsyncClient`:
165
+
166
+ ```python
167
+ from qed_proof import AsyncQedProof
168
+
169
+ async with AsyncQedProof(api_key="...") as qp:
170
+ claim = await qp.submit_claim(..., agent_id="my-agent")
171
+ result = await qp.wait_for_verdict(claim.claim_id)
172
+ page = await qp.list_claims(agent_id="my-agent")
173
+ async for claim in qp.iter_claims(agent_id="my-agent"):
174
+ print(claim.claim_id)
175
+ ```
176
+
177
+ ## Errors
178
+
179
+ - `QedProofError(status_code, detail)` — any non-2xx response; `detail` is the API's own message.
180
+ The API key is never included in an exception's message, `repr`, or the client's own `repr`.
181
+ - `QedProofRateLimited` — a 429, subclassing `QedProofError`, with `.retry_after` (seconds, from the
182
+ `Retry-After` header, or `None`). `wait_for_verdict` handles this for you: it backs off by
183
+ `retry_after` and keeps polling rather than raising.
184
+ - `QedProofTimeout` — `wait_for_verdict` didn't see a decided claim within `timeout` seconds.
185
+
186
+ ## Links
187
+
188
+ - Docs: <https://docs.qedproof.site>
189
+ - License: Apache-2.0 (see `LICENSE`)
@@ -0,0 +1,156 @@
1
+ # qed-proof
2
+
3
+ Copyright 2026 Nuraveda Lab
4
+
5
+ Python SDK for [QED Proof](https://docs.qedproof.site): submit a claim about work your agent did,
6
+ get back an independently-verified receipt, and check that receipt locally — with no further call
7
+ to QED Proof beyond fetching public keys (and, optionally, a public chain RPC for the on-chain
8
+ anchor).
9
+
10
+ A receipt verifies identically here, in the TypeScript SDK, and in the spec's own reference
11
+ `check.py` — this package's `verify_receipt` is a line-for-line port of that tool, proven against
12
+ the same 20-vector conformance suite.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install qed-proof
18
+ # or, if you'll check an on-chain anchor:
19
+ pip install "qed-proof[anchor]"
20
+ ```
21
+
22
+ Requires Python 3.11+.
23
+
24
+ ## Quickstart
25
+
26
+ ```python
27
+ from qed_proof import QedProof, actions
28
+
29
+ qp = QedProof(api_key="qed_sk_...") # or set QED_PROOF_API_KEY
30
+
31
+ claim = qp.submit_claim(
32
+ actions.github_commit_push(target="owner/repo", sha="a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2", branch="main"),
33
+ agent_id="my-agent",
34
+ client_claim_id="deploy-42", # optional: resubmitting the same id returns the same claim (created=False)
35
+ )
36
+
37
+ result = qp.wait_for_verdict(claim.claim_id, timeout=120)
38
+ print(result.verdict) # "verified", "late", "mismatch", "failed" or "unverifiable"
39
+
40
+ receipt = qp.get_receipt(result.receipt_id) # no API key needed — receipts are public
41
+ ```
42
+
43
+ ## List claims
44
+
45
+ ```python
46
+ page = qp.list_claims(limit=50, agent_id="my-agent") # newest first
47
+ for claim in page.claims:
48
+ print(claim.claim_id, claim.state, claim.verdict)
49
+ page.next_cursor # str, or None if this was the last page
50
+
51
+ # or walk every matching claim, following next_cursor automatically:
52
+ for claim in qp.iter_claims(agent_id="my-agent", action="github.commit.push"):
53
+ print(claim.claim_id, claim.verdict)
54
+ ```
55
+
56
+ `limit` (1-200, default 50), `cursor`, `agent_id`, `action`, `verdict` and `state` are all optional
57
+ filters; `list_claims` raises `ValueError` locally if `limit` is out of range, before making a
58
+ request. `iter_claims` takes the same filters plus `page_size` (default 50).
59
+
60
+ ## Verify a receipt
61
+
62
+ A receipt is meant to be checked by anyone, offline, without trusting QED Proof at request time —
63
+ only its published Ed25519 keys.
64
+
65
+ ```python
66
+ from qed_proof import verify_receipt
67
+
68
+ keys = qp.get_keys() # GET /.well-known/poaw-keys.json — no API key needed
69
+ report = verify_receipt(receipt, keys)
70
+
71
+ report.valid # bool — every applicable check passed
72
+ report.verdict # the verdict, or None if invalid
73
+ report.achieved_trust_level # 0, 1 or 2 (2 needs inclusion + an on-chain anchor check)
74
+ report.checks # dict: spec_version, schema, integers_only, key, signature,
75
+ # claim_digest, inclusion, anchor — each True/False or a string
76
+ # reason ("absent", "not_checked_offline", or a failure code)
77
+ report.to_dict() # the same shape as the reference tool's JSON report
78
+ ```
79
+
80
+ Or in one call, using the client's own key fetch:
81
+
82
+ ```python
83
+ report = qp.verify(receipt)
84
+ ```
85
+
86
+ ### Checking the on-chain anchor
87
+
88
+ Some receipts include a Merkle inclusion proof anchored to an EAS attestation on Base. Checking that
89
+ against the chain needs the `anchor` extra and a JSON-RPC URL:
90
+
91
+ ```python
92
+ report = verify_receipt(receipt, keys, rpc_url="https://sepolia.base.org")
93
+ ```
94
+
95
+ Without `rpc_url`, an anchored receipt's `checks["anchor"]` reads `"not_checked_offline"` rather than
96
+ `True` — it's neither proven nor disproven. Any RPC error, decode error or mismatch fails the check
97
+ (`checks["anchor"]` becomes a reason string, e.g. `"root_mismatch"`) — it is never treated as a pass.
98
+ Calling `verify_receipt(..., rpc_url=...)` without the `anchor` extra installed raises a clear
99
+ `ImportError` telling you to `pip install "qed-proof[anchor]"`.
100
+
101
+ ## Self-hosted / a different node
102
+
103
+ Point the client at your own deployment instead of the default `https://api.qedproof.site`:
104
+
105
+ ```python
106
+ qp = QedProof(api_key="...", base_url="https://poaw.internal.example.com")
107
+ ```
108
+
109
+ ## Actions
110
+
111
+ Typed helpers build the `(action, target, params)` triple for the live verifier profiles, validating
112
+ what's cheap to check locally (a receipt's actual verdict is always decided by the destination, never
113
+ by the SDK):
114
+
115
+ ```python
116
+ from qed_proof import actions
117
+
118
+ actions.github_commit_push(target="owner/repo", sha="<40 hex>", branch="main")
119
+ actions.github_pr_open(target="owner/repo", number=42, base="main", head_sha="<40 hex>")
120
+ actions.github_checks_pass(target="owner/repo", sha="<40 hex>")
121
+ actions.x_post_publish(target="@handle", post_id="1234567890", text_sha256="<64 hex>")
122
+ actions.slack_message_post(target="slack://T0123456789/C0123456789", ts="1234567890.123456")
123
+ actions.http_url_status(target="https://example.com", status=200, content_fingerprint="sha256:...")
124
+ ```
125
+
126
+ Pass the result straight to `submit_claim`, or pass `action` (a string) with `target=` / `params=`
127
+ directly for an action this SDK doesn't yet have a helper for.
128
+
129
+ ## Async
130
+
131
+ `AsyncQedProof` mirrors the same surface over `httpx.AsyncClient`:
132
+
133
+ ```python
134
+ from qed_proof import AsyncQedProof
135
+
136
+ async with AsyncQedProof(api_key="...") as qp:
137
+ claim = await qp.submit_claim(..., agent_id="my-agent")
138
+ result = await qp.wait_for_verdict(claim.claim_id)
139
+ page = await qp.list_claims(agent_id="my-agent")
140
+ async for claim in qp.iter_claims(agent_id="my-agent"):
141
+ print(claim.claim_id)
142
+ ```
143
+
144
+ ## Errors
145
+
146
+ - `QedProofError(status_code, detail)` — any non-2xx response; `detail` is the API's own message.
147
+ The API key is never included in an exception's message, `repr`, or the client's own `repr`.
148
+ - `QedProofRateLimited` — a 429, subclassing `QedProofError`, with `.retry_after` (seconds, from the
149
+ `Retry-After` header, or `None`). `wait_for_verdict` handles this for you: it backs off by
150
+ `retry_after` and keeps polling rather than raising.
151
+ - `QedProofTimeout` — `wait_for_verdict` didn't see a decided claim within `timeout` seconds.
152
+
153
+ ## Links
154
+
155
+ - Docs: <https://docs.qedproof.site>
156
+ - License: Apache-2.0 (see `LICENSE`)
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "qed-proof"
7
+ version = "0.1.1"
8
+ description = "Python SDK for QED Proof: submit claims, fetch receipts, and verify them offline against the PoAW receipt spec."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Nuraveda Lab" }]
13
+ requires-python = ">=3.11"
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ "Typing :: Typed",
24
+ ]
25
+ dependencies = [
26
+ "httpx>=0.27",
27
+ "cryptography>=43",
28
+ "rfc8785==0.1.4",
29
+ "jsonschema>=4.23",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://docs.qedproof.site"
34
+ Documentation = "https://docs.qedproof.site"
35
+ Source = "https://github.com/Nuraveda-Labs/qed-proof-python"
36
+
37
+ [project.optional-dependencies]
38
+ anchor = [
39
+ "eth-abi>=5",
40
+ "eth-hash[pycryptodome]>=0.7",
41
+ ]
42
+ test = [
43
+ "pytest>=8",
44
+ "pytest-asyncio>=0.24",
45
+ "respx>=0.21",
46
+ ]
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/qed_proof"]
50
+
51
+ [tool.hatch.build.targets.sdist]
52
+ include = ["src", "tests", "README.md", "CHANGELOG.md", "LICENSE"]
53
+
54
+ [tool.pytest.ini_options]
55
+ asyncio_mode = "auto"
56
+ testpaths = ["tests"]
@@ -0,0 +1,42 @@
1
+ """qed-proof: the Python SDK for QED Proof.
2
+
3
+ from qed_proof import QedProof, actions, verify_receipt
4
+
5
+ qp = QedProof(api_key="qed_sk_...")
6
+ claim = qp.submit_claim(actions.github_commit_push(target="owner/repo", sha="...", branch="main"),
7
+ agent_id="my-agent")
8
+ result = qp.wait_for_verdict(claim.claim_id)
9
+ receipt = qp.get_receipt(result.receipt_id)
10
+ report = verify_receipt(receipt, keys=qp.get_keys())
11
+ """
12
+ from __future__ import annotations
13
+
14
+ from . import actions
15
+ from .actions import Action
16
+ from .client import (
17
+ AsyncQedProof,
18
+ ClaimPage,
19
+ ClaimResult,
20
+ QedProof,
21
+ QedProofError,
22
+ QedProofRateLimited,
23
+ QedProofTimeout,
24
+ )
25
+ from .verify import VerifyReport, verify_receipt
26
+
27
+ __version__ = "0.1.1"
28
+
29
+ __all__ = [
30
+ "Action",
31
+ "actions",
32
+ "AsyncQedProof",
33
+ "ClaimPage",
34
+ "ClaimResult",
35
+ "QedProof",
36
+ "QedProofError",
37
+ "QedProofRateLimited",
38
+ "QedProofTimeout",
39
+ "VerifyReport",
40
+ "verify_receipt",
41
+ "__version__",
42
+ ]