BitVMX’s Open Source Stack keeps expanding: Message Broker & Operator Communication Library

As part of our ongoing journey to open up the BitVMX stack, we’re proud to release two new core components: Message Broker and Operator Communication Library
These libraries enable secure, authenticated communication between operators, laying the foundation for multi-operator coordination in off-chain protocols, dispute systems, or shared execution networks. With these modules now open source, developers can directly integrate low-latency, identity-bound messaging into their own Bitcoin-native systems.
Message Broker: Messaging Infrastructure with Fine-Grained Access Control
The Message BitVMX Broker handles identity, routing, and message transport. The message broker is also responsible for coordinating communication between internal sub-components and across operators, ensuring reliable and authenticated message flow throughout the protocol stack.
It includes:
- A sync server (BrokerSync) for managing message flow
- A client interface for sending/receiving
- A dual-channel API for bidirectional communication
- TLS auth with certificate validation via public key hash
- YAML-based allowlist and routing table generation
🖥️ Broker Server Setup
let storage = Arc::new(Mutex::new(MemStorage::new()));
let server_cert = Cert::new()?;
let server_pubkey_hash = server_cert.get_pubk_hash()?;
let allow_list = AllowList::new();
let routing_table = RoutingTable::new();
let config = BrokerConfig::new(10000, Some(IpAddr::V4(Ipv4Addr::LOCALHOST)), server_pubkey_hash)?;
let server = BrokerSync::new(&config, storage.clone(), server_cert, allow_list, routing_table);
📡 Broker Client Example
let client_cert = Cert::new()?;
let destination_id = Identifier::new(client_cert.get_pubk_hash()?, 0);
let client = Client::new(&config, client_cert, allow_list)?;
client.send_msg(0, destination_id.clone(), "hello".to_string())?;
while let Some(msg) = client.get_msg(destination_id.clone())? {
println!("{:?}", msg);
client.ack(destination_id.clone(), msg.uid)?;
}
🔄 DualChannel for P2P Messaging
let user_1 = DualChannel::new(&server_config, client1_cert, 0, allow_list.clone());
let user_2 = DualChannel::new(&server_config, client2_cert, 0, allow_list);
user_1.send(client2_identifier, "Hello!".to_string())?;
let msg = user_2.recv()?.unwrap();
Broker’s flexibility makes it suitable for a variety of deployment topologies—from centralized coordination servers to distributed peer-to-peer setups.
Operator Communication Library: TLS-Based Secure Channels Between Nodes
Operator Communication Library is a lightweight messaging layer that allows direct peer-to-peer communication between operators. It is built on top of the Broker and exposes a simplified interface to send and receive data securely.
- TLS-authenticated connections using PEM private keys
- Peer identity is bound to a public key hash
- Supports allowlists and routing tables for granular access control
- Graceful shutdowns with .stop()
🔧 Example: Peer-to-Peer Messaging
let mut comms1 = OperatorComms::new(addr1, &privk1, allow_list.clone(), routing.clone())?;
let mut comms2 = OperatorComms::new(addr2, &privk2, allow_list.clone(), routing)?;
comms1.send(&pubk_hash2, addr2, b"hello peer2".to_vec())?;
match comms2.check_receive() {
Some(ReceiveHandlerChannel::Msg(from_id, data)) => {
assert_eq!(data, b"hello peer2".to_vec());
},
_ => panic!("Message not received"),
}
📡 Supporting Methods
let pubk_hash = OperatorComms::get_pubk_hash_from_privk("test.key")?;
let address = comms1.get_address();
let my_id = comms1.get_pubk_hash();
comms1.stop()?; // Gracefully close
This abstraction removes the complexity of socket and certificate management, letting you focus on protocol-level message semantics.
Development Status
Both components are under active development, are not yet audited, and may undergo breaking changes. They are not production-ready at this stage, but are stable enough for exploration, experimentation, and integration into early-stage protocol designs.
Get Involved
These tools are part of our broader initiative to build a robust, modular, and open Bitcoin infrastructure. Whether you're building decentralized protocols, relays, bridges, or coordination layers, we invite you to explore, fork, and contribute.
Repository
GitHub FairgateLabs |