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