zeroproof 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.
- zeroproof-0.1.0/LICENSE +21 -0
- zeroproof-0.1.0/MANIFEST.in +5 -0
- zeroproof-0.1.0/PKG-INFO +361 -0
- zeroproof-0.1.0/README.md +320 -0
- zeroproof-0.1.0/examples/shopping_agent_demo.py +221 -0
- zeroproof-0.1.0/pyproject.toml +72 -0
- zeroproof-0.1.0/requirements.txt +1 -0
- zeroproof-0.1.0/setup.cfg +4 -0
- zeroproof-0.1.0/setup.py +57 -0
- zeroproof-0.1.0/zeroproof/__init__.py +12 -0
- zeroproof-0.1.0/zeroproof/client.py +275 -0
- zeroproof-0.1.0/zeroproof.egg-info/PKG-INFO +361 -0
- zeroproof-0.1.0/zeroproof.egg-info/SOURCES.txt +14 -0
- zeroproof-0.1.0/zeroproof.egg-info/dependency_links.txt +1 -0
- zeroproof-0.1.0/zeroproof.egg-info/requires.txt +9 -0
- zeroproof-0.1.0/zeroproof.egg-info/top_level.txt +1 -0
zeroproof-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ZeroProof AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
zeroproof-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zeroproof
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for ZeroProof AI verification API - Secure your agentic e-commerce ecosystem
|
|
5
|
+
Home-page: https://github.com/jacobweiss2305/zeroproof
|
|
6
|
+
Author: ZeroProof AI
|
|
7
|
+
Author-email: ZeroProof AI <support@zeroproofai.com>
|
|
8
|
+
Maintainer-email: ZeroProof AI <support@zeroproofai.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/jacobweiss2305/zeroproof
|
|
11
|
+
Project-URL: Documentation, https://docs.zeroproofai.com
|
|
12
|
+
Project-URL: Repository, https://github.com/jacobweiss2305/zeroproof
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/jacobweiss2305/zeroproof/issues
|
|
14
|
+
Keywords: zeroproof,ai,verification,zkp,zero-knowledge-proof,agent,security,ecommerce
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Topic :: Security :: Cryptography
|
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: requests>=2.25.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: mypy>=0.950; extra == "dev"
|
|
36
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
37
|
+
Dynamic: author
|
|
38
|
+
Dynamic: home-page
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
Dynamic: requires-python
|
|
41
|
+
|
|
42
|
+
# ZeroProof Python SDK
|
|
43
|
+
|
|
44
|
+
[](https://badge.fury.io/py/zeroproof)
|
|
45
|
+
[](https://www.python.org/downloads/)
|
|
46
|
+
[](https://opensource.org/licenses/MIT)
|
|
47
|
+
|
|
48
|
+
Python SDK for the ZeroProof AI verification API. Secure your agentic e-commerce ecosystem with zero-knowledge proofs.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install zeroproof
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from zeroproof import ZeroProof
|
|
60
|
+
|
|
61
|
+
# Initialize the client with your API key
|
|
62
|
+
client = ZeroProof(api_key="zkp_your_api_key_here")
|
|
63
|
+
|
|
64
|
+
# Create a verification challenge
|
|
65
|
+
challenge = client.create_challenge(
|
|
66
|
+
agent_id="shopping-assistant-v1",
|
|
67
|
+
action="add_to_cart",
|
|
68
|
+
context={"item_id": "laptop-123", "price": 999.99}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
print(f"Challenge ID: {challenge.challenge_id}")
|
|
72
|
+
print(f"Nonce: {challenge.nonce}")
|
|
73
|
+
print(f"Expires in: {challenge.expires_in} seconds")
|
|
74
|
+
|
|
75
|
+
# Verify the proof (in production, this would be generated by your agent)
|
|
76
|
+
result = client.verify_proof(
|
|
77
|
+
challenge_id=challenge.challenge_id,
|
|
78
|
+
proof="your_cryptographic_proof_here",
|
|
79
|
+
agent_signature="optional_signature_here"
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if result.verified:
|
|
83
|
+
print(f"✅ Verification successful!")
|
|
84
|
+
print(f" Agent: {result.agent_id}")
|
|
85
|
+
print(f" Action: {result.action}")
|
|
86
|
+
print(f" Confidence: {result.confidence * 100}%")
|
|
87
|
+
# Now execute the actual e-commerce action
|
|
88
|
+
else:
|
|
89
|
+
print("❌ Verification failed")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Use Cases
|
|
93
|
+
|
|
94
|
+
### E-Commerce Agent Authorization
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from zeroproof import ZeroProof
|
|
98
|
+
|
|
99
|
+
client = ZeroProof(api_key="zkp_...")
|
|
100
|
+
|
|
101
|
+
# Before allowing an agent to make a purchase
|
|
102
|
+
challenge = client.create_challenge(
|
|
103
|
+
agent_id="checkout-agent-v2",
|
|
104
|
+
action="initiate_purchase",
|
|
105
|
+
context={
|
|
106
|
+
"amount": 1499.99,
|
|
107
|
+
"merchant": "TechStore",
|
|
108
|
+
"items": ["laptop", "mouse", "keyboard"]
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Agent generates proof
|
|
113
|
+
proof = your_agent.generate_proof(challenge)
|
|
114
|
+
|
|
115
|
+
# Verify before processing payment
|
|
116
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
117
|
+
|
|
118
|
+
if result.verified and result.confidence > 0.95:
|
|
119
|
+
process_payment(1499.99)
|
|
120
|
+
else:
|
|
121
|
+
log_security_incident(result)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Refund Authorization
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# Verify agent before approving refund
|
|
128
|
+
challenge = client.create_challenge(
|
|
129
|
+
agent_id="refund-processor",
|
|
130
|
+
action="approve_refund",
|
|
131
|
+
context={"order_id": "ORD-12345", "amount": 299.99}
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
135
|
+
|
|
136
|
+
if result.verified:
|
|
137
|
+
approve_refund(order_id="ORD-12345")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Inventory Management
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
# Verify agent before updating inventory
|
|
144
|
+
challenge = client.create_challenge(
|
|
145
|
+
agent_id="inventory-manager",
|
|
146
|
+
action="update_stock",
|
|
147
|
+
context={"product_id": "PROD-789", "quantity_change": -50}
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
151
|
+
|
|
152
|
+
if result.verified:
|
|
153
|
+
update_inventory("PROD-789", quantity=-50)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### ZeroProof
|
|
159
|
+
|
|
160
|
+
The main client class for interacting with the API.
|
|
161
|
+
|
|
162
|
+
#### `__init__(api_key: str, base_url: Optional[str] = None)`
|
|
163
|
+
|
|
164
|
+
Initialize the ZeroProof client.
|
|
165
|
+
|
|
166
|
+
**Parameters:**
|
|
167
|
+
- `api_key` (str): Your ZeroProof API key (starts with 'zkp_')
|
|
168
|
+
- `base_url` (str, optional): Custom API base URL (defaults to production)
|
|
169
|
+
|
|
170
|
+
**Raises:**
|
|
171
|
+
- `ValueError`: If API key is invalid or missing
|
|
172
|
+
|
|
173
|
+
#### `create_challenge(agent_id: str, action: str, context: Optional[Dict] = None) -> Challenge`
|
|
174
|
+
|
|
175
|
+
Create a new verification challenge.
|
|
176
|
+
|
|
177
|
+
**Parameters:**
|
|
178
|
+
- `agent_id` (str): Unique identifier for the AI agent
|
|
179
|
+
- `action` (str): The action the agent wants to perform
|
|
180
|
+
- `context` (dict, optional): Additional context for the action
|
|
181
|
+
|
|
182
|
+
**Returns:**
|
|
183
|
+
- `Challenge`: Object containing challenge_id, nonce, expires_in, timestamp
|
|
184
|
+
|
|
185
|
+
**Raises:**
|
|
186
|
+
- `ZeroProofError`: If the request fails
|
|
187
|
+
|
|
188
|
+
#### `verify_proof(challenge_id: str, proof: str, agent_signature: Optional[str] = None) -> VerificationResult`
|
|
189
|
+
|
|
190
|
+
Verify a proof for a given challenge.
|
|
191
|
+
|
|
192
|
+
**Parameters:**
|
|
193
|
+
- `challenge_id` (str): The challenge ID from create_challenge()
|
|
194
|
+
- `proof` (str): The cryptographic proof data
|
|
195
|
+
- `agent_signature` (str, optional): Optional agent signature
|
|
196
|
+
|
|
197
|
+
**Returns:**
|
|
198
|
+
- `VerificationResult`: Object containing verification details
|
|
199
|
+
|
|
200
|
+
**Raises:**
|
|
201
|
+
- `ZeroProofError`: If verification fails
|
|
202
|
+
|
|
203
|
+
#### `get_status(session_id: str) -> Dict`
|
|
204
|
+
|
|
205
|
+
Get the status of a verification session.
|
|
206
|
+
|
|
207
|
+
**Parameters:**
|
|
208
|
+
- `session_id` (str): The session/challenge ID to check
|
|
209
|
+
|
|
210
|
+
**Returns:**
|
|
211
|
+
- `dict`: Session status details
|
|
212
|
+
|
|
213
|
+
**Raises:**
|
|
214
|
+
- `ZeroProofError`: If the request fails
|
|
215
|
+
|
|
216
|
+
### Data Classes
|
|
217
|
+
|
|
218
|
+
#### Challenge
|
|
219
|
+
|
|
220
|
+
Represents a verification challenge.
|
|
221
|
+
|
|
222
|
+
**Attributes:**
|
|
223
|
+
- `challenge_id` (str): Unique challenge identifier
|
|
224
|
+
- `nonce` (str): Random nonce for this challenge
|
|
225
|
+
- `expires_in` (int): Time until expiration in seconds
|
|
226
|
+
- `timestamp` (int): Challenge creation timestamp
|
|
227
|
+
|
|
228
|
+
#### VerificationResult
|
|
229
|
+
|
|
230
|
+
Represents the result of proof verification.
|
|
231
|
+
|
|
232
|
+
**Attributes:**
|
|
233
|
+
- `verified` (bool): Whether the proof was verified
|
|
234
|
+
- `agent_id` (str): The agent that was verified
|
|
235
|
+
- `action` (str): The action that was authorized
|
|
236
|
+
- `confidence` (float): Confidence score (0.0 to 1.0)
|
|
237
|
+
- `timestamp` (str): Verification timestamp
|
|
238
|
+
- `session_id` (str): Session identifier
|
|
239
|
+
|
|
240
|
+
### Exceptions
|
|
241
|
+
|
|
242
|
+
#### ZeroProofError
|
|
243
|
+
|
|
244
|
+
Base exception for SDK errors.
|
|
245
|
+
|
|
246
|
+
**Attributes:**
|
|
247
|
+
- `message` (str): Error message
|
|
248
|
+
- `status_code` (int, optional): HTTP status code
|
|
249
|
+
- `response` (dict, optional): Full API response
|
|
250
|
+
|
|
251
|
+
## Context Manager Support
|
|
252
|
+
|
|
253
|
+
The SDK supports context managers for automatic resource cleanup:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
with ZeroProof(api_key="zkp_...") as client:
|
|
257
|
+
challenge = client.create_challenge("agent-1", "purchase")
|
|
258
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
259
|
+
# Session is automatically closed
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Error Handling
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
from zeroproof import ZeroProof, ZeroProofError
|
|
266
|
+
|
|
267
|
+
client = ZeroProof(api_key="zkp_...")
|
|
268
|
+
|
|
269
|
+
try:
|
|
270
|
+
challenge = client.create_challenge("agent", "action")
|
|
271
|
+
result = client.verify_proof(challenge.challenge_id, "invalid_proof")
|
|
272
|
+
except ZeroProofError as e:
|
|
273
|
+
print(f"Error: {e.message}")
|
|
274
|
+
print(f"Status Code: {e.status_code}")
|
|
275
|
+
print(f"Response: {e.response}")
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Configuration
|
|
279
|
+
|
|
280
|
+
### Custom API Endpoint
|
|
281
|
+
|
|
282
|
+
For testing or self-hosted deployments:
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
client = ZeroProof(
|
|
286
|
+
api_key="zkp_...",
|
|
287
|
+
base_url="https://api.custom-domain.com/v1"
|
|
288
|
+
)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Environment Variables
|
|
292
|
+
|
|
293
|
+
You can set your API key via environment variable:
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
import os
|
|
297
|
+
from zeroproof import ZeroProof
|
|
298
|
+
|
|
299
|
+
api_key = os.getenv("ZEROPROOF_API_KEY")
|
|
300
|
+
client = ZeroProof(api_key=api_key)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Requirements
|
|
304
|
+
|
|
305
|
+
- Python 3.8+
|
|
306
|
+
- requests >= 2.25.0
|
|
307
|
+
|
|
308
|
+
## Getting an API Key
|
|
309
|
+
|
|
310
|
+
1. Sign up at [https://zeroproofai.com](https://zeroproofai.com)
|
|
311
|
+
2. Navigate to your dashboard
|
|
312
|
+
3. Generate a new API key
|
|
313
|
+
4. Copy the key (starts with `zkp_`)
|
|
314
|
+
|
|
315
|
+
## Development
|
|
316
|
+
|
|
317
|
+
### Installing for Development
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
git clone https://github.com/jacobweiss2305/zeroproof.git
|
|
321
|
+
cd zeroproof/python-sdk
|
|
322
|
+
pip install -e ".[dev]"
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Running Tests
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
pytest tests/
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Code Formatting
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
black zeroproof/
|
|
335
|
+
flake8 zeroproof/
|
|
336
|
+
mypy zeroproof/
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Support
|
|
340
|
+
|
|
341
|
+
- **Documentation**: [https://docs.zeroproofai.com](https://docs.zeroproofai.com)
|
|
342
|
+
- **Issues**: [GitHub Issues](https://github.com/jacobweiss2305/zeroproof/issues)
|
|
343
|
+
- **Email**: support@zeroproofai.com
|
|
344
|
+
|
|
345
|
+
## License
|
|
346
|
+
|
|
347
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
348
|
+
|
|
349
|
+
## Contributing
|
|
350
|
+
|
|
351
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
352
|
+
|
|
353
|
+
## Changelog
|
|
354
|
+
|
|
355
|
+
### 0.1.0 (2025-01-10)
|
|
356
|
+
|
|
357
|
+
- Initial release
|
|
358
|
+
- Basic challenge/proof verification flow
|
|
359
|
+
- Context manager support
|
|
360
|
+
- Comprehensive error handling
|
|
361
|
+
- Full type hints
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# ZeroProof Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/zeroproof)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Python SDK for the ZeroProof AI verification API. Secure your agentic e-commerce ecosystem with zero-knowledge proofs.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install zeroproof
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from zeroproof import ZeroProof
|
|
19
|
+
|
|
20
|
+
# Initialize the client with your API key
|
|
21
|
+
client = ZeroProof(api_key="zkp_your_api_key_here")
|
|
22
|
+
|
|
23
|
+
# Create a verification challenge
|
|
24
|
+
challenge = client.create_challenge(
|
|
25
|
+
agent_id="shopping-assistant-v1",
|
|
26
|
+
action="add_to_cart",
|
|
27
|
+
context={"item_id": "laptop-123", "price": 999.99}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
print(f"Challenge ID: {challenge.challenge_id}")
|
|
31
|
+
print(f"Nonce: {challenge.nonce}")
|
|
32
|
+
print(f"Expires in: {challenge.expires_in} seconds")
|
|
33
|
+
|
|
34
|
+
# Verify the proof (in production, this would be generated by your agent)
|
|
35
|
+
result = client.verify_proof(
|
|
36
|
+
challenge_id=challenge.challenge_id,
|
|
37
|
+
proof="your_cryptographic_proof_here",
|
|
38
|
+
agent_signature="optional_signature_here"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
if result.verified:
|
|
42
|
+
print(f"✅ Verification successful!")
|
|
43
|
+
print(f" Agent: {result.agent_id}")
|
|
44
|
+
print(f" Action: {result.action}")
|
|
45
|
+
print(f" Confidence: {result.confidence * 100}%")
|
|
46
|
+
# Now execute the actual e-commerce action
|
|
47
|
+
else:
|
|
48
|
+
print("❌ Verification failed")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Use Cases
|
|
52
|
+
|
|
53
|
+
### E-Commerce Agent Authorization
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from zeroproof import ZeroProof
|
|
57
|
+
|
|
58
|
+
client = ZeroProof(api_key="zkp_...")
|
|
59
|
+
|
|
60
|
+
# Before allowing an agent to make a purchase
|
|
61
|
+
challenge = client.create_challenge(
|
|
62
|
+
agent_id="checkout-agent-v2",
|
|
63
|
+
action="initiate_purchase",
|
|
64
|
+
context={
|
|
65
|
+
"amount": 1499.99,
|
|
66
|
+
"merchant": "TechStore",
|
|
67
|
+
"items": ["laptop", "mouse", "keyboard"]
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Agent generates proof
|
|
72
|
+
proof = your_agent.generate_proof(challenge)
|
|
73
|
+
|
|
74
|
+
# Verify before processing payment
|
|
75
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
76
|
+
|
|
77
|
+
if result.verified and result.confidence > 0.95:
|
|
78
|
+
process_payment(1499.99)
|
|
79
|
+
else:
|
|
80
|
+
log_security_incident(result)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Refund Authorization
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
# Verify agent before approving refund
|
|
87
|
+
challenge = client.create_challenge(
|
|
88
|
+
agent_id="refund-processor",
|
|
89
|
+
action="approve_refund",
|
|
90
|
+
context={"order_id": "ORD-12345", "amount": 299.99}
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
94
|
+
|
|
95
|
+
if result.verified:
|
|
96
|
+
approve_refund(order_id="ORD-12345")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Inventory Management
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
# Verify agent before updating inventory
|
|
103
|
+
challenge = client.create_challenge(
|
|
104
|
+
agent_id="inventory-manager",
|
|
105
|
+
action="update_stock",
|
|
106
|
+
context={"product_id": "PROD-789", "quantity_change": -50}
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
110
|
+
|
|
111
|
+
if result.verified:
|
|
112
|
+
update_inventory("PROD-789", quantity=-50)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## API Reference
|
|
116
|
+
|
|
117
|
+
### ZeroProof
|
|
118
|
+
|
|
119
|
+
The main client class for interacting with the API.
|
|
120
|
+
|
|
121
|
+
#### `__init__(api_key: str, base_url: Optional[str] = None)`
|
|
122
|
+
|
|
123
|
+
Initialize the ZeroProof client.
|
|
124
|
+
|
|
125
|
+
**Parameters:**
|
|
126
|
+
- `api_key` (str): Your ZeroProof API key (starts with 'zkp_')
|
|
127
|
+
- `base_url` (str, optional): Custom API base URL (defaults to production)
|
|
128
|
+
|
|
129
|
+
**Raises:**
|
|
130
|
+
- `ValueError`: If API key is invalid or missing
|
|
131
|
+
|
|
132
|
+
#### `create_challenge(agent_id: str, action: str, context: Optional[Dict] = None) -> Challenge`
|
|
133
|
+
|
|
134
|
+
Create a new verification challenge.
|
|
135
|
+
|
|
136
|
+
**Parameters:**
|
|
137
|
+
- `agent_id` (str): Unique identifier for the AI agent
|
|
138
|
+
- `action` (str): The action the agent wants to perform
|
|
139
|
+
- `context` (dict, optional): Additional context for the action
|
|
140
|
+
|
|
141
|
+
**Returns:**
|
|
142
|
+
- `Challenge`: Object containing challenge_id, nonce, expires_in, timestamp
|
|
143
|
+
|
|
144
|
+
**Raises:**
|
|
145
|
+
- `ZeroProofError`: If the request fails
|
|
146
|
+
|
|
147
|
+
#### `verify_proof(challenge_id: str, proof: str, agent_signature: Optional[str] = None) -> VerificationResult`
|
|
148
|
+
|
|
149
|
+
Verify a proof for a given challenge.
|
|
150
|
+
|
|
151
|
+
**Parameters:**
|
|
152
|
+
- `challenge_id` (str): The challenge ID from create_challenge()
|
|
153
|
+
- `proof` (str): The cryptographic proof data
|
|
154
|
+
- `agent_signature` (str, optional): Optional agent signature
|
|
155
|
+
|
|
156
|
+
**Returns:**
|
|
157
|
+
- `VerificationResult`: Object containing verification details
|
|
158
|
+
|
|
159
|
+
**Raises:**
|
|
160
|
+
- `ZeroProofError`: If verification fails
|
|
161
|
+
|
|
162
|
+
#### `get_status(session_id: str) -> Dict`
|
|
163
|
+
|
|
164
|
+
Get the status of a verification session.
|
|
165
|
+
|
|
166
|
+
**Parameters:**
|
|
167
|
+
- `session_id` (str): The session/challenge ID to check
|
|
168
|
+
|
|
169
|
+
**Returns:**
|
|
170
|
+
- `dict`: Session status details
|
|
171
|
+
|
|
172
|
+
**Raises:**
|
|
173
|
+
- `ZeroProofError`: If the request fails
|
|
174
|
+
|
|
175
|
+
### Data Classes
|
|
176
|
+
|
|
177
|
+
#### Challenge
|
|
178
|
+
|
|
179
|
+
Represents a verification challenge.
|
|
180
|
+
|
|
181
|
+
**Attributes:**
|
|
182
|
+
- `challenge_id` (str): Unique challenge identifier
|
|
183
|
+
- `nonce` (str): Random nonce for this challenge
|
|
184
|
+
- `expires_in` (int): Time until expiration in seconds
|
|
185
|
+
- `timestamp` (int): Challenge creation timestamp
|
|
186
|
+
|
|
187
|
+
#### VerificationResult
|
|
188
|
+
|
|
189
|
+
Represents the result of proof verification.
|
|
190
|
+
|
|
191
|
+
**Attributes:**
|
|
192
|
+
- `verified` (bool): Whether the proof was verified
|
|
193
|
+
- `agent_id` (str): The agent that was verified
|
|
194
|
+
- `action` (str): The action that was authorized
|
|
195
|
+
- `confidence` (float): Confidence score (0.0 to 1.0)
|
|
196
|
+
- `timestamp` (str): Verification timestamp
|
|
197
|
+
- `session_id` (str): Session identifier
|
|
198
|
+
|
|
199
|
+
### Exceptions
|
|
200
|
+
|
|
201
|
+
#### ZeroProofError
|
|
202
|
+
|
|
203
|
+
Base exception for SDK errors.
|
|
204
|
+
|
|
205
|
+
**Attributes:**
|
|
206
|
+
- `message` (str): Error message
|
|
207
|
+
- `status_code` (int, optional): HTTP status code
|
|
208
|
+
- `response` (dict, optional): Full API response
|
|
209
|
+
|
|
210
|
+
## Context Manager Support
|
|
211
|
+
|
|
212
|
+
The SDK supports context managers for automatic resource cleanup:
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
with ZeroProof(api_key="zkp_...") as client:
|
|
216
|
+
challenge = client.create_challenge("agent-1", "purchase")
|
|
217
|
+
result = client.verify_proof(challenge.challenge_id, proof)
|
|
218
|
+
# Session is automatically closed
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Error Handling
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
from zeroproof import ZeroProof, ZeroProofError
|
|
225
|
+
|
|
226
|
+
client = ZeroProof(api_key="zkp_...")
|
|
227
|
+
|
|
228
|
+
try:
|
|
229
|
+
challenge = client.create_challenge("agent", "action")
|
|
230
|
+
result = client.verify_proof(challenge.challenge_id, "invalid_proof")
|
|
231
|
+
except ZeroProofError as e:
|
|
232
|
+
print(f"Error: {e.message}")
|
|
233
|
+
print(f"Status Code: {e.status_code}")
|
|
234
|
+
print(f"Response: {e.response}")
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Configuration
|
|
238
|
+
|
|
239
|
+
### Custom API Endpoint
|
|
240
|
+
|
|
241
|
+
For testing or self-hosted deployments:
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
client = ZeroProof(
|
|
245
|
+
api_key="zkp_...",
|
|
246
|
+
base_url="https://api.custom-domain.com/v1"
|
|
247
|
+
)
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Environment Variables
|
|
251
|
+
|
|
252
|
+
You can set your API key via environment variable:
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
import os
|
|
256
|
+
from zeroproof import ZeroProof
|
|
257
|
+
|
|
258
|
+
api_key = os.getenv("ZEROPROOF_API_KEY")
|
|
259
|
+
client = ZeroProof(api_key=api_key)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Requirements
|
|
263
|
+
|
|
264
|
+
- Python 3.8+
|
|
265
|
+
- requests >= 2.25.0
|
|
266
|
+
|
|
267
|
+
## Getting an API Key
|
|
268
|
+
|
|
269
|
+
1. Sign up at [https://zeroproofai.com](https://zeroproofai.com)
|
|
270
|
+
2. Navigate to your dashboard
|
|
271
|
+
3. Generate a new API key
|
|
272
|
+
4. Copy the key (starts with `zkp_`)
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
### Installing for Development
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
git clone https://github.com/jacobweiss2305/zeroproof.git
|
|
280
|
+
cd zeroproof/python-sdk
|
|
281
|
+
pip install -e ".[dev]"
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Running Tests
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
pytest tests/
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Code Formatting
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
black zeroproof/
|
|
294
|
+
flake8 zeroproof/
|
|
295
|
+
mypy zeroproof/
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Support
|
|
299
|
+
|
|
300
|
+
- **Documentation**: [https://docs.zeroproofai.com](https://docs.zeroproofai.com)
|
|
301
|
+
- **Issues**: [GitHub Issues](https://github.com/jacobweiss2305/zeroproof/issues)
|
|
302
|
+
- **Email**: support@zeroproofai.com
|
|
303
|
+
|
|
304
|
+
## License
|
|
305
|
+
|
|
306
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
307
|
+
|
|
308
|
+
## Contributing
|
|
309
|
+
|
|
310
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
311
|
+
|
|
312
|
+
## Changelog
|
|
313
|
+
|
|
314
|
+
### 0.1.0 (2025-01-10)
|
|
315
|
+
|
|
316
|
+
- Initial release
|
|
317
|
+
- Basic challenge/proof verification flow
|
|
318
|
+
- Context manager support
|
|
319
|
+
- Comprehensive error handling
|
|
320
|
+
- Full type hints
|