Rust bindings for Tashi Vertex, an embedded Byzantine fault-tolerant consensus engine based on the Hashgraph algorithm.
Tashi Vertex uses a DAG (Directed Acyclic Graph) of cryptographically signed events and virtual voting to achieve consensus finality in under 100 milliseconds — without exchanging explicit vote messages. For a detailed explanation, see the Vertex whitepaper.
- Fast BFT Consensus — sub-100ms finality with tolerance up to
f = ⌊(n-1)/3⌋Byzantine participants - Async-first — socket binding and message receiving are
Future-based - Zero runtime dependencies — only links dynamically to the
tashi-vertexC library - Safe FFI — opaque pointer wrappers with automatic cleanup via
Drop - Configurable — 15+ tunable engine parameters (heartbeat, latency thresholds, epoch sizing, etc.)
- Base58 utilities — encode/decode keys and binary data
Add the crate to your project:
cargo add tashi-vertex- CMake >= 4.0
- The Tashi Vertex shared library (
libtashi-vertex.so/.dylib/.dll), fetched automatically by the build script
Generate a keypair for your node:
use tashi_vertex::KeySecret;
let secret = KeySecret::generate();
let public = secret.public();
println!("Secret: {secret}"); // Base58-encoded DER
println!("Public: {public}");Run a minimal consensus network:
use tashi_vertex::{Context, Engine, KeySecret, Message, Options, Peers, Socket, Transaction};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let key: KeySecret = "BASE58_SECRET_KEY".parse()?;
// Configure peers in the network
let mut peers = Peers::new()?;
peers.insert("127.0.0.1:9001", &"BASE58_PEER_PUBLIC_KEY".parse()?, Default::default())?;
peers.insert("127.0.0.1:9000", &key.public(), Default::default())?;
// Initialize the runtime and bind a socket
let context = Context::new()?;
let socket = Socket::bind(&context, "127.0.0.1:9000").await?;
// Start the consensus engine
let options = Options::default();
let engine = Engine::start(&context, socket, options, &key, peers)?;
// Send a transaction
let data = b"hello world";
let mut tx = Transaction::allocate(data.len());
tx.copy_from_slice(data);
engine.send_transaction(tx)?;
// Receive consensus-ordered messages
while let Some(message) = engine.recv_message().await? {
match message {
Message::Event(event) => {
for tx in event.transactions() {
println!("tx: {:?}", tx);
}
}
Message::SyncPoint(_) => { /* session management */ }
}
}
Ok(())
}| Type | Description |
|---|---|
[Engine] |
Starts and drives the consensus engine — send transactions and receive ordered messages |
[Context] |
Runtime context managing async operations and resources |
[Socket] |
Async network socket bound to a local address |
[Options] |
Engine configuration (heartbeat, latency, epoch size, threading, etc.) |
[Message] |
Received message — either an Event or a SyncPoint |
[Event] |
A finalized event carrying consensus-ordered transactions |
[Transaction] |
Allocated buffer for submitting data to the network |
[KeySecret] |
Ed25519 secret key for signing (Base58/DER serializable) |
[KeyPublic] |
Ed25519 public key for verification (Base58/DER serializable) |
[Peers] |
Set of network participants with addresses and capabilities |
[SyncPoint] |
Session management decision from the consensus layer |
[base58] |
Base58 encoding/decoding utilities |
The examples/ directory contains runnable demos:
key-generate— Generate a new keypairkey-parse— Parse Base58-encoded keyspingback— Full multi-peer consensus network with transaction exchange
cargo run --example key-generateThe pingback example runs a 3-node consensus network where each node sends a PING transaction. First, generate a keypair for each node:
cargo run --example key-generate # run 3 times, save each secret/public keyThen start each node in a separate terminal, passing the other two nodes as peers:
cargo run --example pingback -- \
-B 127.0.0.1:8001 \
-K <secret_key> \
-P <peer2_public_key>@127.0.0.1:8002 \
-P <peer3_public_key>@127.0.0.1:8003Once all three nodes are running, each will reach consensus and print the ordered events:
:: Configured network for 3 peers
:: Initialized runtime
:: Bound local socket
:: Started the consensus engine
> Received SYNC POINT
> Received EVENT
- From: aSq9DsNNvGhY...
- Created: 1770174202473826258
- Consensus: 1770174208954261963
- Transactions: 1
- >> PING
> Received EVENT
- From: aSq9DsNNvGhY...
- Created: 1770174208954261966
- Consensus: 1770174208954261964
- Transactions: 1
- >> PING
> Received EVENT
- From: aSq9DsNNvGhY...
- Created: 1770174216230094057
- Consensus: 1770174208954261965
- Transactions: 1
- >> PING
This project is licensed under the Apache License, Version 2.0 (LICENSE).
This project dynamically links to the Tashi Vertex binary library (proprietary). Its origin and licensing details are provided in the NOTICE file.
Disclaimer: The Apache 2.0 license applies only to the source code of this project. The Tashi Vertex binary is not part of this open-source distribution and is governed by its own commercial license.