revery/
lib.rs

1//! # Revery
2//!
3//! ## Components
4//!
5//! - **`auth`** - SPAKE2 password-based authentication
6//! - **`session`** - Encrypted messaging with ChaCha20 and forgery capabilities
7//! - **`protocol`** - Wire protocol for message framing over TCP
8//!
9//! ## Basic Usage
10//!
11//! The core library works with any stream that implements `AsyncRead + AsyncWrite`.
12//! For Tor integration, use the `revery-onion` crate.
13//!
14//! ```rust,no_run
15//! use revery::{auth, protocol, session};
16//! use tokio::io::{AsyncRead, AsyncWrite};
17//!
18//! async fn messaging_example<S>(stream: S) -> Result<(), Box<dyn std::error::Error>>
19//! where
20//!     S: AsyncRead + AsyncWrite + Unpin + Send + 'static,
21//! {
22//!     let mut wire = protocol::WireProtocol::new(stream);
23//!
24//!     // Authenticate
25//!     let auth = auth::AuthFlow::new(auth::SessionRole::Creator, "password");
26//!     let peer_msg = wire.receive_auth_message().await?;
27//!     wire.send_auth_message(&auth.our_message()).await?;
28//!     let shared_secret = auth.authenticate(&peer_msg)?;
29//!
30//!     // Set up conversation and send message
31//!     let timestamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH)?.as_millis();
32//!     let conversation = session::Conversation::new(&shared_secret, "example.onion", timestamp.try_into()?);
33//!     wire.set_conversation(conversation);
34//!     wire.send_text_message("Hello!").await?;
35//!
36//!     Ok(())
37//! }
38//! ```
39
40pub mod auth;
41pub mod protocol;
42pub mod session;