1 unstable release
Uses new Rust 2024
new 0.1.0 | Apr 14, 2025 |
---|
#352 in Authentication
102 downloads per month
525KB
833 lines
gardens-rs 🌺
End-to-end encrypted peer-to-peer messaging protocol built on P2Panda
Gardens Protocol is a resilient P2P messaging protocol that enables secure, private, and decentralized communication. Built on the P2Panda framework with Rust for performance and security, Gardens Protocol provides a robust foundation for developing local-first, encrypted messaging applications.
Features
- End-to-end encryption: Secure messaging with modern cryptographic primitives
- Decentralized architecture: No central servers or points of failure
- Local-first design: Work offline with seamless synchronization when reconnected
- Group messaging: Create and manage encrypted group conversations
- Lightweight: Optimized for resource efficiency and quick synchronization
- Cross-platform: Core library written in Rust for use on any platform
Getting Started
Prerequisites
- Rust 1.70 or later
- Cargo
- Development packages (varies by OS)
Installation
Add the library to your Rust project:
[dependencies]
garden-core = "0.1.0"
Or clone and build from source:
git clone https://github.com/yourusername/gardens-protocol.git
cd gardens-protocol
cargo build --release
Basic Usage
Here's a simple example of how to use Gardens Protocol for encrypted P2P messaging:
use gardens_rs::{
identity::Identity,
p2p::{GardenConfig, create_garden_client},
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a user identity
let (my_identity, _) = Identity::generate_identity();
// Configure the P2P client
let mut config = GardenConfig::default();
config.user_identity = Some(my_identity);
// Create and initialize client
let client = create_garden_client(config).await?;
client.initialize_group_encryption().await?;
// Create a topic to subscribe to
let topic = client.create_direct_message_topic("recipient-id");
client.subscribe(topic.clone()).await?;
// Send a message
let message = b"Hello, Gardens Protocol!";
client.send_message(&topic, message).await?;
// Process events (in a real app, this would be in a loop)
client.process_events().await?;
// Clean up
client.shutdown().await?;
Ok(())
}
Building a Tauri App with Gardens Protocol
Gardens Protocol is designed to work perfectly with Tauri for creating cross-platform desktop applications. Here's how to integrate it:
- Create a new Tauri project
- Add garden-core to your dependencies
- Create Tauri commands to interface with the core library
- Build your UI using React, Vue, or other frontend frameworks
Architecture
Gardens Protocol consists of several core components:
- Identity: Secure user identities with cryptographic keys
- P2P Networking: Built on P2Panda for robust peer-to-peer communication
- Encrypted Messaging: End-to-end encrypted communications
- Group Management: Create and maintain secure group conversations
API Reference
The core API includes these main modules:
identity
: User identity managementp2p
: Peer-to-peer networkingauth
: Authentication and authorizationentries
: Message entry creation and validationtypes
: Core type definitionspath
: Path utilities for topic handling
See the API documentation for complete details.
Examples
Check out the examples directory for more detailed usage examples:
p2p_example.rs
: Demonstrates basic P2P messaging between two peers
Roadmap
- Group encryption (When p2panda-group is released)
- Enhanced group management capabilities
- Store integration
- Improved NAT traversal mechanisms
- Decentralized identity verification
- Additional transport protocols
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the GNU Affero General Public License v3.0
Acknowledgments
- P2Panda - Decentralized data schemas and synchronization
- The Rust community for excellent libraries and tools
Dependencies
~51–85MB
~1.5M SLoC