{"id":49682548,"url":"https://github.com/CorvidLabs/swift-algochat","last_synced_at":"2026-05-23T21:00:56.031Z","repository":{"id":334454661,"uuid":"1120612340","full_name":"CorvidLabs/swift-algochat","owner":"CorvidLabs","description":"🔐 Encrypted messaging on Algorand. Your keys, your messages, your blockchain.","archived":false,"fork":false,"pushed_at":"2026-02-26T04:57:54.000Z","size":250,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-26T08:51:59.285Z","etag":null,"topics":["algorand","async-await","blockchain","chacha20-poly1305","cryptography","decentralized","encryption","end-to-end-encryption","hkdf","messaging","privacy","psk","quantum-resistance","swift","swift-package-manager","x25519"],"latest_commit_sha":null,"homepage":"https://corvidlabs.github.io/swift-algochat/documentation/algochat","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CorvidLabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","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":"2025-12-21T15:29:59.000Z","updated_at":"2026-02-26T04:57:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/CorvidLabs/swift-algochat","commit_stats":null,"previous_names":["corvidlabs/swift-algochat"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/CorvidLabs/swift-algochat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorvidLabs%2Fswift-algochat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorvidLabs%2Fswift-algochat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorvidLabs%2Fswift-algochat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorvidLabs%2Fswift-algochat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CorvidLabs","download_url":"https://codeload.github.com/CorvidLabs/swift-algochat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorvidLabs%2Fswift-algochat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33412082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T18:09:33.147Z","status":"ssl_error","status_checked_at":"2026-05-23T18:09:31.380Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["algorand","async-await","blockchain","chacha20-poly1305","cryptography","decentralized","encryption","end-to-end-encryption","hkdf","messaging","privacy","psk","quantum-resistance","swift","swift-package-manager","x25519"],"created_at":"2026-05-07T08:00:26.875Z","updated_at":"2026-05-23T21:00:56.026Z","avatar_url":"https://github.com/CorvidLabs.png","language":"Swift","funding_links":[],"categories":["Development \u0026 Tools"],"sub_categories":["Language SDKs \u0026 Tools"],"readme":"# swift-algochat\n\n[![macOS](https://img.shields.io/github/actions/workflow/status/CorvidLabs/swift-algochat/macOS.yml?label=macOS\u0026branch=main)](https://github.com/CorvidLabs/swift-algochat/actions/workflows/macOS.yml)\n[![Linux](https://img.shields.io/github/actions/workflow/status/CorvidLabs/swift-algochat/linux.yml?label=Linux\u0026branch=main)](https://github.com/CorvidLabs/swift-algochat/actions/workflows/linux.yml)\n[![License](https://img.shields.io/github/license/CorvidLabs/swift-algochat)](https://github.com/CorvidLabs/swift-algochat/blob/main/LICENSE)\n[![Version](https://img.shields.io/github/v/release/CorvidLabs/swift-algochat)](https://github.com/CorvidLabs/swift-algochat/releases)\n\n\u003e **Pre-1.0 Notice**: This library is under active development. The API may change between minor versions until 1.0.\n\n\u003e **Security Notice**: This library has not been independently audited. While it uses well-established cryptographic primitives from [swift-crypto](https://github.com/apple/swift-crypto), use in production is at your own risk.\n\nEncrypted peer-to-peer messaging on the Algorand blockchain. Built with Swift 6 and async/await.\n\n## Features\n\n- **End-to-End Encryption** - X25519 key agreement + ChaCha20-Poly1305\n- **Forward Secrecy** - Per-message ephemeral keys protect past messages\n- **Quantum Defense-in-Depth** - Optional ratcheting PSK mode (protocol v1.1) provides hybrid X25519 + pre-shared key encryption\n- **Replay Protection** - Counter-based sliding window for PSK messages\n- **Immutable Messages** - Permanently recorded on-chain\n- **Decentralized** - No central server controls delivery\n- **Bidirectional Decryption** - Both sender and recipient can decrypt messages\n- **Reply Support** - Thread conversations with reply context\n- **Biometric Storage** - Protect encryption keys with Face ID / Touch ID\n- **Cross-Implementation** - Compatible with [ts-algochat](https://github.com/CorvidLabs/ts-algochat), [rs-algochat](https://github.com/CorvidLabs/rs-algochat), [py-algochat](https://github.com/CorvidLabs/py-algochat), [kt-algochat](https://github.com/CorvidLabs/kt-algochat)\n- **Multi-Platform** - iOS 15+, macOS 12+, tvOS 15+, watchOS 8+, visionOS 1+, Linux\n\n## Installation\n\n### Swift Package Manager\n\nAdd AlgoChat to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/CorvidLabs/swift-algochat.git\", from: \"0.1.0\")\n]\n```\n\nThen add the dependency to your target:\n\n```swift\n.target(\n    name: \"YourApp\",\n    dependencies: [\n        .product(name: \"AlgoChat\", package: \"swift-algochat\")\n    ]\n)\n```\n\nOr add it via Xcode:\n1. File \u003e Add Package Dependencies\n2. Enter: `https://github.com/CorvidLabs/swift-algochat.git`\n\n## Quick Start\n\n### Creating a Chat Client\n\n```swift\nimport AlgoChat\nimport Algorand\n\n// Create a new account\nlet account = try Account()\n\n// Initialize chat client\nlet chat = try await AlgoChat(network: .testnet, account: account)\n```\n\n### Sending Messages\n\n```swift\n// Start a conversation\nlet recipient = try Address(string: \"RECIPIENT_ADDRESS_HERE\")\nlet conversation = try await chat.conversation(with: recipient)\n\n// Send a message (wait for confirmation)\ntry await chat.send(\"Hello!\", to: conversation, options: .confirmed)\n\n// Send with indexer confirmation (guarantees visibility on refresh)\ntry await chat.send(\"Hello!\", to: conversation, options: .indexed)\n\n// Send a reply\nif let lastMessage = conversation.lastReceived {\n    try await chat.send(\"Thanks!\", to: conversation, options: .replying(to: lastMessage))\n}\n```\n\n### Fetching Messages\n\n```swift\n// Get all conversations\nlet conversations = try await chat.conversations()\n\n// Refresh a specific conversation\nlet updated = try await chat.refresh(conversation)\n\n// Access messages\nfor message in updated.messages {\n    print(\"\\(message.direction): \\(message.content)\")\n}\n\n// Filter by direction\nlet received = updated.receivedMessages\nlet sent = updated.sentMessages\n```\n\n### Publishing Your Key\n\nAllow others to message you before you've sent them a message:\n\n```swift\ntry await chat.publishKeyAndWait()\n```\n\n### PSK Mode (Quantum Defense-in-Depth)\n\nPSK mode adds a pre-shared key layer on top of standard ECDH encryption, providing defense-in-depth against future quantum attacks on key exchange.\n\n```swift\n// Generate and share a PSK exchange URI\nlet psk = PSKExchangeURI(\n    address: account.address.description,\n    psk: Data.random(count: 32),\n    label: \"Alice\"\n)\nlet uri = psk.toString()\n// Share uri out-of-band: algochat-psk://v1?addr=...\u0026psk=...\u0026label=Alice\n\n// Import a PSK from a received URI\nlet received = try PSKExchangeURI.parse(uri)\nlet contact = PSKContact(\n    address: received.address,\n    initialPSK: received.psk,\n    label: received.label\n)\n\n// Manage PSK contacts\nlet pskManager = PSKManager(storage: FilePSKStorage(directory: \".algochat\"))\ntry await pskManager.addContact(contact)\n```\n\n## Core Concepts\n\n### Encryption\n\nMessages are encrypted using modern cryptographic primitives:\n\n- **Key Agreement**: X25519 elliptic curve Diffie-Hellman\n- **Encryption**: ChaCha20-Poly1305 authenticated encryption\n- **Key Derivation**: HKDF-SHA256 with domain separation\n- **Forward Secrecy**: Fresh ephemeral key per message\n\n### Message Envelope Formats\n\n**Standard Mode** (protocol `0x01`):\n\n```\n[version: 1][protocol: 1][sender_pubkey: 32][ephemeral_pubkey: 32][nonce: 12][encrypted_sender_key: 48][ciphertext: variable]\n```\n\n- **Header size**: 126 bytes\n- **Maximum message**: 882 bytes (after encryption overhead)\n\n**PSK Ratcheting Mode** (protocol `0x02`):\n\n```\n[version: 1][protocol: 2][ratchet_counter: 4][sender_pubkey: 32][ephemeral_pubkey: 32][nonce: 12][encrypted_sender_key: 48][ciphertext: variable]\n```\n\n- **Header size**: 130 bytes\n- **Maximum message**: 878 bytes (after encryption overhead)\n\n### Key Storage\n\n```swift\n// Biometric-protected storage (Apple platforms)\nlet storage = KeychainKeyStorage()\nlet chatAccount = try await ChatAccount(account: algorandAccount, storage: storage)\n\n// Password-encrypted file storage (Linux/cross-platform)\nlet storage = FileKeyStorage(directory: \".algochat\", password: \"secret\")\n```\n\n### Send Options\n\n```swift\n// Fire-and-forget (fastest)\ntry await chat.send(\"Hello!\", to: conversation)\n\n// Wait for blockchain confirmation\ntry await chat.send(\"Hello!\", to: conversation, options: .confirmed)\n\n// Wait for indexer (guarantees visibility)\ntry await chat.send(\"Hello!\", to: conversation, options: .indexed)\n```\n\n## CLI Tool\n\nThe package includes an interactive command-line interface:\n\n```bash\nswift run algochat\n```\n\n## Testing\n\n### Unit Tests\n\n```bash\nswift test\n```\n\n### Integration Tests (LocalNet)\n\n```bash\n# Start local Algorand network\nalgokit localnet start\n\n# Run integration tests\nswift test --filter \"LocalnetIntegration\"\n\n# Stop localnet\nalgokit localnet stop\n```\n\n## Requirements\n\n- Swift 6.0+\n- iOS 15.0+ / macOS 12.0+ / tvOS 15.0+ / watchOS 8.0+ / visionOS 1.0+\n- Linux (with Swift 6.0+)\n- [AlgoKit CLI](https://github.com/algorandfoundation/algokit-cli) (optional, for localnet testing)\n\n## Security\n\nSee [SECURITY.md](SECURITY.md) for:\n- Cryptographic guarantees\n- Threat model\n- Key management details\n\n## License\n\nMIT License - See [LICENSE](LICENSE) file for details.\n\n## Resources\n\n- [swift-algorand](https://github.com/CorvidLabs/swift-algorand) - Algorand SDK for Swift\n- [swift-algokit](https://github.com/CorvidLabs/swift-algokit) - High-level Algorand toolkit\n- [Algorand Developer Portal](https://developer.algorand.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCorvidLabs%2Fswift-algochat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCorvidLabs%2Fswift-algochat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCorvidLabs%2Fswift-algochat/lists"}