zanii-certify 0.5.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 (100) hide show
  1. zanii_certify-0.5.0/.gitignore +15 -0
  2. zanii_certify-0.5.0/LICENSE +159 -0
  3. zanii_certify-0.5.0/PKG-INFO +145 -0
  4. zanii_certify-0.5.0/README.md +127 -0
  5. zanii_certify-0.5.0/pyproject.toml +32 -0
  6. zanii_certify-0.5.0/src/zanii_certify/__init__.py +537 -0
  7. zanii_certify-0.5.0/src/zanii_certify/_shared.py +89 -0
  8. zanii_certify-0.5.0/src/zanii_certify/_verification_bounds.py +67 -0
  9. zanii_certify-0.5.0/src/zanii_certify/appliance.py +321 -0
  10. zanii_certify-0.5.0/src/zanii_certify/appliance_execution.py +24 -0
  11. zanii_certify-0.5.0/src/zanii_certify/assurance_status.py +128 -0
  12. zanii_certify-0.5.0/src/zanii_certify/audit.py +127 -0
  13. zanii_certify-0.5.0/src/zanii_certify/audit_renewal.py +86 -0
  14. zanii_certify-0.5.0/src/zanii_certify/beacon.py +146 -0
  15. zanii_certify-0.5.0/src/zanii_certify/beacon_client.py +115 -0
  16. zanii_certify-0.5.0/src/zanii_certify/bitstring_status.py +172 -0
  17. zanii_certify-0.5.0/src/zanii_certify/board.py +540 -0
  18. zanii_certify-0.5.0/src/zanii_certify/bundle.py +148 -0
  19. zanii_certify-0.5.0/src/zanii_certify/certificate.py +416 -0
  20. zanii_certify-0.5.0/src/zanii_certify/cli-messages.json +148 -0
  21. zanii_certify-0.5.0/src/zanii_certify/cli.py +396 -0
  22. zanii_certify-0.5.0/src/zanii_certify/current_issuer_vc.py +83 -0
  23. zanii_certify-0.5.0/src/zanii_certify/evidence_share.py +553 -0
  24. zanii_certify-0.5.0/src/zanii_certify/federation.py +263 -0
  25. zanii_certify-0.5.0/src/zanii_certify/feed_snapshot.py +209 -0
  26. zanii_certify-0.5.0/src/zanii_certify/fingerprint.py +58 -0
  27. zanii_certify-0.5.0/src/zanii_certify/formats/board-transition.schema.json +30 -0
  28. zanii_certify-0.5.0/src/zanii_certify/formats/scheme-text.schema.json +26 -0
  29. zanii_certify-0.5.0/src/zanii_certify/formats/status-v2.schema.json +31 -0
  30. zanii_certify-0.5.0/src/zanii_certify/governance.py +501 -0
  31. zanii_certify-0.5.0/src/zanii_certify/identity.py +186 -0
  32. zanii_certify-0.5.0/src/zanii_certify/impartiality.py +104 -0
  33. zanii_certify-0.5.0/src/zanii_certify/issuer_authorization.py +68 -0
  34. zanii_certify-0.5.0/src/zanii_certify/issuer_resolution.py +112 -0
  35. zanii_certify-0.5.0/src/zanii_certify/licence.py +497 -0
  36. zanii_certify-0.5.0/src/zanii_certify/licence_owner.py +241 -0
  37. zanii_certify-0.5.0/src/zanii_certify/licence_owner_entry.py +46 -0
  38. zanii_certify-0.5.0/src/zanii_certify/live_evidence.py +261 -0
  39. zanii_certify-0.5.0/src/zanii_certify/normalization.py +19 -0
  40. zanii_certify-0.5.0/src/zanii_certify/pq.py +107 -0
  41. zanii_certify-0.5.0/src/zanii_certify/profile.py +182 -0
  42. zanii_certify-0.5.0/src/zanii_certify/py.typed +0 -0
  43. zanii_certify-0.5.0/src/zanii_certify/register.py +172 -0
  44. zanii_certify-0.5.0/src/zanii_certify/rotation.py +123 -0
  45. zanii_certify-0.5.0/src/zanii_certify/royalty_reconciliation.py +98 -0
  46. zanii_certify-0.5.0/src/zanii_certify/runtime.py +432 -0
  47. zanii_certify-0.5.0/src/zanii_certify/runtime_knowledge.py +97 -0
  48. zanii_certify-0.5.0/src/zanii_certify/sandbox_delegation.py +81 -0
  49. zanii_certify-0.5.0/src/zanii_certify/schema_dialect.py +102 -0
  50. zanii_certify-0.5.0/src/zanii_certify/schemas/clause-map.schema.json +52 -0
  51. zanii_certify-0.5.0/src/zanii_certify/schemas/profile.schema.json +80 -0
  52. zanii_certify-0.5.0/src/zanii_certify/schemas/scenarios.schema.json +573 -0
  53. zanii_certify-0.5.0/src/zanii_certify/schemas/suite.schema.json +138 -0
  54. zanii_certify-0.5.0/src/zanii_certify/scheme_authority.py +19 -0
  55. zanii_certify-0.5.0/src/zanii_certify/scheme_entry.py +101 -0
  56. zanii_certify-0.5.0/src/zanii_certify/scheme_history.py +81 -0
  57. zanii_certify-0.5.0/src/zanii_certify/scheme_log.py +371 -0
  58. zanii_certify-0.5.0/src/zanii_certify/scheme_merkle.py +24 -0
  59. zanii_certify-0.5.0/src/zanii_certify/scheme_text.py +77 -0
  60. zanii_certify-0.5.0/src/zanii_certify/scheme_timing.py +28 -0
  61. zanii_certify-0.5.0/src/zanii_certify/scheme_transition.py +119 -0
  62. zanii_certify-0.5.0/src/zanii_certify/scoring.py +52 -0
  63. zanii_certify-0.5.0/src/zanii_certify/signer.py +69 -0
  64. zanii_certify-0.5.0/src/zanii_certify/signing_identity.py +22 -0
  65. zanii_certify-0.5.0/src/zanii_certify/status.py +235 -0
  66. zanii_certify-0.5.0/src/zanii_certify/succession.py +94 -0
  67. zanii_certify-0.5.0/src/zanii_certify/suite.py +509 -0
  68. zanii_certify-0.5.0/src/zanii_certify/vc.py +97 -0
  69. zanii_certify-0.5.0/src/zanii_certify/verification_policy.py +108 -0
  70. zanii_certify-0.5.0/src/zanii_certify/witness.py +125 -0
  71. zanii_certify-0.5.0/tests/test_assurance_status.py +106 -0
  72. zanii_certify-0.5.0/tests/test_audit_renewal.py +125 -0
  73. zanii_certify-0.5.0/tests/test_beacon_client.py +84 -0
  74. zanii_certify-0.5.0/tests/test_bitstring_status.py +100 -0
  75. zanii_certify-0.5.0/tests/test_certify.py +255 -0
  76. zanii_certify-0.5.0/tests/test_cli_policy.py +112 -0
  77. zanii_certify-0.5.0/tests/test_current_issuer_vc.py +150 -0
  78. zanii_certify-0.5.0/tests/test_evidence_share_scale.py +82 -0
  79. zanii_certify-0.5.0/tests/test_federation_incremental.py +43 -0
  80. zanii_certify-0.5.0/tests/test_feed_snapshot.py +83 -0
  81. zanii_certify-0.5.0/tests/test_frozen_scheme_text.py +16 -0
  82. zanii_certify-0.5.0/tests/test_licence_owner.py +128 -0
  83. zanii_certify-0.5.0/tests/test_licence_owner_entry.py +29 -0
  84. zanii_certify-0.5.0/tests/test_licence_owner_royalty.py +34 -0
  85. zanii_certify-0.5.0/tests/test_normalization_policy.py +43 -0
  86. zanii_certify-0.5.0/tests/test_p1.py +65 -0
  87. zanii_certify-0.5.0/tests/test_p2.py +92 -0
  88. zanii_certify-0.5.0/tests/test_royalty_proposal.py +41 -0
  89. zanii_certify-0.5.0/tests/test_royalty_reconciliation.py +102 -0
  90. zanii_certify-0.5.0/tests/test_runtime.py +176 -0
  91. zanii_certify-0.5.0/tests/test_runtime_knowledge.py +134 -0
  92. zanii_certify-0.5.0/tests/test_sandbox_team.py +108 -0
  93. zanii_certify-0.5.0/tests/test_schema_dialect.py +67 -0
  94. zanii_certify-0.5.0/tests/test_scheme_entry.py +50 -0
  95. zanii_certify-0.5.0/tests/test_scheme_text.py +74 -0
  96. zanii_certify-0.5.0/tests/test_scheme_timing.py +23 -0
  97. zanii_certify-0.5.0/tests/test_scheme_transition.py +82 -0
  98. zanii_certify-0.5.0/tests/test_signing_identity.py +62 -0
  99. zanii_certify-0.5.0/tests/test_status_v2.py +96 -0
  100. zanii_certify-0.5.0/tests/test_verification_policy.py +143 -0
@@ -0,0 +1,15 @@
1
+ node_modules/
2
+ .venv/
3
+ dist/
4
+ __pycache__/
5
+ *.db
6
+ *.db-*
7
+ .env*
8
+ secrets/
9
+ sectrets/
10
+ .data/
11
+ .pytest_cache/
12
+ .ruff_cache/
13
+ *.rar
14
+ *.zip
15
+ *.7z
@@ -0,0 +1,159 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work; and
103
+
104
+ (d) If the Work includes a "NOTICE" text file as part of its
105
+ distribution, then any Derivative Works that You distribute must
106
+ include a readable copy of the attribution notices contained
107
+ within such NOTICE file.
108
+
109
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
110
+ any Contribution intentionally submitted for inclusion in the Work
111
+ by You to the Licensor shall be under the terms and conditions of
112
+ this License, without any additional terms or conditions.
113
+
114
+ 6. Trademarks. This License does not grant permission to use the trade
115
+ names, trademarks, service marks, or product names of the Licensor,
116
+ except as required for reasonable and customary use in describing the
117
+ origin of the Work and reproducing the content of the NOTICE file.
118
+
119
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed
120
+ to in writing, Licensor provides the Work (and each Contributor
121
+ provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
122
+ OR CONDITIONS OF ANY KIND, either express or implied, including,
123
+ without limitation, any warranties or conditions of TITLE,
124
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
125
+
126
+ 8. Limitation of Liability. In no event and under no legal theory,
127
+ whether in tort (including negligence), contract, or otherwise,
128
+ unless required by applicable law (such as deliberate and grossly
129
+ negligent acts) or agreed to in writing, shall any Contributor be
130
+ liable to You for damages, including any direct, indirect, special,
131
+ incidental, or consequential damages of any character arising as a
132
+ result of this License or out of the use or inability to use the
133
+ Work.
134
+
135
+ 9. Accepting Warranty or Additional Liability. While redistributing
136
+ the Work or Derivative Works thereof, You may choose to offer,
137
+ and charge a fee for, acceptance of support, warranty, indemnity,
138
+ or other liability obligations and/or rights consistent with this
139
+ License. However, in accepting such obligations, You may act only
140
+ on Your own behalf and on Your sole responsibility, not on behalf
141
+ of any other Contributor, and only if You agree to indemnify,
142
+ defend, and hold each Contributor harmless for any liability
143
+ incurred by, or claims asserted against, such Contributor.
144
+
145
+ END OF TERMS AND CONDITIONS
146
+
147
+ Copyright 2026 Zanii
148
+
149
+ Licensed under the Apache License, Version 2.0 (the "License");
150
+ you may not use this file except in compliance with the License.
151
+ You may obtain a copy of the License at
152
+
153
+ http://www.apache.org/licenses/LICENSE-2.0
154
+
155
+ Unless required by applicable law or agreed to in writing, software
156
+ distributed under the License is distributed on an "AS IS" BASIS,
157
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
158
+ See the License for the specific language governing permissions and
159
+ limitations under the License.
@@ -0,0 +1,145 @@
1
+ Metadata-Version: 2.5
2
+ Name: zanii-certify
3
+ Version: 0.5.0
4
+ Summary: Build and verify Zanii Certify certificates for AI agents: fingerprints, signed certificates, status documents, test suites and the certify command line tool.
5
+ Project-URL: Homepage, https://zanii.agency
6
+ Author-email: Zanii <info@zanii.agency>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Keywords: ai-agents,ai-assurance,arabic,certification,ed25519,post-quantum,verifiable-credentials,zanii
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Security :: Cryptography
14
+ Requires-Python: >=3.11
15
+ Requires-Dist: zanii-blackbox<0.24,>=0.23.0
16
+ Requires-Dist: zanii[pq]<0.27,>=0.26.2
17
+ Description-Content-Type: text/markdown
18
+
19
+ # zanii-certify
20
+
21
+ Python SDK and `certify` CLI for Zanii Certify fingerprints, signed certificates,
22
+ status, evidence sharing, runtime assurance and scheme governance. Requires Python
23
+ 3.11 or newer. Public functions are exported by the `zanii_certify` module; common
24
+ signed formats are checked against the TypeScript SDK (`@zanii/certify` on npm) using
25
+ shared vectors.
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pip install zanii-certify
31
+ certify verify cert.json --online https://lab.zanii.agency
32
+ ```
33
+
34
+ Certificate, status and signature checks work on every supported Python. The strict
35
+ text-normalisation policy used to grade test suites pins the Unicode version and
36
+ currently supports Unicode 16 and 17 (Python 3.14 or newer); on an older Python it
37
+ reports the policy as unsupported instead of grading with different Unicode tables.
38
+
39
+ Paths in backticks below (`spec/...`, `conformance/...`) are files of the Zanii Certify source repository, which is private; the specification documents are available from Zanii on request (info@zanii.agency).
40
+
41
+ ## Use this checkout
42
+
43
+ From the repository root, install the locked workspace and inspect the current CLI:
44
+
45
+ ```sh
46
+ uv sync --frozen
47
+ uv run certify --help-v2
48
+ ```
49
+
50
+ Save this as `example.py` at the repository root and run `uv run python example.py`.
51
+ It needs no server, network access or signing key:
52
+
53
+ ```python
54
+ from zanii_certify import (
55
+ build_fingerprint,
56
+ check_fingerprint,
57
+ prompt_sha256,
58
+ runtime_request_hash,
59
+ sha256_bytes,
60
+ )
61
+
62
+ fingerprint = build_fingerprint(
63
+ model="example-model@1",
64
+ prompt=prompt_sha256("Answer using the approved policy."),
65
+ tools=None,
66
+ policy=None,
67
+ knowledge=None,
68
+ )
69
+ assert check_fingerprint(fingerprint)
70
+ print(fingerprint["id"])
71
+
72
+ # Commit the exact request body bytes; this hash alone grants no permission.
73
+ body = '{"amount_minor":100,"currency":"USD"}'
74
+ print(runtime_request_hash({
75
+ "method": "POST",
76
+ "url": "https://bank.example/payments",
77
+ "body_sha256": sha256_bytes(body),
78
+ }))
79
+ ```
80
+
81
+ This produces the same two hashes as the
82
+ TypeScript example (`packages/certify/README.md`). Fingerprint inputs contain
83
+ hashes or `None`, rather than raw prompts/documents. Keep the original bytes:
84
+ changing whitespace can change a commitment.
85
+
86
+ ## Verification policy
87
+
88
+ `verify_certificate(certificate, **options)` is synchronous and returns a dictionary
89
+ with `ok` and `reasons`. Optional checks run when their inputs/policies are supplied;
90
+ an `ok` result alone does not mean every relying-party requirement was checked.
91
+
92
+ - Supply fresh signed `status` and `revocation_list`, the expected `fingerprint`,
93
+ and `now` when a reproducible verification time is required.
94
+ - Supply an independently approved `issuer_policy` and corresponding `issuer_doc`.
95
+ Downloaded metadata cannot nominate trusted keys. Key/PQ changes require local
96
+ review; `allow_no_pq` cannot override the pinned policy.
97
+ - Supply `pq`/`status_pq` when required. For Level 3, supply the audit plus
98
+ `trusted_bodies` or an independently rooted `body_register`. Add witness,
99
+ licence and release policies where required. Strict withdrawal checking uses
100
+ the withdrawal log and `releases["rejectWithdrawn"] = True`; signed JSON policy
101
+ field names retain their wire spelling, even in Python.
102
+
103
+ See the full verify_certificate signature (`python/src/zanii_certify/certificate.py`),
104
+ policy tests (`python/tests/test_verification_policy.py`) and
105
+ certificate contract (`spec/certificate.md`). Legacy optional behavior remains
106
+ for compatibility; choose your relying-party policy explicitly. Offline evidence
107
+ cannot reveal an undisclosed newer checkpoint or revocation.
108
+
109
+ The CLI is offline by default. `--help-v2` lists current strict-policy, audit,
110
+ witness and release options. `--online` enables bounded retrieval, including
111
+ required PQ material. Accept only exit code 0 when every CLI check is required;
112
+ exit code 2 means not fully checked. See the CLI contract (`spec/cli.md`).
113
+ Python issuer retrieval uses at most four daemon-worker slots; a timed-out
114
+ standard-library request may occupy its slot until it finishes.
115
+
116
+ ## Contracts and limits
117
+
118
+ | Area | Contract |
119
+ | --- | --- |
120
+ | Fingerprints and certificates | Fingerprint (`spec/fingerprint.md`), certificate (`spec/certificate.md`) |
121
+ | Status and freshness | Status v1/v2 (`spec/status.md`), witnesses (`spec/witness.md`), Bitstring Status List (`spec/bitstring-status.md`), assurance withdrawal (`spec/assurance-status.md`) |
122
+ | Runtime releases, mandates, leases and knowledge proofs | Runtime assurance (`spec/runtime.md`) |
123
+ | Scheme releases, exact text and transitions | Scheme (`spec/scheme.md`), immutable text (`spec/scheme-text.md`), checkpointed log (`spec/scheme-log.md`) |
124
+ | Redacted evidence and inclusion proofs | Evidence sharing (`spec/evidence-share.md`) |
125
+
126
+ Format-specific byte/count limits bound builders and verifiers. Preserve trusted
127
+ freshness watermarks independently when the contract requires them. An inclusion
128
+ proof establishes commitment, not content truth, ACL permission or quality.
129
+ Node-only Nitro verification, runtime reporter and reference HTTP gateway are
130
+ not exported by this Python package.
131
+
132
+ ## Check changes
133
+
134
+ Run from the repository root:
135
+
136
+ ```sh
137
+ uv run pytest python/tests
138
+ uv run pytest python/tests/test_verification_policy.py
139
+ uv run ruff check python
140
+ ```
141
+
142
+ Shared vectors (`spec/vectors`) and conformance tests (`conformance`) verify
143
+ the common wire formats and preserve old signed bytes when adding new versions.
144
+ Local SDK tests do not qualify deployment security or capacity; see the
145
+ readiness report (`docs/readiness-report.md`).
@@ -0,0 +1,127 @@
1
+ # zanii-certify
2
+
3
+ Python SDK and `certify` CLI for Zanii Certify fingerprints, signed certificates,
4
+ status, evidence sharing, runtime assurance and scheme governance. Requires Python
5
+ 3.11 or newer. Public functions are exported by the `zanii_certify` module; common
6
+ signed formats are checked against the TypeScript SDK (`@zanii/certify` on npm) using
7
+ shared vectors.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pip install zanii-certify
13
+ certify verify cert.json --online https://lab.zanii.agency
14
+ ```
15
+
16
+ Certificate, status and signature checks work on every supported Python. The strict
17
+ text-normalisation policy used to grade test suites pins the Unicode version and
18
+ currently supports Unicode 16 and 17 (Python 3.14 or newer); on an older Python it
19
+ reports the policy as unsupported instead of grading with different Unicode tables.
20
+
21
+ Paths in backticks below (`spec/...`, `conformance/...`) are files of the Zanii Certify source repository, which is private; the specification documents are available from Zanii on request (info@zanii.agency).
22
+
23
+ ## Use this checkout
24
+
25
+ From the repository root, install the locked workspace and inspect the current CLI:
26
+
27
+ ```sh
28
+ uv sync --frozen
29
+ uv run certify --help-v2
30
+ ```
31
+
32
+ Save this as `example.py` at the repository root and run `uv run python example.py`.
33
+ It needs no server, network access or signing key:
34
+
35
+ ```python
36
+ from zanii_certify import (
37
+ build_fingerprint,
38
+ check_fingerprint,
39
+ prompt_sha256,
40
+ runtime_request_hash,
41
+ sha256_bytes,
42
+ )
43
+
44
+ fingerprint = build_fingerprint(
45
+ model="example-model@1",
46
+ prompt=prompt_sha256("Answer using the approved policy."),
47
+ tools=None,
48
+ policy=None,
49
+ knowledge=None,
50
+ )
51
+ assert check_fingerprint(fingerprint)
52
+ print(fingerprint["id"])
53
+
54
+ # Commit the exact request body bytes; this hash alone grants no permission.
55
+ body = '{"amount_minor":100,"currency":"USD"}'
56
+ print(runtime_request_hash({
57
+ "method": "POST",
58
+ "url": "https://bank.example/payments",
59
+ "body_sha256": sha256_bytes(body),
60
+ }))
61
+ ```
62
+
63
+ This produces the same two hashes as the
64
+ TypeScript example (`packages/certify/README.md`). Fingerprint inputs contain
65
+ hashes or `None`, rather than raw prompts/documents. Keep the original bytes:
66
+ changing whitespace can change a commitment.
67
+
68
+ ## Verification policy
69
+
70
+ `verify_certificate(certificate, **options)` is synchronous and returns a dictionary
71
+ with `ok` and `reasons`. Optional checks run when their inputs/policies are supplied;
72
+ an `ok` result alone does not mean every relying-party requirement was checked.
73
+
74
+ - Supply fresh signed `status` and `revocation_list`, the expected `fingerprint`,
75
+ and `now` when a reproducible verification time is required.
76
+ - Supply an independently approved `issuer_policy` and corresponding `issuer_doc`.
77
+ Downloaded metadata cannot nominate trusted keys. Key/PQ changes require local
78
+ review; `allow_no_pq` cannot override the pinned policy.
79
+ - Supply `pq`/`status_pq` when required. For Level 3, supply the audit plus
80
+ `trusted_bodies` or an independently rooted `body_register`. Add witness,
81
+ licence and release policies where required. Strict withdrawal checking uses
82
+ the withdrawal log and `releases["rejectWithdrawn"] = True`; signed JSON policy
83
+ field names retain their wire spelling, even in Python.
84
+
85
+ See the full verify_certificate signature (`python/src/zanii_certify/certificate.py`),
86
+ policy tests (`python/tests/test_verification_policy.py`) and
87
+ certificate contract (`spec/certificate.md`). Legacy optional behavior remains
88
+ for compatibility; choose your relying-party policy explicitly. Offline evidence
89
+ cannot reveal an undisclosed newer checkpoint or revocation.
90
+
91
+ The CLI is offline by default. `--help-v2` lists current strict-policy, audit,
92
+ witness and release options. `--online` enables bounded retrieval, including
93
+ required PQ material. Accept only exit code 0 when every CLI check is required;
94
+ exit code 2 means not fully checked. See the CLI contract (`spec/cli.md`).
95
+ Python issuer retrieval uses at most four daemon-worker slots; a timed-out
96
+ standard-library request may occupy its slot until it finishes.
97
+
98
+ ## Contracts and limits
99
+
100
+ | Area | Contract |
101
+ | --- | --- |
102
+ | Fingerprints and certificates | Fingerprint (`spec/fingerprint.md`), certificate (`spec/certificate.md`) |
103
+ | Status and freshness | Status v1/v2 (`spec/status.md`), witnesses (`spec/witness.md`), Bitstring Status List (`spec/bitstring-status.md`), assurance withdrawal (`spec/assurance-status.md`) |
104
+ | Runtime releases, mandates, leases and knowledge proofs | Runtime assurance (`spec/runtime.md`) |
105
+ | Scheme releases, exact text and transitions | Scheme (`spec/scheme.md`), immutable text (`spec/scheme-text.md`), checkpointed log (`spec/scheme-log.md`) |
106
+ | Redacted evidence and inclusion proofs | Evidence sharing (`spec/evidence-share.md`) |
107
+
108
+ Format-specific byte/count limits bound builders and verifiers. Preserve trusted
109
+ freshness watermarks independently when the contract requires them. An inclusion
110
+ proof establishes commitment, not content truth, ACL permission or quality.
111
+ Node-only Nitro verification, runtime reporter and reference HTTP gateway are
112
+ not exported by this Python package.
113
+
114
+ ## Check changes
115
+
116
+ Run from the repository root:
117
+
118
+ ```sh
119
+ uv run pytest python/tests
120
+ uv run pytest python/tests/test_verification_policy.py
121
+ uv run ruff check python
122
+ ```
123
+
124
+ Shared vectors (`spec/vectors`) and conformance tests (`conformance`) verify
125
+ the common wire formats and preserve old signed bytes when adding new versions.
126
+ Local SDK tests do not qualify deployment security or capacity; see the
127
+ readiness report (`docs/readiness-report.md`).
@@ -0,0 +1,32 @@
1
+ [project]
2
+ name = "zanii-certify"
3
+ version = "0.5.0"
4
+ description = "Build and verify Zanii Certify certificates for AI agents: fingerprints, signed certificates, status documents, test suites and the certify command line tool."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ authors = [{ name = "Zanii", email = "info@zanii.agency" }]
8
+ requires-python = ">=3.11"
9
+ keywords = ["ai-agents", "certification", "verifiable-credentials", "ai-assurance", "ed25519", "post-quantum", "arabic", "zanii"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "Programming Language :: Python :: 3",
14
+ "Topic :: Security :: Cryptography",
15
+ ]
16
+ dependencies = [
17
+ "zanii[pq]>=0.26.2,<0.27",
18
+ "zanii-blackbox>=0.23.0,<0.24",
19
+ ]
20
+
21
+ [project.scripts]
22
+ certify = "zanii_certify.cli:main"
23
+
24
+ [project.urls]
25
+ Homepage = "https://zanii.agency"
26
+
27
+ [build-system]
28
+ requires = ["hatchling"]
29
+ build-backend = "hatchling.build"
30
+
31
+ [tool.hatch.build.targets.wheel]
32
+ packages = ["src/zanii_certify"]