glacis 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.
glacis/__init__.py ADDED
@@ -0,0 +1,88 @@
1
+ """
2
+ GLACIS SDK for Python
3
+
4
+ AI Compliance Attestation - hash locally, prove globally.
5
+
6
+ Example (online):
7
+ >>> from glacis import Glacis
8
+ >>> glacis = Glacis(api_key="glsk_live_xxx")
9
+ >>> receipt = glacis.attest(
10
+ ... service_id="my-ai-service",
11
+ ... operation_type="inference",
12
+ ... input={"prompt": "Hello, world!"},
13
+ ... output={"response": "Hi there!"},
14
+ ... )
15
+ >>> print(f"Verified at: {receipt.verify_url}")
16
+
17
+ Example (offline):
18
+ >>> from glacis import Glacis
19
+ >>> import os
20
+ >>> glacis = Glacis(mode="offline", signing_seed=os.urandom(32))
21
+ >>> receipt = glacis.attest(...) # Returns OfflineAttestReceipt
22
+ >>> result = glacis.verify(receipt) # witness_status="UNVERIFIED"
23
+
24
+ Async Example:
25
+ >>> from glacis import AsyncGlacis
26
+ >>> glacis = AsyncGlacis(api_key="glsk_live_xxx")
27
+ >>> receipt = await glacis.attest(...)
28
+
29
+ Streaming Example:
30
+ >>> from glacis import Glacis
31
+ >>> from glacis.streaming import StreamingSession
32
+ >>> glacis = Glacis(api_key="glsk_live_xxx")
33
+ >>> session = await StreamingSession.start(glacis, {
34
+ ... "service_id": "voice-assistant",
35
+ ... "operation_type": "completion",
36
+ ... "session_do_url": "https://session-do.glacis.dev",
37
+ ... })
38
+ >>> await session.attest_chunk(input=audio_chunk, output=transcript)
39
+ >>> receipt = await session.end(metadata={"duration": "00:05:23"})
40
+ """
41
+
42
+ from glacis.client import AsyncGlacis, Glacis, GlacisMode
43
+ from glacis.crypto import canonical_json, hash_payload
44
+ from glacis.models import (
45
+ AttestInput,
46
+ AttestReceipt,
47
+ GlacisConfig,
48
+ LogEntry,
49
+ LogQueryParams,
50
+ LogQueryResult,
51
+ MerkleInclusionProof,
52
+ OfflineAttestReceipt,
53
+ OfflineVerifyResult,
54
+ SignedTreeHead,
55
+ VerifyResult,
56
+ )
57
+ from glacis.storage import ReceiptStorage
58
+ from glacis.streaming import SessionContext, SessionReceipt, StreamingSession
59
+
60
+ __version__ = "0.2.0"
61
+
62
+ __all__ = [
63
+ # Main classes
64
+ "Glacis",
65
+ "AsyncGlacis",
66
+ "GlacisMode",
67
+ # Streaming
68
+ "StreamingSession",
69
+ "SessionContext",
70
+ "SessionReceipt",
71
+ # Storage (offline mode)
72
+ "ReceiptStorage",
73
+ # Models
74
+ "GlacisConfig",
75
+ "AttestInput",
76
+ "AttestReceipt",
77
+ "OfflineAttestReceipt",
78
+ "VerifyResult",
79
+ "OfflineVerifyResult",
80
+ "LogQueryParams",
81
+ "LogQueryResult",
82
+ "LogEntry",
83
+ "MerkleInclusionProof",
84
+ "SignedTreeHead",
85
+ # Crypto utilities
86
+ "canonical_json",
87
+ "hash_payload",
88
+ ]
glacis/__main__.py ADDED
@@ -0,0 +1,76 @@
1
+ """
2
+ Glacis CLI
3
+
4
+ Usage:
5
+ python -m glacis verify <receipt.json>
6
+ """
7
+
8
+ import argparse
9
+ import json
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ from glacis import Glacis
14
+ from glacis.models import AttestReceipt, OfflineAttestReceipt
15
+
16
+
17
+ def verify_command(args):
18
+ """Verify a receipt file."""
19
+ receipt_path = Path(args.receipt)
20
+
21
+ if not receipt_path.exists():
22
+ print(f"Error: File not found: {receipt_path}", file=sys.stderr)
23
+ sys.exit(1)
24
+
25
+ try:
26
+ with open(receipt_path) as f:
27
+ data = json.load(f)
28
+ except json.JSONDecodeError as e:
29
+ print(f"Error: Invalid JSON: {e}", file=sys.stderr)
30
+ sys.exit(1)
31
+
32
+ # Determine receipt type
33
+ if data.get("attestation_id", "").startswith("oatt_"):
34
+ receipt = OfflineAttestReceipt(**data)
35
+ glacis = Glacis(mode="offline")
36
+ else:
37
+ receipt = AttestReceipt(**data)
38
+ glacis = Glacis(mode="online")
39
+
40
+ # Verify
41
+ result = glacis.verify(receipt)
42
+
43
+ # Output
44
+ print(f"Receipt: {receipt.attestation_id}")
45
+ print(f"Type: {'Offline' if isinstance(receipt, OfflineAttestReceipt) else 'Online'}")
46
+ print()
47
+
48
+ if result.valid:
49
+ print("Status: VALID")
50
+ print(f" Signature: {'PASS' if result.signature_valid else 'FAIL'}")
51
+ if hasattr(result, "proof_valid") and result.proof_valid is not None:
52
+ print(f" Merkle proof: {'PASS' if result.proof_valid else 'FAIL'}")
53
+ else:
54
+ print("Status: INVALID")
55
+ if hasattr(result, "error"):
56
+ print(f" Error: {result.error}")
57
+ sys.exit(1)
58
+
59
+
60
+ def main():
61
+ parser = argparse.ArgumentParser(
62
+ prog="glacis", description="Glacis CLI - Cryptographic attestation for AI systems"
63
+ )
64
+ subparsers = parser.add_subparsers(dest="command", required=True)
65
+
66
+ # verify command
67
+ verify_parser = subparsers.add_parser("verify", help="Verify a receipt")
68
+ verify_parser.add_argument("receipt", help="Path to receipt JSON file")
69
+ verify_parser.set_defaults(func=verify_command)
70
+
71
+ args = parser.parse_args()
72
+ args.func(args)
73
+
74
+
75
+ if __name__ == "__main__":
76
+ main()