{"id":25432326,"url":"https://github.com/pyrohost/clavis","last_synced_at":"2025-08-31T12:40:16.904Z","repository":{"id":258392720,"uuid":"872235551","full_name":"pyrohost/clavis","owner":"pyrohost","description":"A Rust library for secure, encrypted communication over asynchronous streams","archived":false,"fork":false,"pushed_at":"2025-02-10T03:58:02.000Z","size":142,"stargazers_count":37,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-23T11:39:22.499Z","etag":null,"topics":["async","communication","encryption","security"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/clavis","language":"Rust","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/pyrohost.png","metadata":{"files":{"readme":"README.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}},"created_at":"2024-10-14T04:46:30.000Z","updated_at":"2025-08-18T01:03:58.000Z","dependencies_parsed_at":"2025-07-26T20:38:45.826Z","dependency_job_id":"a2eec717-6ada-439a-8126-c0e057f3d9c6","html_url":"https://github.com/pyrohost/clavis","commit_stats":null,"previous_names":["pyrohost/clavis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pyrohost/clavis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrohost%2Fclavis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrohost%2Fclavis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrohost%2Fclavis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrohost%2Fclavis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyrohost","download_url":"https://codeload.github.com/pyrohost/clavis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrohost%2Fclavis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272982765,"owners_count":25025984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["async","communication","encryption","security"],"created_at":"2025-02-17T04:49:51.344Z","updated_at":"2025-08-31T12:40:16.849Z","avatar_url":"https://github.com/pyrohost.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clavis\n\n![Crates.io](https://img.shields.io/crates/v/clavis)\n![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)\n![Rust Version](https://img.shields.io/badge/rust-1.75%2B-orange.svg)\n\nClavis is an asynchronous Rust library designed for secure, encrypted communication over network streams. Built on `tokio`, it provides abstractions for encrypted packet-based communication with strong security guarantees, utilizing modern cryptographic primitives.\n\nThe library implements XChaCha20-Poly1305 encryption, along with a type-safe protocol DSL macro for custom protocol definitions and built-in serialization.\n\n## Installation\n\nTo add Clavis to your project, include these dependencies in `Cargo.toml`:\n\n```toml\n[dependencies]\nclavis = { git = \"https://github.com/pyrohost/clavis\" }\ntokio = { version = \"1.0\", features = [\"full\"] }\nserde = { version = \"1.0\", features = [\"derive\"] }\n```\n\n## Quick Start\n\n### Defining a Protocol\n\nDefine custom protocol messages using the `protocol!` macro:\n\n```rust\nuse clavis::protocol;\nuse serde::{Serialize, Deserialize};\n\n#[derive(Debug, Clone, Serialize, Deserialize)]\nstruct ChatMessage {\n    username: String,\n    content: String,\n    timestamp: u64,\n}\n\nprotocol! {\n    enum ChatProtocol {\n        Heartbeat,\n        Join(String),\n        Leave(String),\n        Message(ChatMessage),\n        Status {\n            users_online: u32,\n            server_uptime: u64,\n        },\n    }\n}\n```\n\n### Client Implementation\n\nSet up a client to connect, send, and receive encrypted messages:\n\n```rust\nuse clavis::{EncryptedStream, EncryptedStreamOptions, EncryptedPacket};\nuse tokio::net::TcpStream;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let stream = TcpStream::connect(\"127.0.0.1:8080\").await?;\n    let options = EncryptedStreamOptions {\n        max_packet_size: 65536,\n        psk: Some(b\"pre-shared_key\".to_vec()),\n    };\n    let encrypted = EncryptedStream::new(stream, Some(options)).await?;\n    let (mut reader, mut writer) = encrypted.split()?;\n\n    writer.write_packet(\u0026ChatProtocol::Join(\"Alice\".into())).await?;\n\n    if let Ok(packet) = reader.read_packet::\u003cChatProtocol\u003e().await {\n        println!(\"Received packet: {:?}\", packet);\n    }\n    \n    Ok(())\n}\n```\n\n### Server Implementation\n\nSet up a server to handle encrypted client connections and process messages:\n\n```rust\nuse clavis::{EncryptedStream, EncryptedStreamOptions, EncryptedPacket};\nuse tokio::net::TcpListener;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let listener = TcpListener::bind(\"127.0.0.1:8080\").await?;\n    println!(\"Server listening on :8080\");\n\n    while let Ok((stream, addr)) = listener.accept().await {\n        tokio::spawn(async move {\n            let options = EncryptedStreamOptions {\n                max_packet_size: 65536,\n                psk: Some(b\"shared_secret\".to_vec()),\n            };\n            match EncryptedStream::new(stream, Some(options)).await {\n                Ok(mut encrypted) =\u003e {\n                    if let Ok(packet) = encrypted.read_packet::\u003cChatProtocol\u003e().await {\n                        println!(\"Received packet: {:?}\", packet);\n                    }\n                }\n                Err(e) =\u003e eprintln!(\"Connection error: {}\", e),\n            }\n        });\n    }\n\n    Ok(())\n}\n```\n\n## Contributing\n\nWe welcome contributions! For suggestions, bug reports, or feature requests, please open an issue or submit a pull request on our GitHub repository.\n\n## Security\n\nClavis is designed to provide strong security guarantees. However, no software is perfect, and security vulnerabilities may exist. If you discover a security issue, please report it [here](https://github.com/pyrohost/clavis/security) so we can address it promptly.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyrohost%2Fclavis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyrohost%2Fclavis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyrohost%2Fclavis/lists"}