h33 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.
h33-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 H33.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.
h33-0.1.0/MANIFEST.in ADDED
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include h33 *.py
h33-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: h33
3
+ Version: 0.1.0
4
+ Summary: H33 Post-Quantum Encryption SDK — Kyber + AES-256-GCM hybrid encryption, FHE biometrics, and more
5
+ Home-page: https://h33.ai
6
+ Author: H33.ai
7
+ Author-email: sdk@h33.ai
8
+ License: MIT
9
+ Project-URL: Homepage, https://h33.ai
10
+ Project-URL: Documentation, https://h33.ai/docs
11
+ Project-URL: API Reference, https://h33.ai/apis
12
+ Project-URL: Benchmarks, https://h33.ai/benchmarks
13
+ Project-URL: White Paper, https://h33.ai/white-paper
14
+ Project-URL: Source, https://github.com/h33-ai/h33-python-sdk
15
+ Project-URL: Issues, https://github.com/h33-ai/h33-python-sdk/issues
16
+ Keywords: post-quantum,encryption,cryptography,fhe,homomorphic-encryption,kyber,dilithium,biometrics,zero-knowledge,pqc,ml-kem,ml-dsa
17
+ Classifier: Development Status :: 4 - Beta
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Classifier: Topic :: Security :: Cryptography
28
+ Classifier: Topic :: Scientific/Engineering
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: requests>=2.25.0
33
+ Provides-Extra: fhe
34
+ Dynamic: author
35
+ Dynamic: author-email
36
+ Dynamic: classifier
37
+ Dynamic: description
38
+ Dynamic: description-content-type
39
+ Dynamic: home-page
40
+ Dynamic: keywords
41
+ Dynamic: license
42
+ Dynamic: license-file
43
+ Dynamic: project-url
44
+ Dynamic: provides-extra
45
+ Dynamic: requires-dist
46
+ Dynamic: requires-python
47
+ Dynamic: summary
48
+
49
+ # h33 — Post-Quantum Encryption SDK for Python
50
+
51
+ The official Python SDK for [H33](https://h33.ai), the post-quantum encryption platform delivering 1.6M authentications/sec with lattice-based cryptography.
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ pip install h33
57
+ ```
58
+
59
+ ## Quick Start
60
+
61
+ ```python
62
+ from h33 import H33Client
63
+
64
+ client = H33Client(api_key="h33_live_...", base_url="https://api.h33.ai")
65
+
66
+ # Post-quantum storage encryption (Kyber + AES-256-GCM)
67
+ result = client.encrypt_blob(b"sensitive data")
68
+ ciphertext = result["ciphertext_b64"]
69
+ key_id = result["key_id"]
70
+
71
+ # Decrypt
72
+ plaintext = client.decrypt_blob(ciphertext, key_id)
73
+ assert plaintext == b"sensitive data"
74
+ ```
75
+
76
+ ## Storage Encryption
77
+
78
+ Encrypt data at rest with hybrid post-quantum encryption (ML-KEM/Kyber + AES-256-GCM):
79
+
80
+ ```python
81
+ from h33 import StorageClient
82
+
83
+ storage = StorageClient(api_key="h33_live_...")
84
+
85
+ # Encrypt with optional authenticated data
86
+ result = storage.encrypt(b"patient record", aad=b"user:12345")
87
+ print(result["key_id"]) # Kyber key ID for decryption
88
+
89
+ # Decrypt
90
+ plaintext = storage.decrypt(result["ciphertext_b64"], result["key_id"], aad=b"user:12345")
91
+
92
+ # Field-level encryption with automatic sensitivity classification
93
+ fields = storage.encrypt_fields([
94
+ {"name": "ssn", "value": "123-45-6789"},
95
+ {"name": "name", "value": "Jane Doe"},
96
+ {"name": "email", "value": "jane@example.com"},
97
+ ])
98
+ # Each field gets a sensitivity level (Confidential, Internal, etc.)
99
+
100
+ # Key rotation — re-encrypt under the current active key
101
+ rotated = storage.rotate(result["ciphertext_b64"], result["key_id"])
102
+ ```
103
+
104
+ ## Client-Side FHE (Homomorphic Encryption)
105
+
106
+ Encrypt biometric embeddings on the client so the server never sees plaintext:
107
+
108
+ ```python
109
+ from h33 import FheEncryptor
110
+
111
+ # Load public key from H33 API
112
+ enc = FheEncryptor.from_public_key("public_key.json", embedding_dim=128)
113
+
114
+ # Encrypt a 128-dimensional face embedding
115
+ embedding = [0.1, 0.2, 0.03, ...] # from your ML model
116
+ ciphertext_json = enc.encrypt_embedding(embedding)
117
+
118
+ # Send ciphertext to H33 for matching — server operates on encrypted data
119
+ ```
120
+
121
+ Requires the `h33-fhe-client` native library. Build from source:
122
+
123
+ ```bash
124
+ cd h33-fhe-client && cargo build --release
125
+ ```
126
+
127
+ ## API Reference
128
+
129
+ ### H33Client
130
+
131
+ | Method | Description |
132
+ |--------|-------------|
133
+ | `health()` | Check API status |
134
+ | `send_code(phone)` | Send SMS OTP for authentication |
135
+ | `verify_code(phone, code)` | Verify OTP and get session |
136
+ | `create_key(label)` | Create a new API key |
137
+ | `list_keys()` | List all API keys |
138
+ | `revoke_key(key_id)` | Revoke an API key |
139
+ | `encrypt_blob(plaintext, aad)` | PQ-encrypt arbitrary data |
140
+ | `decrypt_blob(ciphertext_b64, key_id, aad)` | Decrypt PQ-encrypted data |
141
+ | `encrypt_fields(fields)` | Field-level PQ encryption |
142
+ | `rotate_encryption(ciphertext_b64, old_key_id, aad)` | Re-encrypt under current key |
143
+ | `fhe_schemes()` | List available FHE schemes |
144
+ | `noise_estimate(n, t, q_bits, operations)` | Estimate FHE noise budget |
145
+
146
+ ### StorageClient
147
+
148
+ Convenience wrapper for encryption-only workflows:
149
+
150
+ | Method | Description |
151
+ |--------|-------------|
152
+ | `encrypt(plaintext, aad)` | Encrypt bytes |
153
+ | `decrypt(ciphertext_b64, key_id, aad)` | Decrypt bytes |
154
+ | `encrypt_fields(fields)` | Field-level encryption |
155
+ | `rotate(ciphertext_b64, old_key_id, aad)` | Key rotation |
156
+
157
+ ## Platform
158
+
159
+ H33 is the world's fastest post-quantum authentication platform:
160
+
161
+ - **1.6M auth/sec** on AWS Graviton4 (96 vCPUs)
162
+ - **~42 microseconds** per authentication
163
+ - **Kyber + AES-256-GCM** hybrid encryption for data at rest
164
+ - **BFV Fully Homomorphic Encryption** for biometric matching on encrypted data
165
+ - **Dilithium digital signatures** for attestation
166
+ - **Zero-knowledge proofs** for privacy-preserving verification
167
+
168
+ Learn more at [h33.ai](https://h33.ai)
169
+
170
+ ## Documentation
171
+
172
+ - [H33 Platform](https://h33.ai)
173
+ - [API Documentation](https://h33.ai/docs)
174
+ - [FHE Overview](https://h33.ai/fhe)
175
+ - [Post-Quantum Cryptography](https://h33.ai/pqc)
176
+ - [White Paper](https://h33.ai/white-paper)
177
+ - [Benchmarks](https://h33.ai/benchmarks)
178
+
179
+ ## License
180
+
181
+ MIT — see [LICENSE](LICENSE)
h33-0.1.0/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # h33 — Post-Quantum Encryption SDK for Python
2
+
3
+ The official Python SDK for [H33](https://h33.ai), the post-quantum encryption platform delivering 1.6M authentications/sec with lattice-based cryptography.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install h33
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from h33 import H33Client
15
+
16
+ client = H33Client(api_key="h33_live_...", base_url="https://api.h33.ai")
17
+
18
+ # Post-quantum storage encryption (Kyber + AES-256-GCM)
19
+ result = client.encrypt_blob(b"sensitive data")
20
+ ciphertext = result["ciphertext_b64"]
21
+ key_id = result["key_id"]
22
+
23
+ # Decrypt
24
+ plaintext = client.decrypt_blob(ciphertext, key_id)
25
+ assert plaintext == b"sensitive data"
26
+ ```
27
+
28
+ ## Storage Encryption
29
+
30
+ Encrypt data at rest with hybrid post-quantum encryption (ML-KEM/Kyber + AES-256-GCM):
31
+
32
+ ```python
33
+ from h33 import StorageClient
34
+
35
+ storage = StorageClient(api_key="h33_live_...")
36
+
37
+ # Encrypt with optional authenticated data
38
+ result = storage.encrypt(b"patient record", aad=b"user:12345")
39
+ print(result["key_id"]) # Kyber key ID for decryption
40
+
41
+ # Decrypt
42
+ plaintext = storage.decrypt(result["ciphertext_b64"], result["key_id"], aad=b"user:12345")
43
+
44
+ # Field-level encryption with automatic sensitivity classification
45
+ fields = storage.encrypt_fields([
46
+ {"name": "ssn", "value": "123-45-6789"},
47
+ {"name": "name", "value": "Jane Doe"},
48
+ {"name": "email", "value": "jane@example.com"},
49
+ ])
50
+ # Each field gets a sensitivity level (Confidential, Internal, etc.)
51
+
52
+ # Key rotation — re-encrypt under the current active key
53
+ rotated = storage.rotate(result["ciphertext_b64"], result["key_id"])
54
+ ```
55
+
56
+ ## Client-Side FHE (Homomorphic Encryption)
57
+
58
+ Encrypt biometric embeddings on the client so the server never sees plaintext:
59
+
60
+ ```python
61
+ from h33 import FheEncryptor
62
+
63
+ # Load public key from H33 API
64
+ enc = FheEncryptor.from_public_key("public_key.json", embedding_dim=128)
65
+
66
+ # Encrypt a 128-dimensional face embedding
67
+ embedding = [0.1, 0.2, 0.03, ...] # from your ML model
68
+ ciphertext_json = enc.encrypt_embedding(embedding)
69
+
70
+ # Send ciphertext to H33 for matching — server operates on encrypted data
71
+ ```
72
+
73
+ Requires the `h33-fhe-client` native library. Build from source:
74
+
75
+ ```bash
76
+ cd h33-fhe-client && cargo build --release
77
+ ```
78
+
79
+ ## API Reference
80
+
81
+ ### H33Client
82
+
83
+ | Method | Description |
84
+ |--------|-------------|
85
+ | `health()` | Check API status |
86
+ | `send_code(phone)` | Send SMS OTP for authentication |
87
+ | `verify_code(phone, code)` | Verify OTP and get session |
88
+ | `create_key(label)` | Create a new API key |
89
+ | `list_keys()` | List all API keys |
90
+ | `revoke_key(key_id)` | Revoke an API key |
91
+ | `encrypt_blob(plaintext, aad)` | PQ-encrypt arbitrary data |
92
+ | `decrypt_blob(ciphertext_b64, key_id, aad)` | Decrypt PQ-encrypted data |
93
+ | `encrypt_fields(fields)` | Field-level PQ encryption |
94
+ | `rotate_encryption(ciphertext_b64, old_key_id, aad)` | Re-encrypt under current key |
95
+ | `fhe_schemes()` | List available FHE schemes |
96
+ | `noise_estimate(n, t, q_bits, operations)` | Estimate FHE noise budget |
97
+
98
+ ### StorageClient
99
+
100
+ Convenience wrapper for encryption-only workflows:
101
+
102
+ | Method | Description |
103
+ |--------|-------------|
104
+ | `encrypt(plaintext, aad)` | Encrypt bytes |
105
+ | `decrypt(ciphertext_b64, key_id, aad)` | Decrypt bytes |
106
+ | `encrypt_fields(fields)` | Field-level encryption |
107
+ | `rotate(ciphertext_b64, old_key_id, aad)` | Key rotation |
108
+
109
+ ## Platform
110
+
111
+ H33 is the world's fastest post-quantum authentication platform:
112
+
113
+ - **1.6M auth/sec** on AWS Graviton4 (96 vCPUs)
114
+ - **~42 microseconds** per authentication
115
+ - **Kyber + AES-256-GCM** hybrid encryption for data at rest
116
+ - **BFV Fully Homomorphic Encryption** for biometric matching on encrypted data
117
+ - **Dilithium digital signatures** for attestation
118
+ - **Zero-knowledge proofs** for privacy-preserving verification
119
+
120
+ Learn more at [h33.ai](https://h33.ai)
121
+
122
+ ## Documentation
123
+
124
+ - [H33 Platform](https://h33.ai)
125
+ - [API Documentation](https://h33.ai/docs)
126
+ - [FHE Overview](https://h33.ai/fhe)
127
+ - [Post-Quantum Cryptography](https://h33.ai/pqc)
128
+ - [White Paper](https://h33.ai/white-paper)
129
+ - [Benchmarks](https://h33.ai/benchmarks)
130
+
131
+ ## License
132
+
133
+ MIT — see [LICENSE](LICENSE)
@@ -0,0 +1,7 @@
1
+ """H33 Post-Quantum Encryption SDK for Python."""
2
+
3
+ from .client import H33Client
4
+ from .storage import StorageClient
5
+
6
+ __all__ = ["H33Client", "StorageClient"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,183 @@
1
+ """H33 API Client — HTTP client for the H33 post-quantum platform."""
2
+
3
+ import requests
4
+ from typing import Optional, Dict, Any
5
+
6
+
7
+ class H33Client:
8
+ """Main client for the H33 API.
9
+
10
+ Usage::
11
+
12
+ from h33 import H33Client
13
+
14
+ client = H33Client(api_key="h33_live_...", base_url="https://api.h33.ai")
15
+ result = client.health()
16
+ """
17
+
18
+ def __init__(
19
+ self,
20
+ api_key: str,
21
+ base_url: str = "https://api.h33.ai",
22
+ timeout: int = 30,
23
+ ):
24
+ self.base_url = base_url.rstrip("/")
25
+ self.api_key = api_key
26
+ self.timeout = timeout
27
+ self.session = requests.Session()
28
+ self.session.headers.update({
29
+ "Content-Type": "application/json",
30
+ "X-API-Key": api_key,
31
+ })
32
+
33
+ def _request(self, method: str, path: str, **kwargs) -> Dict[str, Any]:
34
+ url = f"{self.base_url}{path}"
35
+ kwargs.setdefault("timeout", self.timeout)
36
+ resp = self.session.request(method, url, **kwargs)
37
+ resp.raise_for_status()
38
+ return resp.json()
39
+
40
+ def health(self) -> Dict[str, Any]:
41
+ """Check API health."""
42
+ return self._request("GET", "/health")
43
+
44
+ # ── Auth (Onboarding) ─────────────────────────────────────────────────
45
+
46
+ def send_code(self, phone: str, country_code: str = "+1") -> Dict[str, Any]:
47
+ """Send SMS OTP verification code."""
48
+ return self._request("POST", "/api/auth/send-code", json={
49
+ "phone": phone,
50
+ "country_code": country_code,
51
+ })
52
+
53
+ def verify_code(self, phone: str, code: str) -> Dict[str, Any]:
54
+ """Verify OTP code and get auth cookies."""
55
+ return self._request("POST", "/api/auth/verify-code", json={
56
+ "phone": phone,
57
+ "code": code,
58
+ })
59
+
60
+ # ── Keys ──────────────────────────────────────────────────────────────
61
+
62
+ def create_key(self, label: str = "default") -> Dict[str, Any]:
63
+ """Create a new API key."""
64
+ return self._request("POST", "/api/keys/create", json={"label": label})
65
+
66
+ def list_keys(self) -> Dict[str, Any]:
67
+ """List all API keys."""
68
+ return self._request("GET", "/api/keys/list")
69
+
70
+ def revoke_key(self, key_id: str) -> Dict[str, Any]:
71
+ """Revoke an API key."""
72
+ return self._request("POST", "/api/keys/revoke", json={"key_id": key_id})
73
+
74
+ # ── Customer ──────────────────────────────────────────────────────────
75
+
76
+ def get_me(self) -> Dict[str, Any]:
77
+ """Get current customer profile."""
78
+ return self._request("GET", "/api/customer/me")
79
+
80
+ def get_usage(self) -> Dict[str, Any]:
81
+ """Get usage statistics."""
82
+ return self._request("GET", "/api/customer/usage")
83
+
84
+ # ── FHE ───────────────────────────────────────────────────────────────
85
+
86
+ def fhe_schemes(self) -> Dict[str, Any]:
87
+ """List available FHE schemes and parameters."""
88
+ return self._request("GET", "/api/fhe/schemes")
89
+
90
+ def noise_estimate(
91
+ self,
92
+ n: int,
93
+ t: int,
94
+ q_bits: list,
95
+ operations: list,
96
+ ) -> Dict[str, Any]:
97
+ """Estimate noise budget for a circuit.
98
+
99
+ Args:
100
+ n: Polynomial degree (e.g., 2048, 4096)
101
+ t: Plaintext modulus (e.g., 65537)
102
+ q_bits: Coefficient modulus bit sizes (e.g., [40, 40])
103
+ operations: List of operation names ("add", "multiply", "relinearize", etc.)
104
+ """
105
+ return self._request("POST", "/api/fhe/noise-estimate", json={
106
+ "n": n,
107
+ "t": t,
108
+ "q_bits": q_bits,
109
+ "operations": operations,
110
+ })
111
+
112
+ # ── Storage Encryption ────────────────────────────────────────────────
113
+
114
+ def encrypt_blob(
115
+ self,
116
+ plaintext: bytes,
117
+ aad: Optional[bytes] = None,
118
+ ) -> Dict[str, Any]:
119
+ """Encrypt data with post-quantum hybrid encryption (Kyber+AES-256-GCM).
120
+
121
+ Args:
122
+ plaintext: Raw bytes to encrypt
123
+ aad: Optional additional authenticated data
124
+
125
+ Returns:
126
+ {"ciphertext_b64": "...", "key_id": "..."}
127
+ """
128
+ import base64
129
+ body = {"plaintext_b64": base64.b64encode(plaintext).decode()}
130
+ if aad is not None:
131
+ body["aad"] = base64.b64encode(aad).decode()
132
+ return self._request("POST", "/api/storage/encrypt", json=body)
133
+
134
+ def decrypt_blob(
135
+ self,
136
+ ciphertext_b64: str,
137
+ key_id: str,
138
+ aad: Optional[bytes] = None,
139
+ ) -> bytes:
140
+ """Decrypt a PQ-encrypted blob.
141
+
142
+ Returns:
143
+ Decrypted plaintext bytes
144
+ """
145
+ import base64
146
+ body = {"ciphertext_b64": ciphertext_b64, "key_id": key_id}
147
+ if aad is not None:
148
+ body["aad"] = base64.b64encode(aad).decode()
149
+ result = self._request("POST", "/api/storage/decrypt", json=body)
150
+ return base64.b64decode(result["plaintext_b64"])
151
+
152
+ def encrypt_fields(
153
+ self,
154
+ fields: list,
155
+ ) -> Dict[str, Any]:
156
+ """Encrypt fields with automatic sensitivity classification.
157
+
158
+ Args:
159
+ fields: List of {"name": "ssn", "value": "123-45-6789"}
160
+
161
+ Returns:
162
+ {"fields": [{"name", "sensitivity", "ciphertext_b64"}], "key_id": "..."}
163
+ """
164
+ return self._request("POST", "/api/storage/encrypt-fields", json={
165
+ "fields": fields,
166
+ })
167
+
168
+ def rotate_encryption(
169
+ self,
170
+ ciphertext_b64: str,
171
+ old_key_id: str,
172
+ aad: Optional[bytes] = None,
173
+ ) -> Dict[str, Any]:
174
+ """Re-encrypt data under the current active key.
175
+
176
+ Returns:
177
+ {"ciphertext_b64": "...", "new_key_id": "..."}
178
+ """
179
+ import base64
180
+ body = {"ciphertext_b64": ciphertext_b64, "old_key_id": old_key_id}
181
+ if aad is not None:
182
+ body["aad"] = base64.b64encode(aad).decode()
183
+ return self._request("POST", "/api/storage/rotate", json=body)
h33-0.1.0/h33/fhe.py ADDED
@@ -0,0 +1,140 @@
1
+ """FHE Client — ctypes FFI to h33-fhe-client Rust cdylib.
2
+
3
+ Provides client-side BFV encryption for biometric embeddings and
4
+ other FHE operations without exposing plaintext to the server.
5
+
6
+ Requires the compiled cdylib (libh33_fhe_client.so / .dylib / .dll).
7
+ Build with: cd h33-fhe-client && cargo build --release
8
+
9
+ Usage::
10
+
11
+ from h33.fhe import FheEncryptor
12
+
13
+ enc = FheEncryptor.from_public_key("path/to/public_key.json")
14
+ ciphertext_json = enc.encrypt_embedding([0.1, 0.2, ...]) # 128-dim float vector
15
+ """
16
+
17
+ import ctypes
18
+ import json
19
+ import os
20
+ import sys
21
+ from typing import List, Optional
22
+
23
+
24
+ def _find_lib() -> Optional[str]:
25
+ """Search for the h33-fhe-client cdylib."""
26
+ names = {
27
+ "linux": "libh33_fhe_client.so",
28
+ "darwin": "libh33_fhe_client.dylib",
29
+ "win32": "h33_fhe_client.dll",
30
+ }
31
+ libname = names.get(sys.platform, "libh33_fhe_client.so")
32
+
33
+ # Check common locations
34
+ search_paths = [
35
+ os.path.join(os.path.dirname(__file__), "..", "..", "h33-fhe-client", "target", "release"),
36
+ os.path.join(os.path.dirname(__file__), ".."),
37
+ "/usr/local/lib",
38
+ "/usr/lib",
39
+ ]
40
+
41
+ for path in search_paths:
42
+ full = os.path.join(path, libname)
43
+ if os.path.exists(full):
44
+ return full
45
+ return None
46
+
47
+
48
+ class FheEncryptor:
49
+ """Client-side FHE encryptor using h33-fhe-client Rust cdylib via ctypes.
50
+
51
+ This encrypts data locally so the server never sees plaintext.
52
+ The server operates on encrypted data using homomorphic operations.
53
+ """
54
+
55
+ def __init__(self, handle, lib):
56
+ self._handle = handle
57
+ self._lib = lib
58
+
59
+ @classmethod
60
+ def from_public_key(cls, pk_json_path: str, embedding_dim: int = 128) -> "FheEncryptor":
61
+ """Load from a public key JSON file.
62
+
63
+ Args:
64
+ pk_json_path: Path to public key JSON (from /api/fhe/init)
65
+ embedding_dim: Embedding dimension (default 128)
66
+ """
67
+ lib_path = _find_lib()
68
+ if lib_path is None:
69
+ raise FileNotFoundError(
70
+ "h33-fhe-client cdylib not found. "
71
+ "Build it with: cd h33-fhe-client && cargo build --release"
72
+ )
73
+
74
+ lib = ctypes.CDLL(lib_path)
75
+
76
+ # Set up function signatures
77
+ lib.h33_encryptor_new.argtypes = [
78
+ ctypes.c_char_p, # public_key_json
79
+ ctypes.c_size_t, # json_len
80
+ ctypes.c_size_t, # embedding_dim
81
+ ctypes.POINTER(ctypes.c_void_p), # out_handle
82
+ ]
83
+ lib.h33_encryptor_new.restype = ctypes.c_int
84
+
85
+ lib.h33_encrypt_embedding.argtypes = [
86
+ ctypes.c_void_p, # handle
87
+ ctypes.POINTER(ctypes.c_float), # embedding
88
+ ctypes.c_size_t, # dim
89
+ ctypes.POINTER(ctypes.c_char_p), # out_json
90
+ ctypes.POINTER(ctypes.c_size_t), # out_len
91
+ ]
92
+ lib.h33_encrypt_embedding.restype = ctypes.c_int
93
+
94
+ lib.h33_encryptor_free.argtypes = [ctypes.c_void_p]
95
+ lib.h33_encryptor_free.restype = None
96
+
97
+ lib.h33_free_bytes.argtypes = [ctypes.c_char_p, ctypes.c_size_t]
98
+ lib.h33_free_bytes.restype = None
99
+
100
+ with open(pk_json_path, "rb") as f:
101
+ pk_json = f.read()
102
+
103
+ handle = ctypes.c_void_p()
104
+ rc = lib.h33_encryptor_new(pk_json, len(pk_json), embedding_dim, ctypes.byref(handle))
105
+ if rc != 0:
106
+ raise RuntimeError(f"h33_encryptor_new failed with code {rc}")
107
+
108
+ return cls(handle, lib)
109
+
110
+ def encrypt_embedding(self, embedding: List[float]) -> str:
111
+ """Encrypt a float embedding vector.
112
+
113
+ Args:
114
+ embedding: List of floats (must match embedding_dim)
115
+
116
+ Returns:
117
+ JSON string containing the encrypted ciphertext
118
+ """
119
+ arr = (ctypes.c_float * len(embedding))(*embedding)
120
+ out_json = ctypes.c_char_p()
121
+ out_len = ctypes.c_size_t()
122
+
123
+ rc = self._lib.h33_encrypt_embedding(
124
+ self._handle, arr, len(embedding),
125
+ ctypes.byref(out_json), ctypes.byref(out_len),
126
+ )
127
+ if rc != 0:
128
+ raise RuntimeError(f"h33_encrypt_embedding failed with code {rc}")
129
+
130
+ result = out_json.value[:out_len.value].decode("utf-8")
131
+
132
+ # Free the Rust-allocated buffer
133
+ self._lib.h33_free_bytes(out_json, out_len)
134
+
135
+ return result
136
+
137
+ def __del__(self):
138
+ if hasattr(self, "_handle") and self._handle:
139
+ self._lib.h33_encryptor_free(self._handle)
140
+ self._handle = None
@@ -0,0 +1,51 @@
1
+ """Standalone Storage Encryption Client.
2
+
3
+ Thin wrapper around H33Client's storage methods for users who only need
4
+ data-at-rest encryption without the full SDK.
5
+ """
6
+
7
+ from .client import H33Client
8
+ from typing import Optional, Dict, Any, List
9
+
10
+
11
+ class StorageClient:
12
+ """Post-quantum storage encryption client.
13
+
14
+ Usage::
15
+
16
+ from h33 import StorageClient
17
+
18
+ storage = StorageClient(api_key="h33_live_...")
19
+
20
+ # Encrypt
21
+ result = storage.encrypt(b"sensitive data")
22
+ ciphertext = result["ciphertext_b64"]
23
+ key_id = result["key_id"]
24
+
25
+ # Decrypt
26
+ plaintext = storage.decrypt(ciphertext, key_id)
27
+ assert plaintext == b"sensitive data"
28
+ """
29
+
30
+ def __init__(
31
+ self,
32
+ api_key: str,
33
+ base_url: str = "https://api.h33.ai",
34
+ ):
35
+ self._client = H33Client(api_key=api_key, base_url=base_url)
36
+
37
+ def encrypt(self, plaintext: bytes, aad: Optional[bytes] = None) -> Dict[str, Any]:
38
+ """Encrypt data with Kyber+AES-256-GCM."""
39
+ return self._client.encrypt_blob(plaintext, aad)
40
+
41
+ def decrypt(self, ciphertext_b64: str, key_id: str, aad: Optional[bytes] = None) -> bytes:
42
+ """Decrypt PQ-encrypted data."""
43
+ return self._client.decrypt_blob(ciphertext_b64, key_id, aad)
44
+
45
+ def encrypt_fields(self, fields: List[Dict[str, str]]) -> Dict[str, Any]:
46
+ """Encrypt fields with sensitivity classification."""
47
+ return self._client.encrypt_fields(fields)
48
+
49
+ def rotate(self, ciphertext_b64: str, old_key_id: str, aad: Optional[bytes] = None) -> Dict[str, Any]:
50
+ """Re-encrypt under current active key."""
51
+ return self._client.rotate_encryption(ciphertext_b64, old_key_id, aad)
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: h33
3
+ Version: 0.1.0
4
+ Summary: H33 Post-Quantum Encryption SDK — Kyber + AES-256-GCM hybrid encryption, FHE biometrics, and more
5
+ Home-page: https://h33.ai
6
+ Author: H33.ai
7
+ Author-email: sdk@h33.ai
8
+ License: MIT
9
+ Project-URL: Homepage, https://h33.ai
10
+ Project-URL: Documentation, https://h33.ai/docs
11
+ Project-URL: API Reference, https://h33.ai/apis
12
+ Project-URL: Benchmarks, https://h33.ai/benchmarks
13
+ Project-URL: White Paper, https://h33.ai/white-paper
14
+ Project-URL: Source, https://github.com/h33-ai/h33-python-sdk
15
+ Project-URL: Issues, https://github.com/h33-ai/h33-python-sdk/issues
16
+ Keywords: post-quantum,encryption,cryptography,fhe,homomorphic-encryption,kyber,dilithium,biometrics,zero-knowledge,pqc,ml-kem,ml-dsa
17
+ Classifier: Development Status :: 4 - Beta
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Classifier: Topic :: Security :: Cryptography
28
+ Classifier: Topic :: Scientific/Engineering
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: requests>=2.25.0
33
+ Provides-Extra: fhe
34
+ Dynamic: author
35
+ Dynamic: author-email
36
+ Dynamic: classifier
37
+ Dynamic: description
38
+ Dynamic: description-content-type
39
+ Dynamic: home-page
40
+ Dynamic: keywords
41
+ Dynamic: license
42
+ Dynamic: license-file
43
+ Dynamic: project-url
44
+ Dynamic: provides-extra
45
+ Dynamic: requires-dist
46
+ Dynamic: requires-python
47
+ Dynamic: summary
48
+
49
+ # h33 — Post-Quantum Encryption SDK for Python
50
+
51
+ The official Python SDK for [H33](https://h33.ai), the post-quantum encryption platform delivering 1.6M authentications/sec with lattice-based cryptography.
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ pip install h33
57
+ ```
58
+
59
+ ## Quick Start
60
+
61
+ ```python
62
+ from h33 import H33Client
63
+
64
+ client = H33Client(api_key="h33_live_...", base_url="https://api.h33.ai")
65
+
66
+ # Post-quantum storage encryption (Kyber + AES-256-GCM)
67
+ result = client.encrypt_blob(b"sensitive data")
68
+ ciphertext = result["ciphertext_b64"]
69
+ key_id = result["key_id"]
70
+
71
+ # Decrypt
72
+ plaintext = client.decrypt_blob(ciphertext, key_id)
73
+ assert plaintext == b"sensitive data"
74
+ ```
75
+
76
+ ## Storage Encryption
77
+
78
+ Encrypt data at rest with hybrid post-quantum encryption (ML-KEM/Kyber + AES-256-GCM):
79
+
80
+ ```python
81
+ from h33 import StorageClient
82
+
83
+ storage = StorageClient(api_key="h33_live_...")
84
+
85
+ # Encrypt with optional authenticated data
86
+ result = storage.encrypt(b"patient record", aad=b"user:12345")
87
+ print(result["key_id"]) # Kyber key ID for decryption
88
+
89
+ # Decrypt
90
+ plaintext = storage.decrypt(result["ciphertext_b64"], result["key_id"], aad=b"user:12345")
91
+
92
+ # Field-level encryption with automatic sensitivity classification
93
+ fields = storage.encrypt_fields([
94
+ {"name": "ssn", "value": "123-45-6789"},
95
+ {"name": "name", "value": "Jane Doe"},
96
+ {"name": "email", "value": "jane@example.com"},
97
+ ])
98
+ # Each field gets a sensitivity level (Confidential, Internal, etc.)
99
+
100
+ # Key rotation — re-encrypt under the current active key
101
+ rotated = storage.rotate(result["ciphertext_b64"], result["key_id"])
102
+ ```
103
+
104
+ ## Client-Side FHE (Homomorphic Encryption)
105
+
106
+ Encrypt biometric embeddings on the client so the server never sees plaintext:
107
+
108
+ ```python
109
+ from h33 import FheEncryptor
110
+
111
+ # Load public key from H33 API
112
+ enc = FheEncryptor.from_public_key("public_key.json", embedding_dim=128)
113
+
114
+ # Encrypt a 128-dimensional face embedding
115
+ embedding = [0.1, 0.2, 0.03, ...] # from your ML model
116
+ ciphertext_json = enc.encrypt_embedding(embedding)
117
+
118
+ # Send ciphertext to H33 for matching — server operates on encrypted data
119
+ ```
120
+
121
+ Requires the `h33-fhe-client` native library. Build from source:
122
+
123
+ ```bash
124
+ cd h33-fhe-client && cargo build --release
125
+ ```
126
+
127
+ ## API Reference
128
+
129
+ ### H33Client
130
+
131
+ | Method | Description |
132
+ |--------|-------------|
133
+ | `health()` | Check API status |
134
+ | `send_code(phone)` | Send SMS OTP for authentication |
135
+ | `verify_code(phone, code)` | Verify OTP and get session |
136
+ | `create_key(label)` | Create a new API key |
137
+ | `list_keys()` | List all API keys |
138
+ | `revoke_key(key_id)` | Revoke an API key |
139
+ | `encrypt_blob(plaintext, aad)` | PQ-encrypt arbitrary data |
140
+ | `decrypt_blob(ciphertext_b64, key_id, aad)` | Decrypt PQ-encrypted data |
141
+ | `encrypt_fields(fields)` | Field-level PQ encryption |
142
+ | `rotate_encryption(ciphertext_b64, old_key_id, aad)` | Re-encrypt under current key |
143
+ | `fhe_schemes()` | List available FHE schemes |
144
+ | `noise_estimate(n, t, q_bits, operations)` | Estimate FHE noise budget |
145
+
146
+ ### StorageClient
147
+
148
+ Convenience wrapper for encryption-only workflows:
149
+
150
+ | Method | Description |
151
+ |--------|-------------|
152
+ | `encrypt(plaintext, aad)` | Encrypt bytes |
153
+ | `decrypt(ciphertext_b64, key_id, aad)` | Decrypt bytes |
154
+ | `encrypt_fields(fields)` | Field-level encryption |
155
+ | `rotate(ciphertext_b64, old_key_id, aad)` | Key rotation |
156
+
157
+ ## Platform
158
+
159
+ H33 is the world's fastest post-quantum authentication platform:
160
+
161
+ - **1.6M auth/sec** on AWS Graviton4 (96 vCPUs)
162
+ - **~42 microseconds** per authentication
163
+ - **Kyber + AES-256-GCM** hybrid encryption for data at rest
164
+ - **BFV Fully Homomorphic Encryption** for biometric matching on encrypted data
165
+ - **Dilithium digital signatures** for attestation
166
+ - **Zero-knowledge proofs** for privacy-preserving verification
167
+
168
+ Learn more at [h33.ai](https://h33.ai)
169
+
170
+ ## Documentation
171
+
172
+ - [H33 Platform](https://h33.ai)
173
+ - [API Documentation](https://h33.ai/docs)
174
+ - [FHE Overview](https://h33.ai/fhe)
175
+ - [Post-Quantum Cryptography](https://h33.ai/pqc)
176
+ - [White Paper](https://h33.ai/white-paper)
177
+ - [Benchmarks](https://h33.ai/benchmarks)
178
+
179
+ ## License
180
+
181
+ MIT — see [LICENSE](LICENSE)
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ setup.py
5
+ h33/__init__.py
6
+ h33/client.py
7
+ h33/fhe.py
8
+ h33/storage.py
9
+ h33.egg-info/PKG-INFO
10
+ h33.egg-info/SOURCES.txt
11
+ h33.egg-info/dependency_links.txt
12
+ h33.egg-info/requires.txt
13
+ h33.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ requests>=2.25.0
2
+
3
+ [fhe]
@@ -0,0 +1 @@
1
+ h33
h33-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
h33-0.1.0/setup.py ADDED
@@ -0,0 +1,55 @@
1
+ from setuptools import setup, find_packages
2
+ import os
3
+
4
+ here = os.path.abspath(os.path.dirname(__file__))
5
+ with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
6
+ long_description = f.read()
7
+
8
+ setup(
9
+ name="h33",
10
+ version="0.1.0",
11
+ description="H33 Post-Quantum Encryption SDK — Kyber + AES-256-GCM hybrid encryption, FHE biometrics, and more",
12
+ long_description=long_description,
13
+ long_description_content_type="text/markdown",
14
+ author="H33.ai",
15
+ author_email="sdk@h33.ai",
16
+ url="https://h33.ai",
17
+ license="MIT",
18
+ packages=find_packages(),
19
+ include_package_data=True,
20
+ python_requires=">=3.8",
21
+ install_requires=[
22
+ "requests>=2.25.0",
23
+ ],
24
+ extras_require={
25
+ "fhe": [], # ctypes FFI to h33-fhe-client cdylib (no extra pip deps)
26
+ },
27
+ keywords=[
28
+ "post-quantum", "encryption", "cryptography", "fhe",
29
+ "homomorphic-encryption", "kyber", "dilithium", "biometrics",
30
+ "zero-knowledge", "pqc", "ml-kem", "ml-dsa",
31
+ ],
32
+ project_urls={
33
+ "Homepage": "https://h33.ai",
34
+ "Documentation": "https://h33.ai/docs",
35
+ "API Reference": "https://h33.ai/apis",
36
+ "Benchmarks": "https://h33.ai/benchmarks",
37
+ "White Paper": "https://h33.ai/white-paper",
38
+ "Source": "https://github.com/h33-ai/h33-python-sdk",
39
+ "Issues": "https://github.com/h33-ai/h33-python-sdk/issues",
40
+ },
41
+ classifiers=[
42
+ "Development Status :: 4 - Beta",
43
+ "Intended Audience :: Developers",
44
+ "Intended Audience :: Science/Research",
45
+ "License :: OSI Approved :: MIT License",
46
+ "Programming Language :: Python :: 3",
47
+ "Programming Language :: Python :: 3.8",
48
+ "Programming Language :: Python :: 3.9",
49
+ "Programming Language :: Python :: 3.10",
50
+ "Programming Language :: Python :: 3.11",
51
+ "Programming Language :: Python :: 3.12",
52
+ "Topic :: Security :: Cryptography",
53
+ "Topic :: Scientific/Engineering",
54
+ ],
55
+ )