tether-name 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.
- tether_name-0.1.0/.github/workflows/publish.yml +30 -0
- tether_name-0.1.0/.github/workflows/test.yml +27 -0
- tether_name-0.1.0/LICENSE +21 -0
- tether_name-0.1.0/PKG-INFO +360 -0
- tether_name-0.1.0/README.md +303 -0
- tether_name-0.1.0/example.py +86 -0
- tether_name-0.1.0/pyproject.toml +70 -0
- tether_name-0.1.0/src/tether_name/__init__.py +53 -0
- tether_name-0.1.0/src/tether_name/client.py +248 -0
- tether_name-0.1.0/src/tether_name/crypto.py +141 -0
- tether_name-0.1.0/src/tether_name/exceptions.py +41 -0
- tether_name-0.1.0/src/tether_name/py.typed +0 -0
- tether_name-0.1.0/tests/__init__.py +1 -0
- tether_name-0.1.0/tests/test_crypto.py +270 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write # trusted publishing
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
|
|
23
|
+
- name: Install build tools
|
|
24
|
+
run: pip install build
|
|
25
|
+
|
|
26
|
+
- name: Build package
|
|
27
|
+
run: python -m build
|
|
28
|
+
|
|
29
|
+
- name: Publish to PyPI
|
|
30
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: |
|
|
24
|
+
pip install -e ".[dev]"
|
|
25
|
+
|
|
26
|
+
- name: Run tests
|
|
27
|
+
run: pytest tests/ -v
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Commit 451
|
|
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,360 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tether-name
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for Tether.name - AI agent identity verification
|
|
5
|
+
Project-URL: Homepage, https://tether.name
|
|
6
|
+
Project-URL: Documentation, https://github.com/Commit451/tether-name-python#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/Commit451/tether-name-python
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/Commit451/tether-name-python/issues
|
|
9
|
+
Author-email: Commit 451 <jawnnypoo@gmail.com>
|
|
10
|
+
Maintainer-email: Commit 451 <jawnnypoo@gmail.com>
|
|
11
|
+
License: MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2024 Commit 451
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Keywords: agent,ai,cryptography,identity,tether,verification
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
44
|
+
Classifier: Topic :: Security :: Cryptography
|
|
45
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
46
|
+
Requires-Python: >=3.8
|
|
47
|
+
Requires-Dist: cryptography>=3.4.0
|
|
48
|
+
Requires-Dist: httpx>=0.20.0
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: black; extra == 'dev'
|
|
51
|
+
Requires-Dist: isort; extra == 'dev'
|
|
52
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
53
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
54
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
55
|
+
Requires-Dist: pytest>=6.0; extra == 'dev'
|
|
56
|
+
Description-Content-Type: text/markdown
|
|
57
|
+
|
|
58
|
+
# Tether.name Python SDK
|
|
59
|
+
|
|
60
|
+
[](https://pypi.org/project/tether-name/)
|
|
61
|
+
[](https://pypi.org/project/tether-name/)
|
|
62
|
+
[](https://opensource.org/licenses/MIT)
|
|
63
|
+
|
|
64
|
+
**Official Python SDK for [Tether.name](https://tether.name) โ cryptographic identity verification for AI agents.**
|
|
65
|
+
|
|
66
|
+
Tether lets AI agents prove their identity using RSA-2048 digital signatures, providing a secure, verifiable way to establish trust in AI-to-AI and AI-to-human interactions.
|
|
67
|
+
|
|
68
|
+
## ๐ Quick Start
|
|
69
|
+
|
|
70
|
+
### Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install tether-name
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Basic Usage
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from tether_name import TetherClient
|
|
80
|
+
|
|
81
|
+
# Initialize with your credentials
|
|
82
|
+
client = TetherClient(
|
|
83
|
+
credential_id="your-credential-id",
|
|
84
|
+
private_key_path="/path/to/your/private-key.der"
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Verify your agent's identity
|
|
88
|
+
result = client.verify()
|
|
89
|
+
|
|
90
|
+
if result.verified:
|
|
91
|
+
print(f"โ
Verified as: {result.agent_name}")
|
|
92
|
+
print(f"๐ง Email: {result.email}")
|
|
93
|
+
print(f"๐ Verification URL: {result.verify_url}")
|
|
94
|
+
else:
|
|
95
|
+
print(f"โ Verification failed: {result.error}")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## ๐ How Tether Works
|
|
99
|
+
|
|
100
|
+
Tether.name provides cryptographic identity verification for AI agents through a simple 3-step process:
|
|
101
|
+
|
|
102
|
+
1. **Register**: Create an agent identity at [tether.name](https://tether.name) and get your credential ID and RSA-2048 private key
|
|
103
|
+
2. **Sign**: Your agent signs a cryptographic challenge using its private key
|
|
104
|
+
3. **Verify**: The signature proves your agent's identity to others
|
|
105
|
+
|
|
106
|
+
This creates unforgeable digital identity that anyone can verify.
|
|
107
|
+
|
|
108
|
+
## ๐ง Configuration
|
|
109
|
+
|
|
110
|
+
### Environment Variables
|
|
111
|
+
|
|
112
|
+
Set these environment variables to avoid hardcoding credentials:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
export TETHER_CREDENTIAL_ID="your-credential-id"
|
|
116
|
+
export TETHER_PRIVATE_KEY_PATH="/path/to/your/key.der"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Then initialize without parameters:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
client = TetherClient() # Uses environment variables
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Key Formats
|
|
126
|
+
|
|
127
|
+
The SDK supports multiple private key formats:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
# From file path (PEM or DER)
|
|
131
|
+
client = TetherClient(
|
|
132
|
+
credential_id="...",
|
|
133
|
+
private_key_path="/path/to/key.der"
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
# From PEM string
|
|
137
|
+
client = TetherClient(
|
|
138
|
+
credential_id="...",
|
|
139
|
+
private_key_pem="-----BEGIN PRIVATE KEY-----\n..."
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
# From DER bytes
|
|
143
|
+
with open("key.der", "rb") as f:
|
|
144
|
+
key_bytes = f.read()
|
|
145
|
+
|
|
146
|
+
client = TetherClient(
|
|
147
|
+
credential_id="...",
|
|
148
|
+
private_key_der=key_bytes
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## ๐ API Reference
|
|
153
|
+
|
|
154
|
+
### `TetherClient`
|
|
155
|
+
|
|
156
|
+
Main client for Tether.name API interactions.
|
|
157
|
+
|
|
158
|
+
#### Constructor
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
TetherClient(
|
|
162
|
+
credential_id: Optional[str] = None,
|
|
163
|
+
private_key_path: Optional[Union[str, Path]] = None,
|
|
164
|
+
private_key_pem: Optional[Union[str, bytes]] = None,
|
|
165
|
+
private_key_der: Optional[bytes] = None,
|
|
166
|
+
base_url: str = "https://api.tether.name",
|
|
167
|
+
timeout: float = 30.0
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### Methods
|
|
172
|
+
|
|
173
|
+
##### `verify() -> VerificationResult`
|
|
174
|
+
|
|
175
|
+
Perform complete identity verification in one call.
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
result = client.verify()
|
|
179
|
+
print(result.verified) # bool: True if verified
|
|
180
|
+
print(result.agent_name) # str: Your agent's display name
|
|
181
|
+
print(result.verify_url) # str: Public verification URL
|
|
182
|
+
print(result.email) # str: Registered email address
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
##### `request_challenge() -> str`
|
|
186
|
+
|
|
187
|
+
Request a cryptographic challenge from Tether.
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
challenge = client.request_challenge()
|
|
191
|
+
print(challenge) # "550e8400-e29b-41d4-a716-446655440000"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
##### `sign(challenge: str) -> str`
|
|
195
|
+
|
|
196
|
+
Sign a challenge with your private key.
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
challenge = client.request_challenge()
|
|
200
|
+
signature = client.sign(challenge)
|
|
201
|
+
print(signature) # URL-safe base64 signature (no padding)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
##### `submit_proof(challenge: str, proof: str) -> VerificationResult`
|
|
205
|
+
|
|
206
|
+
Submit signed challenge for verification.
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
challenge = client.request_challenge()
|
|
210
|
+
signature = client.sign(challenge)
|
|
211
|
+
result = client.submit_proof(challenge, signature)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `VerificationResult`
|
|
215
|
+
|
|
216
|
+
Result object returned by verification operations.
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
@dataclass
|
|
220
|
+
class VerificationResult:
|
|
221
|
+
verified: bool # True if verification succeeded
|
|
222
|
+
agent_name: Optional[str] = None # Agent's display name
|
|
223
|
+
verify_url: Optional[str] = None # Public verification URL
|
|
224
|
+
email: Optional[str] = None # Registered email
|
|
225
|
+
registered_since: Optional[datetime] = None # Registration date
|
|
226
|
+
error: Optional[str] = None # Error message if failed
|
|
227
|
+
challenge: Optional[str] = None # Original challenge
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## ๐ Step-by-Step Example
|
|
231
|
+
|
|
232
|
+
For more control, you can break down the verification process:
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
from tether_name import TetherClient, TetherAPIError, TetherVerificationError
|
|
236
|
+
|
|
237
|
+
try:
|
|
238
|
+
client = TetherClient(
|
|
239
|
+
credential_id="your-credential-id",
|
|
240
|
+
private_key_path="/path/to/key.der"
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
# Step 1: Request a challenge
|
|
244
|
+
print("๐ก Requesting challenge...")
|
|
245
|
+
challenge = client.request_challenge()
|
|
246
|
+
print(f"๐ข Challenge: {challenge}")
|
|
247
|
+
|
|
248
|
+
# Step 2: Sign the challenge
|
|
249
|
+
print("โ๏ธ Signing challenge...")
|
|
250
|
+
signature = client.sign(challenge)
|
|
251
|
+
print(f"๐ Signature: {signature[:32]}...")
|
|
252
|
+
|
|
253
|
+
# Step 3: Submit proof
|
|
254
|
+
print("๐ค Submitting proof...")
|
|
255
|
+
result = client.submit_proof(challenge, signature)
|
|
256
|
+
|
|
257
|
+
if result.verified:
|
|
258
|
+
print(f"โ
Successfully verified as {result.agent_name}")
|
|
259
|
+
print(f"๐ Share this verification: {result.verify_url}")
|
|
260
|
+
else:
|
|
261
|
+
print(f"โ Verification failed: {result.error}")
|
|
262
|
+
|
|
263
|
+
except TetherAPIError as e:
|
|
264
|
+
print(f"๐ API Error: {e.message}")
|
|
265
|
+
if e.status_code:
|
|
266
|
+
print(f"๐ Status: {e.status_code}")
|
|
267
|
+
|
|
268
|
+
except TetherVerificationError as e:
|
|
269
|
+
print(f"๐ Verification Error: {e.message}")
|
|
270
|
+
|
|
271
|
+
finally:
|
|
272
|
+
client.close() # Clean up HTTP connections
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## ๐งช Testing
|
|
276
|
+
|
|
277
|
+
The SDK includes comprehensive unit tests that don't hit the live API:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Install development dependencies
|
|
281
|
+
pip install -e ".[dev]"
|
|
282
|
+
|
|
283
|
+
# Run tests
|
|
284
|
+
pytest
|
|
285
|
+
|
|
286
|
+
# Run with coverage
|
|
287
|
+
pytest --cov=tether_name
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## ๐ Context Manager Support
|
|
291
|
+
|
|
292
|
+
Use TetherClient as a context manager for automatic cleanup:
|
|
293
|
+
|
|
294
|
+
```python
|
|
295
|
+
with TetherClient(credential_id="...", private_key_path="...") as client:
|
|
296
|
+
result = client.verify()
|
|
297
|
+
print(f"Verified: {result.verified}")
|
|
298
|
+
# HTTP client automatically closed
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## ๐ก๏ธ Security Notes
|
|
302
|
+
|
|
303
|
+
- **Private Key Security**: Never commit private keys to version control or share them publicly
|
|
304
|
+
- **Key Format**: Tether requires RSA-2048 keys. Other key sizes will be rejected
|
|
305
|
+
- **Challenge Uniqueness**: Each verification uses a unique challenge to prevent replay attacks
|
|
306
|
+
- **Signature Algorithm**: Uses SHA256withRSA (PKCS#1 v1.5 padding) as specified by Tether
|
|
307
|
+
|
|
308
|
+
## ๐ Error Handling
|
|
309
|
+
|
|
310
|
+
The SDK provides specific exception types for different error conditions:
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
from tether_name import (
|
|
314
|
+
TetherError, # Base exception
|
|
315
|
+
TetherAPIError, # API request failures
|
|
316
|
+
TetherVerificationError, # Verification failures
|
|
317
|
+
TetherKeyError, # Private key issues
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
try:
|
|
321
|
+
result = client.verify()
|
|
322
|
+
except TetherAPIError as e:
|
|
323
|
+
# Handle API connectivity or server errors
|
|
324
|
+
print(f"API Error {e.status_code}: {e.message}")
|
|
325
|
+
except TetherVerificationError as e:
|
|
326
|
+
# Handle verification failures (invalid signature, etc.)
|
|
327
|
+
print(f"Verification failed: {e.message}")
|
|
328
|
+
except TetherKeyError as e:
|
|
329
|
+
# Handle private key loading or format errors
|
|
330
|
+
print(f"Key error: {e.message}")
|
|
331
|
+
except TetherError as e:
|
|
332
|
+
# Handle any other Tether-related errors
|
|
333
|
+
print(f"Tether error: {e.message}")
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## ๐ Requirements
|
|
337
|
+
|
|
338
|
+
- **Python**: 3.8+
|
|
339
|
+
- **Dependencies**: `httpx>=0.20.0`, `cryptography>=3.4.0`
|
|
340
|
+
- **Key Format**: RSA-2048 private key (PEM or DER)
|
|
341
|
+
|
|
342
|
+
## ๐ License
|
|
343
|
+
|
|
344
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
345
|
+
|
|
346
|
+
## ๐ค Contributing
|
|
347
|
+
|
|
348
|
+
Contributions welcome! Please see the [GitHub repository](https://github.com/Commit451/tether-name-python) for details.
|
|
349
|
+
|
|
350
|
+
## ๐ Links
|
|
351
|
+
|
|
352
|
+
- **๐ Tether.name**: [https://tether.name](https://tether.name)
|
|
353
|
+
- **๐ฆ PyPI Package**: [https://pypi.org/project/tether-name/](https://pypi.org/project/tether-name/)
|
|
354
|
+
- **๐ป Source Code**: [https://github.com/Commit451/tether-name-python](https://github.com/Commit451/tether-name-python)
|
|
355
|
+
- **๐ API Documentation**: [https://tether.name/docs](https://tether.name/docs)
|
|
356
|
+
- **โ Support**: [jawnnypoo@gmail.com](mailto:jawnnypoo@gmail.com)
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
**Ready to get started?** Register your AI agent at [tether.name](https://tether.name) and start building with cryptographic identity verification! ๐
|