zeroproof 0.1.0__py3-none-any.whl
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/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ZeroProof Python SDK
|
|
3
|
+
|
|
4
|
+
A minimal SDK for the ZeroProof AI verification API.
|
|
5
|
+
Secure your agentic e-commerce ecosystem with zero-knowledge proofs.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
from .client import ZeroProof, ZeroProofError, Challenge, VerificationResult
|
|
11
|
+
|
|
12
|
+
__all__ = ["ZeroProof", "ZeroProofError", "Challenge", "VerificationResult"]
|
zeroproof/client.py
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ZeroProof Client Module
|
|
3
|
+
|
|
4
|
+
Provides the main ZeroProof class for interacting with the API.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
from typing import Any, Dict, Optional
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
import requests
|
|
14
|
+
except ImportError:
|
|
15
|
+
raise ImportError(
|
|
16
|
+
"The 'requests' library is required. Install it with: pip install requests"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class Challenge:
|
|
22
|
+
"""Represents a verification challenge from the API."""
|
|
23
|
+
|
|
24
|
+
challenge_id: str
|
|
25
|
+
nonce: str
|
|
26
|
+
expires_in: int
|
|
27
|
+
timestamp: int
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def from_dict(cls, data: Dict[str, Any]) -> "Challenge":
|
|
31
|
+
"""Create a Challenge from API response data."""
|
|
32
|
+
return cls(
|
|
33
|
+
challenge_id=data["challenge_id"],
|
|
34
|
+
nonce=data["nonce"],
|
|
35
|
+
expires_in=data["expires_in"],
|
|
36
|
+
timestamp=data["timestamp"],
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class VerificationResult:
|
|
42
|
+
"""Represents the result of a proof verification."""
|
|
43
|
+
|
|
44
|
+
verified: bool
|
|
45
|
+
agent_id: str
|
|
46
|
+
action: str
|
|
47
|
+
confidence: float
|
|
48
|
+
timestamp: str
|
|
49
|
+
session_id: str
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_dict(cls, data: Dict[str, Any]) -> "VerificationResult":
|
|
53
|
+
"""Create a VerificationResult from API response data."""
|
|
54
|
+
return cls(
|
|
55
|
+
verified=data["verified"],
|
|
56
|
+
agent_id=data["agent_id"],
|
|
57
|
+
action=data["action"],
|
|
58
|
+
confidence=data["confidence"],
|
|
59
|
+
timestamp=data["timestamp"],
|
|
60
|
+
session_id=data["session_id"],
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ZeroProofError(Exception):
|
|
65
|
+
"""Base exception for ZeroProof SDK errors."""
|
|
66
|
+
|
|
67
|
+
def __init__(self, message: str, status_code: Optional[int] = None, response: Optional[Dict] = None):
|
|
68
|
+
self.message = message
|
|
69
|
+
self.status_code = status_code
|
|
70
|
+
self.response = response
|
|
71
|
+
super().__init__(self.message)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class ZeroProof:
|
|
75
|
+
"""
|
|
76
|
+
ZeroProof API Client
|
|
77
|
+
|
|
78
|
+
A simple client for interacting with the ZeroProof verification API.
|
|
79
|
+
|
|
80
|
+
Example:
|
|
81
|
+
>>> from zeroproof import ZeroProof
|
|
82
|
+
>>> client = ZeroProof(api_key="zkp_your_key_here")
|
|
83
|
+
>>> challenge = client.create_challenge("shopping-bot", "add_to_cart")
|
|
84
|
+
>>> result = client.verify_proof(challenge.challenge_id, "proof_data")
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
DEFAULT_BASE_URL = "https://api.zeroproofai.com/v1"
|
|
88
|
+
|
|
89
|
+
def __init__(self, api_key: str, base_url: Optional[str] = None):
|
|
90
|
+
"""
|
|
91
|
+
Initialize the ZeroProof client.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
api_key: Your ZeroProof API key (starts with 'zkp_')
|
|
95
|
+
base_url: Optional custom API base URL (defaults to production)
|
|
96
|
+
"""
|
|
97
|
+
if not api_key:
|
|
98
|
+
raise ValueError("API key is required")
|
|
99
|
+
|
|
100
|
+
if not api_key.startswith("zkp_"):
|
|
101
|
+
raise ValueError("Invalid API key format. API key should start with 'zkp_'")
|
|
102
|
+
|
|
103
|
+
self.api_key = api_key
|
|
104
|
+
self.base_url = base_url or self.DEFAULT_BASE_URL
|
|
105
|
+
self.session = requests.Session()
|
|
106
|
+
self.session.headers.update({
|
|
107
|
+
"X-Api-Key": self.api_key,
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
def _make_request(
|
|
112
|
+
self,
|
|
113
|
+
method: str,
|
|
114
|
+
endpoint: str,
|
|
115
|
+
data: Optional[Dict] = None,
|
|
116
|
+
params: Optional[Dict] = None,
|
|
117
|
+
) -> Dict[str, Any]:
|
|
118
|
+
"""
|
|
119
|
+
Make a request to the API.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
method: HTTP method (GET, POST, etc.)
|
|
123
|
+
endpoint: API endpoint path
|
|
124
|
+
data: Optional request body data
|
|
125
|
+
params: Optional query parameters
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
Parsed JSON response
|
|
129
|
+
|
|
130
|
+
Raises:
|
|
131
|
+
ZeroProofError: If the request fails
|
|
132
|
+
"""
|
|
133
|
+
url = f"{self.base_url}/{endpoint.lstrip('/')}"
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
response = self.session.request(
|
|
137
|
+
method=method,
|
|
138
|
+
url=url,
|
|
139
|
+
json=data,
|
|
140
|
+
params=params,
|
|
141
|
+
timeout=30,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Try to parse JSON response
|
|
145
|
+
try:
|
|
146
|
+
response_data = response.json()
|
|
147
|
+
except json.JSONDecodeError:
|
|
148
|
+
response_data = {"raw_response": response.text}
|
|
149
|
+
|
|
150
|
+
# Check for errors
|
|
151
|
+
if response.status_code >= 400:
|
|
152
|
+
error_message = response_data.get("error", "Unknown error")
|
|
153
|
+
if "message" in response_data:
|
|
154
|
+
error_message = f"{error_message}: {response_data['message']}"
|
|
155
|
+
|
|
156
|
+
raise ZeroProofError(
|
|
157
|
+
message=error_message,
|
|
158
|
+
status_code=response.status_code,
|
|
159
|
+
response=response_data,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return response_data
|
|
163
|
+
|
|
164
|
+
except requests.RequestException as e:
|
|
165
|
+
raise ZeroProofError(f"Request failed: {str(e)}") from e
|
|
166
|
+
|
|
167
|
+
def create_challenge(
|
|
168
|
+
self,
|
|
169
|
+
agent_id: str,
|
|
170
|
+
action: str,
|
|
171
|
+
context: Optional[Dict[str, Any]] = None,
|
|
172
|
+
) -> Challenge:
|
|
173
|
+
"""
|
|
174
|
+
Create a new verification challenge.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
agent_id: Unique identifier for the AI agent
|
|
178
|
+
action: The action the agent wants to perform (e.g., "add_to_cart")
|
|
179
|
+
context: Optional additional context for the action
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
Challenge object containing the challenge details
|
|
183
|
+
|
|
184
|
+
Raises:
|
|
185
|
+
ZeroProofError: If the request fails
|
|
186
|
+
|
|
187
|
+
Example:
|
|
188
|
+
>>> challenge = client.create_challenge(
|
|
189
|
+
... agent_id="shopping-assistant-v1",
|
|
190
|
+
... action="add_to_cart",
|
|
191
|
+
... context={"item_id": "laptop-123", "price": 999.99}
|
|
192
|
+
... )
|
|
193
|
+
"""
|
|
194
|
+
data = {
|
|
195
|
+
"agent_id": agent_id,
|
|
196
|
+
"action": action,
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if context is not None:
|
|
200
|
+
data["context"] = context
|
|
201
|
+
|
|
202
|
+
response = self._make_request("POST", "/verify/challenge", data=data)
|
|
203
|
+
return Challenge.from_dict(response)
|
|
204
|
+
|
|
205
|
+
def verify_proof(
|
|
206
|
+
self,
|
|
207
|
+
challenge_id: str,
|
|
208
|
+
proof: str,
|
|
209
|
+
agent_signature: Optional[str] = None,
|
|
210
|
+
) -> VerificationResult:
|
|
211
|
+
"""
|
|
212
|
+
Verify a proof for a given challenge.
|
|
213
|
+
|
|
214
|
+
Args:
|
|
215
|
+
challenge_id: The challenge ID from create_challenge()
|
|
216
|
+
proof: The cryptographic proof data
|
|
217
|
+
agent_signature: Optional agent signature for additional verification
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
VerificationResult object with verification details
|
|
221
|
+
|
|
222
|
+
Raises:
|
|
223
|
+
ZeroProofError: If verification fails or request fails
|
|
224
|
+
|
|
225
|
+
Example:
|
|
226
|
+
>>> result = client.verify_proof(
|
|
227
|
+
... challenge_id=challenge.challenge_id,
|
|
228
|
+
... proof="proof_data_here",
|
|
229
|
+
... agent_signature="signature_here"
|
|
230
|
+
... )
|
|
231
|
+
>>> if result.verified:
|
|
232
|
+
... print(f"Verified with {result.confidence * 100}% confidence")
|
|
233
|
+
"""
|
|
234
|
+
data = {
|
|
235
|
+
"challenge_id": challenge_id,
|
|
236
|
+
"proof": proof,
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if agent_signature is not None:
|
|
240
|
+
data["agent_signature"] = agent_signature
|
|
241
|
+
|
|
242
|
+
response = self._make_request("POST", "/verify/proof", data=data)
|
|
243
|
+
return VerificationResult.from_dict(response)
|
|
244
|
+
|
|
245
|
+
def get_status(self, session_id: str) -> Dict[str, Any]:
|
|
246
|
+
"""
|
|
247
|
+
Get the status of a verification session.
|
|
248
|
+
|
|
249
|
+
Args:
|
|
250
|
+
session_id: The session/challenge ID to check
|
|
251
|
+
|
|
252
|
+
Returns:
|
|
253
|
+
Dictionary with session status details
|
|
254
|
+
|
|
255
|
+
Raises:
|
|
256
|
+
ZeroProofError: If the request fails
|
|
257
|
+
|
|
258
|
+
Example:
|
|
259
|
+
>>> status = client.get_status(challenge.challenge_id)
|
|
260
|
+
>>> print(f"Status: {status['status']}")
|
|
261
|
+
"""
|
|
262
|
+
response = self._make_request("GET", f"/verify/status/{session_id}")
|
|
263
|
+
return response
|
|
264
|
+
|
|
265
|
+
def __enter__(self):
|
|
266
|
+
"""Context manager entry."""
|
|
267
|
+
return self
|
|
268
|
+
|
|
269
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
270
|
+
"""Context manager exit - close the session."""
|
|
271
|
+
self.session.close()
|
|
272
|
+
|
|
273
|
+
def close(self):
|
|
274
|
+
"""Close the underlying HTTP session."""
|
|
275
|
+
self.session.close()
|
|
@@ -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,7 @@
|
|
|
1
|
+
zeroproof/__init__.py,sha256=qDAFhOILuf-uqSxvZXQKTn6p8iV6Sos4zvx-jZpAkJc,343
|
|
2
|
+
zeroproof/client.py,sha256=mv2_vpnoKRgjeoWIEksNSFrp2GlydjxtwhYmNCrQwK4,8690
|
|
3
|
+
zeroproof-0.1.0.dist-info/licenses/LICENSE,sha256=syJjKqAU8RC7zNCXS1Njm5_2Ch3UK49meh3dNA6txPM,1090
|
|
4
|
+
zeroproof-0.1.0.dist-info/METADATA,sha256=bK2FzqpQdVmqRJzvXxpHI-mma0rx3_MFneFRSjlBhws,9768
|
|
5
|
+
zeroproof-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
+
zeroproof-0.1.0.dist-info/top_level.txt,sha256=3On0JLPOLYjabAf4QQEUYg9Kelox-ouOWHCiE0-7XGU,10
|
|
7
|
+
zeroproof-0.1.0.dist-info/RECORD,,
|
|
@@ -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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
zeroproof
|