sibna 1.0.0__tar.gz → 1.4.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.
sibna-1.4.0/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of developing the
55
+ Work, excluding communication that is conspicuously marked or otherwise
56
+ designated in writing by the copyright owner as "Not a Contribution."
57
+
58
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
59
+ whom a Contribution has been received by the Licensor and included
60
+ within the Work.
61
+
62
+ 2. Grant of Copyright License. Subject to the terms and conditions of
63
+ this License, each Contributor hereby grants to You a perpetual,
64
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
65
+ copyright license to reproduce, prepare Derivative Works of,
66
+ publicly display, publicly perform, sublicense, and distribute the
67
+ Work and such Derivative Works in Source or Object form.
68
+
69
+ 3. Grant of Patent License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ (except as stated in this section) patent license to make, have made,
73
+ use, offer to sell, sell, import, and otherwise transfer the Work,
74
+ where such license applies only to those patent claims licensable
75
+ by such Contributor that are necessarily infringed by their
76
+ Contribution(s) alone or by the combination of their Contribution(s)
77
+ with the Work to which such Contribution(s) was submitted. If You
78
+ institute patent litigation against any entity (including a cross-claim
79
+ or counterclaim in a lawsuit) alleging that the Work or any other
80
+ Contribution embodied in the Work constitutes patent or contributory
81
+ patent infringement, then any patent licenses granted to You under
82
+ this License for that Work shall terminate as of the date such
83
+ litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative
91
+ Works a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as a part of its
103
+ distribution, You must include a readable copy of the
104
+ attribution notices contained within such NOTICE file, in
105
+ at least one of the following places: within a NOTICE text
106
+ file distributed as part of the Derivative Works; within
107
+ the Source form or documentation, if provided along with the
108
+ Derivative Works; or, within a display generated by the
109
+ Derivative Works, if and wherever such third-party notices
110
+ normally appear. The contents of the NOTICE file are for
111
+ informational purposes only and do not modify the License.
112
+ You may add Your own attribution notices within Derivative
113
+ Works that You distribute, alongside or in addition to the
114
+ NOTICE text from the Work, provided that such additional
115
+ attribution notices cannot be construed as modifying the License.
116
+
117
+ You may add Your own license statement for Your Contribution(s)
118
+ and may provide additional grant of rights not granted by this License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
121
+ any Contribution intentionally submitted for inclusion in the Work
122
+ by You to the Licensor shall be under the terms and conditions of
123
+ this License, without any additional terms or conditions.
124
+
125
+ 6. Trademarks. This License does not grant permission to use the trade
126
+ names, trademarks, service marks, or product names of the Licensor,
127
+ except as required for reasonable and customary use in describing the
128
+ origin of the Work and reproducing the content of the NOTICE file.
129
+
130
+ 7. Disclaimer of Warranty. Unless required by applicable law or
131
+ agreed to in writing, Licensor provides the Work (and each
132
+ Contributor provides its Contributions) on an "AS IS" BASIS,
133
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
134
+ implied, including, without limitation, any warranties or conditions
135
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
136
+ PARTICULAR PURPOSE. You are solely responsible for determining the
137
+ appropriateness of using or reproducing the Work and assume any
138
+ risks associated with Your exercise of permissions under this License.
139
+
140
+ 8. Limitation of Liability. In no event and under no legal theory,
141
+ whether in tort (including negligence), contract, or otherwise,
142
+ unless required by applicable law (such as deliberate and grossly
143
+ negligent acts) or agreed to in writing, shall any Contributor be
144
+ liable to You for damages, including any direct, indirect, special,
145
+ incidental, or exemplary damages of any character arising as a result
146
+ of this License or out of the use or inability to use the Work
147
+ (including but not limited to damages for loss of goodwill, work
148
+ stoppage, computer failure or malfunction, or all other commercial
149
+ damages or losses), even if such Contributor has been advised of the
150
+ possibility of such damages.
151
+
152
+ 9. Accepting Warranty or Liability. While redistributing the Work or
153
+ Derivative Works thereof, You may choose to offer, and charge a fee
154
+ for, acceptance of support, warranty, indemnity, or other liability
155
+ obligations and/or rights consistent with this License. However, in
156
+ accepting such obligations, You may charge a fee on behalf of the
157
+ Licensor or on behalf of such obligated party, and only if You agree
158
+ to indemnify, defend, and hold each Contributor harmless for any
159
+ liability incurred by, or claims asserted against, such Contributor
160
+ by reason of your accepting any warranty or additional liability.
161
+
162
+ END OF TERMS AND CONDITIONS
163
+
164
+ Copyright 2024 Sibna Security Team
165
+
166
+ Licensed under the Apache License, Version 2.0 (the "License");
167
+ you may not use this file except in compliance with the License.
168
+ You may obtain a copy of the License at
169
+
170
+ http://www.apache.org/licenses/LICENSE-2.0
171
+
172
+ Unless required by applicable law or agreed to in writing, software
173
+ distributed under the License is distributed on an "AS IS" BASIS,
174
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
175
+ See the License for the specific language governing permissions and
176
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include sibna *.dll *.so *.dylib
sibna-1.4.0/PKG-INFO ADDED
@@ -0,0 +1,396 @@
1
+ Metadata-Version: 2.4
2
+ Name: sibna
3
+ Version: 1.4.0
4
+ Summary: Standalone Ultra-Secure Communication Protocol - Python SDK
5
+ Author-email: Sibna Security Team <security@sibna.dev>
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship made available under
41
+ the License, as indicated by a copyright notice that is included in
42
+ or attached to the work (an example is provided in the Appendix below).
43
+
44
+ "Derivative Works" shall mean any work, whether in Source or Object
45
+ form, that is based on (or derived from) the Work and for which the
46
+ editorial revisions, annotations, elaborations, or other modifications
47
+ represent, as a whole, an original work of authorship. For the purposes
48
+ of this License, Derivative Works shall not include works that remain
49
+ separable from, or merely link (or bind by name) to the interfaces of,
50
+ the Work and Derivative Works thereof.
51
+
52
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
53
+ in the Work by the copyright owner or by an individual or Legal Entity
54
+ authorized to submit on behalf of the copyright owner. For the purposes
55
+ of this definition, "submitted" means any form of electronic, verbal,
56
+ or written communication sent to the Licensor or its representatives,
57
+ including but not limited to communication on electronic mailing lists,
58
+ source code control systems, and issue tracking systems that are managed
59
+ by, or on behalf of, the Licensor for the purpose of developing the
60
+ Work, excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
64
+ whom a Contribution has been received by the Licensor and included
65
+ within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by the combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a cross-claim
84
+ or counterclaim in a lawsuit) alleging that the Work or any other
85
+ Contribution embodied in the Work constitutes patent or contributory
86
+ patent infringement, then any patent licenses granted to You under
87
+ this License for that Work shall terminate as of the date such
88
+ litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or Derivative
96
+ Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as a part of its
108
+ distribution, You must include a readable copy of the
109
+ attribution notices contained within such NOTICE file, in
110
+ at least one of the following places: within a NOTICE text
111
+ file distributed as part of the Derivative Works; within
112
+ the Source form or documentation, if provided along with the
113
+ Derivative Works; or, within a display generated by the
114
+ Derivative Works, if and wherever such third-party notices
115
+ normally appear. The contents of the NOTICE file are for
116
+ informational purposes only and do not modify the License.
117
+ You may add Your own attribution notices within Derivative
118
+ Works that You distribute, alongside or in addition to the
119
+ NOTICE text from the Work, provided that such additional
120
+ attribution notices cannot be construed as modifying the License.
121
+
122
+ You may add Your own license statement for Your Contribution(s)
123
+ and may provide additional grant of rights not granted by this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, without limitation, any warranties or conditions
140
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
141
+ PARTICULAR PURPOSE. You are solely responsible for determining the
142
+ appropriateness of using or reproducing the Work and assume any
143
+ risks associated with Your exercise of permissions under this License.
144
+
145
+ 8. Limitation of Liability. In no event and under no legal theory,
146
+ whether in tort (including negligence), contract, or otherwise,
147
+ unless required by applicable law (such as deliberate and grossly
148
+ negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special,
150
+ incidental, or exemplary damages of any character arising as a result
151
+ of this License or out of the use or inability to use the Work
152
+ (including but not limited to damages for loss of goodwill, work
153
+ stoppage, computer failure or malfunction, or all other commercial
154
+ damages or losses), even if such Contributor has been advised of the
155
+ possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Liability. While redistributing the Work or
158
+ Derivative Works thereof, You may choose to offer, and charge a fee
159
+ for, acceptance of support, warranty, indemnity, or other liability
160
+ obligations and/or rights consistent with this License. However, in
161
+ accepting such obligations, You may charge a fee on behalf of the
162
+ Licensor or on behalf of such obligated party, and only if You agree
163
+ to indemnify, defend, and hold each Contributor harmless for any
164
+ liability incurred by, or claims asserted against, such Contributor
165
+ by reason of your accepting any warranty or additional liability.
166
+
167
+ END OF TERMS AND CONDITIONS
168
+
169
+ Copyright 2024 Sibna Security Team
170
+
171
+ Licensed under the Apache License, Version 2.0 (the "License");
172
+ you may not use this file except in compliance with the License.
173
+ You may obtain a copy of the License at
174
+
175
+ http://www.apache.org/licenses/LICENSE-2.0
176
+
177
+ Unless required by applicable law or agreed to in writing, software
178
+ distributed under the License is distributed on an "AS IS" BASIS,
179
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
180
+ See the License for the specific language governing permissions and
181
+ limitations under the License.
182
+
183
+ Project-URL: Homepage, https://github.com/SibnaOfficial/libsa
184
+ Project-URL: Repository, https://github.com/SibnaOfficial/libsa
185
+ Project-URL: Bug Tracker, https://github.com/SibnaOfficial/libsa/issues
186
+ Project-URL: Changelog, https://github.com/SibnaOfficial/libsa/releases
187
+ Keywords: cryptography,encryption,signal-protocol,secure-messaging,e2ee,end-to-end-encryption,x3dh,double-ratchet,chacha20
188
+ Classifier: Development Status :: 5 - Production/Stable
189
+ Classifier: Intended Audience :: Developers
190
+ Classifier: Intended Audience :: Information Technology
191
+ Classifier: Topic :: Security :: Cryptography
192
+ Classifier: Topic :: Communications
193
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
194
+ Classifier: Programming Language :: Python :: 3
195
+ Classifier: Programming Language :: Python :: 3.8
196
+ Classifier: Programming Language :: Python :: 3.9
197
+ Classifier: Programming Language :: Python :: 3.10
198
+ Classifier: Programming Language :: Python :: 3.11
199
+ Classifier: Programming Language :: Python :: 3.12
200
+ Classifier: Programming Language :: Python :: 3 :: Only
201
+ Classifier: Operating System :: OS Independent
202
+ Classifier: Operating System :: Microsoft :: Windows
203
+ Classifier: Operating System :: POSIX :: Linux
204
+ Classifier: Operating System :: MacOS
205
+ Requires-Python: >=3.8
206
+ Description-Content-Type: text/markdown
207
+ License-File: LICENSE
208
+ Dynamic: license-file
209
+
210
+ # Sibna Protocol — Python SDK
211
+
212
+ Python SDK for the Sibna encrypted communication protocol.
213
+
214
+ ---
215
+
216
+ ## Before You Start — What You Need
217
+
218
+ This SDK **does not work standalone**. It requires a compiled native library built from the `sibna-protc` Rust project:
219
+
220
+ | OS | Required File |
221
+ |---------|------------------------|
222
+ | Windows | `sibna_core.dll` |
223
+ | Linux | `libsibna_core.so` |
224
+ | macOS | `libsibna_core.dylib` |
225
+
226
+ **To build the library:**
227
+ ```bash
228
+ cd sibna-protc/core
229
+ cargo build --release --features ffi
230
+ # Output is in: target/release/
231
+ ```
232
+ Then copy the resulting file into the same `sibna/` folder as this SDK.
233
+
234
+ ---
235
+
236
+ ## Installation
237
+
238
+ ```bash
239
+ # External dependencies (this SDK is NOT zero-dependencies)
240
+ pip install cryptography # For Identity + signature verification
241
+ pip install requests # For the sync HTTP client
242
+ pip install aiohttp # For async + WebSocket
243
+ ```
244
+
245
+ ---
246
+
247
+ ## What This SDK Does
248
+
249
+ ### `sibna` (core — requires the compiled native library)
250
+
251
+ | Function / Class | What it does |
252
+ |------------------|--------------|
253
+ | `is_available()` | Checks if the native library is loaded |
254
+ | `generate_key()` | Generates a random 32-byte key |
255
+ | `encrypt(key, data)` | Encrypts data (ChaCha20-Poly1305) |
256
+ | `decrypt(key, data)` | Decrypts data |
257
+ | `random_bytes(n)` | Generates cryptographically secure random bytes |
258
+ | `Context()` | Manages identity and encrypted sessions |
259
+ | `Context.generate_identity()` | Generates an identity keypair (Ed25519 + X25519) |
260
+ | `Context.generate_prekey_bundle()` | Generates a bundle to upload to the prekey server |
261
+ | `Context.perform_handshake(...)` | Runs X3DH and creates a Double Ratchet session |
262
+ | `Context.session_encrypt(...)` | Encrypts a message over an existing session |
263
+ | `Context.session_decrypt(...)` | Decrypts a message |
264
+
265
+ ### `sibna.client` (networking — requires `requests` / `aiohttp`)
266
+
267
+ | Class | What it does |
268
+ |-------|--------------|
269
+ | `Identity` | Ed25519 keypair for server authentication |
270
+ | `SibnaClient` | Synchronous HTTP client |
271
+ | `AsyncSibnaClient` | Async + WebSocket client |
272
+
273
+ ---
274
+
275
+ ## Basic Example — Simple Encryption
276
+
277
+ ```python
278
+ import sibna
279
+
280
+ # Check the library is available
281
+ if not sibna.is_available():
282
+ raise RuntimeError("Native library not found. Build it from sibna-protc first.")
283
+
284
+ # Encrypt and decrypt
285
+ key = sibna.generate_key() # Random 32-byte key
286
+ ct = sibna.encrypt(key, b"Hello")
287
+ pt = sibna.decrypt(key, ct)
288
+ assert pt == b"Hello"
289
+
290
+ # With associated data (authenticated but not encrypted)
291
+ ct = sibna.encrypt(key, b"Secret", associated_data=b"context-header")
292
+ pt = sibna.decrypt(key, ct, associated_data=b"context-header")
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Advanced Example — Double Ratchet Session
298
+
299
+ ```python
300
+ import sibna
301
+
302
+ # On Alice's device
303
+ alice_ctx = sibna.Context(password=b"AlicePass1!")
304
+ alice_ed, alice_x = alice_ctx.generate_identity()
305
+ alice_bundle = alice_ctx.generate_prekey_bundle()
306
+
307
+ # On Bob's device
308
+ bob_ctx = sibna.Context(password=b"BobPass1!")
309
+ bob_ed, bob_x = bob_ctx.generate_identity()
310
+ bob_bundle = bob_ctx.generate_prekey_bundle()
311
+
312
+ # Alice initiates the handshake with Bob
313
+ alice_ctx.perform_handshake(
314
+ peer_id=bob_ed, # Bob's identity key (used as session ID)
315
+ peer_bundle=bob_bundle, # Bob's bundle (fetched from prekey server)
316
+ initiator=True,
317
+ )
318
+
319
+ # Bob accepts the handshake from Alice
320
+ bob_ctx.perform_handshake(
321
+ peer_id=alice_ed,
322
+ peer_bundle=alice_bundle,
323
+ initiator=False,
324
+ )
325
+
326
+ # Alice encrypts
327
+ ciphertext = alice_ctx.session_encrypt(bob_ed, b"Hello Bob!")
328
+
329
+ # Bob decrypts
330
+ plaintext = bob_ctx.session_decrypt(alice_ed, ciphertext)
331
+ assert plaintext == b"Hello Bob!"
332
+ ```
333
+
334
+ ---
335
+
336
+ ## Example — HTTP Client
337
+
338
+ ```python
339
+ from sibna.client import SibnaClient
340
+ import sibna
341
+
342
+ # Set up encryption context
343
+ ctx = sibna.Context()
344
+ ctx.generate_identity()
345
+ bundle = ctx.generate_prekey_bundle()
346
+
347
+ # Connect to server
348
+ client = SibnaClient(server="http://localhost:8080")
349
+ client.generate_identity() # Separate identity for server auth
350
+ client.authenticate() # JWT challenge-response flow
351
+ client.upload_prekey(bundle.hex())
352
+
353
+ # Send an encrypted message (payload is pre-encrypted by Context)
354
+ ciphertext = ctx.session_encrypt(b"peer_id_here", b"Hello!")
355
+ client.send_message(
356
+ recipient_id="peer_identity_hex",
357
+ payload_hex=ciphertext.hex(),
358
+ )
359
+
360
+ # Receive messages
361
+ messages = client.fetch_inbox()
362
+ for msg in messages:
363
+ plaintext = ctx.session_decrypt(
364
+ bytes.fromhex(msg["sender_id"]),
365
+ bytes.fromhex(msg["payload_hex"]),
366
+ )
367
+ print(plaintext.decode())
368
+ ```
369
+
370
+ ---
371
+
372
+ ## Common Errors
373
+
374
+ | Error | Cause | Fix |
375
+ |-------|-------|-----|
376
+ | `LibraryNotFoundError` | Native library not found | Build `sibna-protc` with Rust |
377
+ | `SibnaError(13)` | Tampered data or wrong key | Check key and `associated_data` |
378
+ | `SibnaError(7)` | Session does not exist | Call `perform_handshake()` first |
379
+ | `SibnaError(10)` | Weak password | Use a password with uppercase, lowercase, and digits |
380
+ | `MissingDependencyError` | Python package not installed | `pip install cryptography requests aiohttp` |
381
+
382
+ ---
383
+
384
+ ## A Note on Dependencies
385
+
386
+ This SDK is **not** zero-dependencies:
387
+ - `__init__.py` requires the compiled Rust native library
388
+ - `client.py` requires `cryptography`, `requests`, and `aiohttp`
389
+
390
+ The Rust core itself has no runtime dependencies once compiled.
391
+
392
+ ---
393
+
394
+ ## License
395
+
396
+ Apache-2.0