{"id":47727380,"url":"https://github.com/sibnaofficial/libsa","last_synced_at":"2026-04-06T00:01:08.849Z","repository":{"id":348122453,"uuid":"1196564513","full_name":"SibnaOfficial/libsa","owner":"SibnaOfficial","description":"sibna sdk ","archived":false,"fork":false,"pushed_at":"2026-04-01T19:24:38.000Z","size":831,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T06:30:03.144Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SibnaOfficial.png","metadata":{"files":{"readme":"README (1).md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-30T20:25:32.000Z","updated_at":"2026-04-01T19:24:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/SibnaOfficial/libsa","commit_stats":null,"previous_names":["sibnaofficial/libsa"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/SibnaOfficial/libsa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SibnaOfficial%2Flibsa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SibnaOfficial%2Flibsa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SibnaOfficial%2Flibsa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SibnaOfficial%2Flibsa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SibnaOfficial","download_url":"https://codeload.github.com/SibnaOfficial/libsa/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SibnaOfficial%2Flibsa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31379453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T21:40:47.592Z","status":"ssl_error","status_checked_at":"2026-04-03T21:40:05.436Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-02T20:51:24.117Z","updated_at":"2026-04-03T22:01:34.987Z","avatar_url":"https://github.com/SibnaOfficial.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sibna Protocol — Python SDK (Standalone)\n\nPython SDK for the Sibna Protocol. **Zero external dependencies.**\n\n---\n\n## What \"standalone\" means\n\n| Component | Implementation | External package? |\n|-----------|---------------|-------------------|\n| ChaCha20-Poly1305 encryption | Rust core (FFI) | ❌ none |\n| X3DH + Double Ratchet sessions | Rust core (FFI) | ❌ none |\n| Ed25519 signing (server auth) | `_ed25519.py` — pure Python RFC 8032 | ❌ none |\n| HTTP client | Python stdlib `urllib` | ❌ none |\n| WebSocket client | `_websocket.py` — pure Python RFC 6455 | ❌ none |\n\nThe **only** thing you need that isn't pure Python is the compiled Rust library\n(`sibna_core.dll` / `libsibna_core.so` / `.dylib`) — because Python has no\nnative ChaCha20 or Double Ratchet in stdlib.\n\n---\n\n## Requirements\n\n- Python 3.8+\n- The compiled Rust library from `sibna-protc/core`\n\n**Nothing else. No `pip install`.**\n\n---\n\n## Build the native library\n\n```bash\ncd sibna-protc/core\ncargo build --release --features ffi\n```\n\nThen place the output file next to the `sibna/` folder:\n\n| OS      | File                   | Location      |\n|---------|------------------------|---------------|\n| Windows | `sibna_core.dll`       | next to `sibna/` |\n| Linux   | `libsibna_core.so`     | next to `sibna/` |\n| macOS   | `libsibna_core.dylib`  | next to `sibna/` |\n\n---\n\n## Package structure\n\n```\nsibna/\n  __init__.py    — FFI wrapper (encrypt, decrypt, Context)\n  client.py      — HTTP + WebSocket client (SibnaClient, AsyncSibnaClient)\n  _ed25519.py    — Pure Python Ed25519 (RFC 8032) — server auth signing\n  _websocket.py  — Pure Python WebSocket (RFC 6455) — real-time transport\n```\n\n`_ed25519.py` and `_websocket.py` are internal modules (prefixed with `_`).\nThey are bundled inside the SDK — not installed via pip.\n\n---\n\n## Quick start\n\n```python\nimport sibna\n\nif not sibna.is_available():\n    raise RuntimeError(\"Build the Rust library first — see README\")\n\n# Encrypt / decrypt\nkey = sibna.generate_key()\nct  = sibna.encrypt(key, b\"Hello!\")\npt  = sibna.decrypt(key, ct)\nassert pt == b\"Hello!\"\n```\n\n---\n\n## E2EE session (X3DH + Double Ratchet)\n\n```python\nimport sibna\n\n# Alice\nalice = sibna.Context(password=b\"AlicePass1!\")\nalice_ed, alice_x = alice.generate_identity()\nalice_bundle = alice.generate_prekey_bundle()\n\n# Bob\nbob = sibna.Context(password=b\"BobPass1!\")\nbob_ed, bob_x = bob.generate_identity()\nbob_bundle = bob.generate_prekey_bundle()\n\n# Handshake (bundles are normally exchanged via prekey server)\nalice.perform_handshake(peer_id=bob_ed, peer_bundle=bob_bundle, initiator=True)\nbob.perform_handshake(peer_id=alice_ed, peer_bundle=alice_bundle, initiator=False)\n\n# Alice sends\nct = alice.session_encrypt(bob_ed, b\"Hello Bob!\")\n\n# Bob receives\npt = bob.session_decrypt(alice_ed, ct)\nassert pt == b\"Hello Bob!\"\n\nalice.close()\nbob.close()\n```\n\n---\n\n## HTTP client (no pip install)\n\n```python\nfrom sibna.client import SibnaClient\nimport sibna\n\n# Set up encryption\nctx = sibna.Context()\nctx.generate_identity()\nbundle = ctx.generate_prekey_bundle()\n\n# Connect to server\nclient = SibnaClient(server=\"http://localhost:8080\")\nclient.generate_identity()   # Ed25519 identity for server auth\nclient.authenticate()         # challenge-response → JWT (uses urllib, no requests)\nclient.upload_prekey(bundle.hex())\n\n# Send\nct = ctx.session_encrypt(b\"peer_id\", b\"Hello!\")\nclient.send_message(recipient_id=\"peer_hex\", payload_hex=ct.hex())\n\n# Receive\nfor msg in client.fetch_inbox():\n    pt = ctx.session_decrypt(\n        bytes.fromhex(msg[\"sender_id\"]),\n        bytes.fromhex(msg[\"payload_hex\"]),\n    )\n    print(pt.decode())\n```\n\n---\n\n## Async + WebSocket (no pip install)\n\n```python\nimport asyncio\nfrom sibna.client import AsyncSibnaClient\n\nasync def on_message(envelope):\n    print(\"Received:\", envelope[\"payload_hex\"])\n\nasync def main():\n    client = AsyncSibnaClient(server=\"http://localhost:8080\")\n    client.generate_identity()\n    await client.authenticate()   # uses asyncio + urllib, no aiohttp\n    await client.connect(on_message=on_message)   # pure Python WebSocket\n\nasyncio.run(main())\n```\n\n---\n\n## Error reference\n\n| Error | Code | Meaning |\n|-------|------|---------|\n| `SibnaError(13)` | 13 | Tampered data or wrong key |\n| `SibnaError(7)`  |  7 | No session — call `perform_handshake()` first |\n| `SibnaError(8)`  |  8 | No identity — call `generate_identity()` first |\n| `SibnaError(10)` | 10 | Weak password |\n| `SibnaError(6)`  |  6 | Context already closed |\n| `LibraryNotFoundError` | — | Rust library not found |\n| `AuthError` | — | Server auth failed |\n| `NetworkError` | — | HTTP / WebSocket failure |\n\n---\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibnaofficial%2Flibsa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsibnaofficial%2Flibsa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibnaofficial%2Flibsa/lists"}