glacis 0.1.3__py3-none-any.whl → 0.2.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.
- glacis/__init__.py +62 -1
- glacis/__main__.py +1 -80
- glacis/client.py +60 -31
- glacis/config.py +141 -0
- glacis/controls/__init__.py +232 -0
- glacis/controls/base.py +104 -0
- glacis/controls/jailbreak.py +224 -0
- glacis/controls/pii.py +855 -0
- glacis/crypto.py +70 -1
- glacis/integrations/__init__.py +53 -3
- glacis/integrations/anthropic.py +207 -142
- glacis/integrations/base.py +476 -0
- glacis/integrations/openai.py +156 -121
- glacis/models.py +277 -24
- glacis/storage.py +324 -8
- glacis/verify.py +154 -0
- glacis-0.2.0.dist-info/METADATA +275 -0
- glacis-0.2.0.dist-info/RECORD +21 -0
- glacis/wasm/s3p_core_wasi.wasm +0 -0
- glacis/wasm_runtime.py +0 -533
- glacis-0.1.3.dist-info/METADATA +0 -324
- glacis-0.1.3.dist-info/RECORD +0 -16
- {glacis-0.1.3.dist-info → glacis-0.2.0.dist-info}/WHEEL +0 -0
- {glacis-0.1.3.dist-info → glacis-0.2.0.dist-info}/licenses/LICENSE +0 -0
glacis-0.1.3.dist-info/METADATA
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: glacis
|
|
3
|
-
Version: 0.1.3
|
|
4
|
-
Summary: GLACIS SDK for Python - AI Compliance Attestation
|
|
5
|
-
Project-URL: Homepage, https://glacis.io
|
|
6
|
-
Project-URL: Documentation, https://docs.glacis.io/sdk/python
|
|
7
|
-
Project-URL: Repository, https://github.com/Glacis-io/glacis-python
|
|
8
|
-
Project-URL: Issues, https://github.com/Glacis-io/glacis-python/issues
|
|
9
|
-
Author-email: GLACIS <sdk@glacis.io>
|
|
10
|
-
License-Expression: Apache-2.0
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Keywords: ai,attestation,compliance,logging,transparency
|
|
13
|
-
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
-
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
-
Classifier: Topic :: Security :: Cryptography
|
|
22
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
-
Requires-Python: >=3.9
|
|
24
|
-
Requires-Dist: httpx>=0.25.0
|
|
25
|
-
Requires-Dist: pydantic>=2.0.0
|
|
26
|
-
Requires-Dist: pynacl>=1.5.0
|
|
27
|
-
Provides-Extra: all
|
|
28
|
-
Requires-Dist: anthropic>=0.20.0; extra == 'all'
|
|
29
|
-
Requires-Dist: mypy>=1.0.0; extra == 'all'
|
|
30
|
-
Requires-Dist: openai>=1.0.0; extra == 'all'
|
|
31
|
-
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'all'
|
|
32
|
-
Requires-Dist: pytest-httpx>=0.22.0; extra == 'all'
|
|
33
|
-
Requires-Dist: pytest>=7.0.0; extra == 'all'
|
|
34
|
-
Requires-Dist: ruff>=0.1.0; extra == 'all'
|
|
35
|
-
Requires-Dist: wasmtime>=18.0.0; extra == 'all'
|
|
36
|
-
Provides-Extra: anthropic
|
|
37
|
-
Requires-Dist: anthropic>=0.20.0; extra == 'anthropic'
|
|
38
|
-
Provides-Extra: dev
|
|
39
|
-
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
40
|
-
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
41
|
-
Requires-Dist: pytest-httpx>=0.22.0; extra == 'dev'
|
|
42
|
-
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
43
|
-
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
44
|
-
Provides-Extra: openai
|
|
45
|
-
Requires-Dist: openai>=1.0.0; extra == 'openai'
|
|
46
|
-
Provides-Extra: wasm
|
|
47
|
-
Requires-Dist: wasmtime>=18.0.0; extra == 'wasm'
|
|
48
|
-
Description-Content-Type: text/markdown
|
|
49
|
-
|
|
50
|
-
# Glacis Python SDK
|
|
51
|
-
|
|
52
|
-
[](https://badge.fury.io/py/glacis)
|
|
53
|
-
[](https://github.com/Glacis-io/glacis-python/actions/workflows/test.yml)
|
|
54
|
-
[](https://www.python.org/downloads/)
|
|
55
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
56
|
-
|
|
57
|
-
**Cryptographic attestation for AI systems.** Prove what your AI did, what data it saw, and what controls were active - without sensitive data leaving your environment.
|
|
58
|
-
|
|
59
|
-
## Installation
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
pip install glacis
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
With provider integrations:
|
|
66
|
-
```bash
|
|
67
|
-
pip install glacis[openai] # OpenAI auto-attestation
|
|
68
|
-
pip install glacis[anthropic] # Anthropic auto-attestation
|
|
69
|
-
pip install glacis[all] # Everything
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Quick Start
|
|
73
|
-
|
|
74
|
-
### Offline Mode (No API Key Required)
|
|
75
|
-
|
|
76
|
-
Works immediately. Receipts are self-signed and marked "UNVERIFIED."
|
|
77
|
-
|
|
78
|
-
```python
|
|
79
|
-
from glacis import Glacis
|
|
80
|
-
|
|
81
|
-
glacis = Glacis(mode="offline")
|
|
82
|
-
|
|
83
|
-
# Attest an AI interaction
|
|
84
|
-
receipt = glacis.attest(
|
|
85
|
-
service_id="my-ai-app",
|
|
86
|
-
operation_type="inference",
|
|
87
|
-
input={"prompt": "Summarize this document..."}, # Hashed locally
|
|
88
|
-
output={"response": "The document discusses..."}, # Never sent
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
print(f"Receipt ID: {receipt.attestation_id}")
|
|
92
|
-
print(f"Witness status: {receipt.witness_status}") # "UNVERIFIED"
|
|
93
|
-
|
|
94
|
-
# Verify locally
|
|
95
|
-
result = glacis.verify(receipt)
|
|
96
|
-
print(f"Signature valid: {result.signature_valid}")
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Online Mode (Witnessed Attestation)
|
|
100
|
-
|
|
101
|
-
Add an API key for cryptographically witnessed receipts with Merkle proofs.
|
|
102
|
-
|
|
103
|
-
```python
|
|
104
|
-
from glacis import Glacis
|
|
105
|
-
|
|
106
|
-
glacis = Glacis(api_key="glsk_live_...") # Get yours at glacis.io
|
|
107
|
-
|
|
108
|
-
receipt = glacis.attest(
|
|
109
|
-
service_id="my-ai-app",
|
|
110
|
-
operation_type="inference",
|
|
111
|
-
input={"prompt": "..."},
|
|
112
|
-
output={"response": "..."},
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
print(f"Leaf index: {receipt.leaf_index}")
|
|
116
|
-
print(f"Merkle root: {receipt.signed_tree_head.root_hash}")
|
|
117
|
-
print(f"Badge URL: {receipt.badge_url}") # Shareable verification link
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Auto-Attesting OpenAI
|
|
121
|
-
|
|
122
|
-
```python
|
|
123
|
-
from glacis.integrations.openai import attested_openai, get_last_receipt
|
|
124
|
-
|
|
125
|
-
client = attested_openai(
|
|
126
|
-
glacis_api_key="glsk_live_...",
|
|
127
|
-
openai_api_key="sk-..."
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
response = client.chat.completions.create(
|
|
131
|
-
model="gpt-4",
|
|
132
|
-
messages=[{"role": "user", "content": "Hello!"}]
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
# Receipt is automatically created
|
|
136
|
-
receipt = get_last_receipt()
|
|
137
|
-
print(f"Attested: {receipt.badge_url}")
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Auto-Attesting Anthropic
|
|
141
|
-
|
|
142
|
-
```python
|
|
143
|
-
from glacis.integrations.anthropic import attested_anthropic, get_last_receipt
|
|
144
|
-
|
|
145
|
-
client = attested_anthropic(
|
|
146
|
-
glacis_api_key="glsk_live_...",
|
|
147
|
-
anthropic_api_key="sk-..."
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
response = client.messages.create(
|
|
151
|
-
model="claude-3-opus-20240229",
|
|
152
|
-
max_tokens=1024,
|
|
153
|
-
messages=[{"role": "user", "content": "Hello!"}]
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
receipt = get_last_receipt()
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## What Data Leaves Your Environment?
|
|
160
|
-
|
|
161
|
-
**Only hashes. Never payloads.**
|
|
162
|
-
|
|
163
|
-
| What | Sent to Glacis? |
|
|
164
|
-
|------|-----------------|
|
|
165
|
-
| Your prompts | No - SHA-256 hash only |
|
|
166
|
-
| Model responses | No - SHA-256 hash only |
|
|
167
|
-
| API keys | No |
|
|
168
|
-
| Metadata (service_id, operation_type) | Yes |
|
|
169
|
-
| Timestamps | Yes |
|
|
170
|
-
|
|
171
|
-
This is the "zero-egress" design. Your sensitive data stays local; only cryptographic commitments are transmitted for witnessing.
|
|
172
|
-
|
|
173
|
-
## Offline vs Online Mode
|
|
174
|
-
|
|
175
|
-
| Feature | Offline | Online |
|
|
176
|
-
|---------|---------|--------|
|
|
177
|
-
| API key required | No | Yes |
|
|
178
|
-
| Signing | Local Ed25519 | Glacis witness network |
|
|
179
|
-
| Merkle proofs | No | Yes |
|
|
180
|
-
| Transparency log | No | Yes |
|
|
181
|
-
| Verification URL | No | Yes |
|
|
182
|
-
| Witness status | "UNVERIFIED" | "VERIFIED" |
|
|
183
|
-
|
|
184
|
-
**Offline mode is fully functional** - correct crypto, local verification, production-grade Ed25519. The only difference is the absence of an independent witness anchor.
|
|
185
|
-
|
|
186
|
-
Use offline for development. Upgrade to online when you need third-party verifiability (audits, papers, customer due diligence).
|
|
187
|
-
|
|
188
|
-
## CLI
|
|
189
|
-
|
|
190
|
-
Verify a receipt:
|
|
191
|
-
```bash
|
|
192
|
-
python -m glacis verify receipt.json
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## Async Support
|
|
196
|
-
|
|
197
|
-
```python
|
|
198
|
-
from glacis import AsyncGlacis
|
|
199
|
-
|
|
200
|
-
async with AsyncGlacis(api_key="glsk_live_...") as glacis:
|
|
201
|
-
receipt = await glacis.attest(
|
|
202
|
-
service_id="my-service",
|
|
203
|
-
operation_type="inference",
|
|
204
|
-
input={"prompt": "Hello"},
|
|
205
|
-
output={"response": "Hi!"},
|
|
206
|
-
)
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Query the Transparency Log
|
|
210
|
-
|
|
211
|
-
```python
|
|
212
|
-
# Browse public attestations (no auth required)
|
|
213
|
-
result = glacis.query_log(
|
|
214
|
-
org_id="org_xxx",
|
|
215
|
-
service_id="my-service",
|
|
216
|
-
start="2024-01-01T00:00:00Z",
|
|
217
|
-
limit=100,
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
for entry in result.entries:
|
|
221
|
-
print(f"{entry.timestamp}: {entry.operation_type}")
|
|
222
|
-
|
|
223
|
-
# Get current tree state
|
|
224
|
-
tree = glacis.get_tree_head()
|
|
225
|
-
print(f"Tree size: {tree.size}")
|
|
226
|
-
print(f"Root hash: {tree.root_hash}")
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
## Cross-Runtime Hash Compatibility
|
|
230
|
-
|
|
231
|
-
The Python SDK produces identical hashes to the TypeScript and Rust SDKs:
|
|
232
|
-
|
|
233
|
-
```python
|
|
234
|
-
from glacis.crypto import hash_payload
|
|
235
|
-
|
|
236
|
-
# These all produce the same hash across Python, TypeScript, and Rust
|
|
237
|
-
hash1 = hash_payload({"b": 2, "a": 1})
|
|
238
|
-
hash2 = hash_payload({"a": 1, "b": 2})
|
|
239
|
-
assert hash1 == hash2 # Keys are sorted per RFC 8785
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## Security & Trust
|
|
243
|
-
|
|
244
|
-
- **Cryptography**: Ed25519 signatures via PyNaCl (libsodium) or WASM
|
|
245
|
-
- **Hashing**: SHA-256 with RFC 8785 canonical JSON (cross-runtime compatible)
|
|
246
|
-
- **Transparency**: Online receipts are included in an append-only Merkle tree (RFC 6962)
|
|
247
|
-
|
|
248
|
-
### Threat Model
|
|
249
|
-
|
|
250
|
-
Glacis provides cryptographic evidence that a specific operation occurred on a specific input/output pair at a specific time. It does not:
|
|
251
|
-
- Prevent AI from misbehaving (it attests, not enforces)
|
|
252
|
-
- Hide that an AI system exists (receipts are evidence of operation)
|
|
253
|
-
- Guarantee the AI output was correct (only that it was attested)
|
|
254
|
-
|
|
255
|
-
### Security Disclosure
|
|
256
|
-
|
|
257
|
-
Report vulnerabilities to security@glacis.io
|
|
258
|
-
|
|
259
|
-
## API Reference
|
|
260
|
-
|
|
261
|
-
### Glacis
|
|
262
|
-
|
|
263
|
-
```python
|
|
264
|
-
from glacis import Glacis
|
|
265
|
-
|
|
266
|
-
# Online mode (default)
|
|
267
|
-
glacis = Glacis(api_key="glsk_live_...")
|
|
268
|
-
|
|
269
|
-
# Offline mode
|
|
270
|
-
glacis = Glacis(mode="offline")
|
|
271
|
-
glacis = Glacis(mode="offline", signing_seed=os.urandom(32))
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
### glacis.attest()
|
|
275
|
-
|
|
276
|
-
```python
|
|
277
|
-
receipt = glacis.attest(
|
|
278
|
-
service_id="my-service", # Required
|
|
279
|
-
operation_type="inference", # Required
|
|
280
|
-
input={"prompt": "..."}, # Hashed, not sent
|
|
281
|
-
output={"response": "..."}, # Hashed, not sent
|
|
282
|
-
metadata={"model": "gpt-4"}, # Optional, sent as-is
|
|
283
|
-
)
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### glacis.verify()
|
|
287
|
-
|
|
288
|
-
```python
|
|
289
|
-
result = glacis.verify(receipt)
|
|
290
|
-
print(result.valid) # Overall validity
|
|
291
|
-
print(result.signature_valid) # Signature check
|
|
292
|
-
print(result.proof_valid) # Merkle proof check (online only)
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### AttestReceipt
|
|
296
|
-
|
|
297
|
-
| Field | Description |
|
|
298
|
-
|-------|-------------|
|
|
299
|
-
| `attestation_id` | Unique attestation ID |
|
|
300
|
-
| `timestamp` | ISO 8601 timestamp |
|
|
301
|
-
| `leaf_index` | Merkle tree leaf index |
|
|
302
|
-
| `merkle_proof` | Inclusion proof |
|
|
303
|
-
| `signed_tree_head` | Signed tree state |
|
|
304
|
-
| `badge_url` | Verification badge URL |
|
|
305
|
-
| `verify_url` | Verification endpoint |
|
|
306
|
-
|
|
307
|
-
## Pricing
|
|
308
|
-
|
|
309
|
-
| Tier | Price | Includes |
|
|
310
|
-
|------|-------|----------|
|
|
311
|
-
| Offline | Free | Local signing, "UNVERIFIED" status |
|
|
312
|
-
| Witnessed | Free, then usage-based | Independent witness, Merkle proofs, verification URLs |
|
|
313
|
-
| Enterprise | Custom | SLA, compliance exports, dedicated support |
|
|
314
|
-
|
|
315
|
-
Get started at [docs.glacis.io](https://docs.glacis.io/sdk/python/quickstart)
|
|
316
|
-
|
|
317
|
-
## License
|
|
318
|
-
|
|
319
|
-
Apache 2.0. See [LICENSE](LICENSE).
|
|
320
|
-
|
|
321
|
-
## Links
|
|
322
|
-
|
|
323
|
-
- [Documentation](https://docs.glacis.io)
|
|
324
|
-
- [Changelog](CHANGELOG.md)
|
glacis-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
glacis/__init__.py,sha256=9TLZCbUyUQ0JpqHBNiCjvkgt9HbiRRy3B03GMvxdlQ4,2465
|
|
2
|
-
glacis/__main__.py,sha256=GTA84o2Lx5md1kvI80ATu9yNDGidYtW808_TqOmIJSE,2969
|
|
3
|
-
glacis/client.py,sha256=hM3dokL7HZz3E8ovndvd-uHui31Hz8afv8IFGs4aH4U,27414
|
|
4
|
-
glacis/crypto.py,sha256=DiHIMGMKV616wpba0n7Niuw4t-Zz_q5ij4a7m4HDDvk,3579
|
|
5
|
-
glacis/models.py,sha256=S-n-anzfXJL03lENluNL0cbiXfVsPEsKZyh-dPBH93U,9792
|
|
6
|
-
glacis/storage.py,sha256=tsmlG8bAq5daN1o6I9vmppKhstURm3jcO4_oLhOiyPg,10253
|
|
7
|
-
glacis/streaming.py,sha256=hAmR4XHQixLia6awnFfCaA9hZOtCq2b-pOzgaMd3YzQ,11260
|
|
8
|
-
glacis/wasm_runtime.py,sha256=kJeFAomzhtC8zxJYWrnexRVMedSQkz5LXGUF43_9EeQ,17697
|
|
9
|
-
glacis/integrations/__init__.py,sha256=BeLSA6eGkpBWAIbXPodgS42yD_GpQ-IuXhrgF2271Ps,353
|
|
10
|
-
glacis/integrations/anthropic.py,sha256=xJo0Dgx4Y7TK9cQPfEaBXygX0X2lZs0D_pfioZ_P6AM,6927
|
|
11
|
-
glacis/integrations/openai.py,sha256=VkLtu8iQTMiAAa2pX7byC3je8BjzYiv-8_1T7sq3J4E,6941
|
|
12
|
-
glacis/wasm/s3p_core_wasi.wasm,sha256=gGrYI6hd0VkgqCg1mLADzSJP1pEUekkS-3PKd5mdBJo,253289
|
|
13
|
-
glacis-0.1.3.dist-info/METADATA,sha256=m-FzKjthqHXt9mP8Ungm1Ljai8qn8sg4wZmQeQ0b3nQ,9621
|
|
14
|
-
glacis-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
15
|
-
glacis-0.1.3.dist-info/licenses/LICENSE,sha256=B7g2sM9vz4NF1poTFNMil2cnkwMFel1qUnimyvYW1sw,10766
|
|
16
|
-
glacis-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|