3 releases

Uses new Rust 2024

0.1.2 Jul 27, 2025
0.1.1 Jul 27, 2025
0.1.0 Jul 27, 2025

#1741 in Cryptography

Apache-2.0 OR MIT

41KB
781 lines

See: https://github.com/revery-project/revery


lib.rs:

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.

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(())
}

Dependencies

~7–18MB
~242K SLoC