Skip to main content

Lightweight MQTT-based secure P2P messaging layer

Project description

sidewire

Part of the Warpgate project: https://www.warpgate.io/

A decentralized MQTT-based signaling layer for P2P applications.

sidewire routes messages between peers using rendezvous hashing over a shared pool of public MQTT brokers. Neither side needs to know which servers the other is connected to — the shared key deterministically produces the same server ordering on both ends.

Key concepts

  • Router — connects to MQTT brokers, sends and receives signed messages keyed by public key hex. Supports caching of peer-to-server mappings to avoid repeated discovery.
  • SmartPipe — a virtual pipe over multiple MQTT clients that automatically routes a message to the first broker where both peers are connected.
  • AppPacket — wire-format envelope for signed P2P messages. Includes a per-queue sequence number for ordered delivery, a message type field, and an ECDSA signature over the payload.
  • MQTTClient — low-level async MQTT client. Handles subscribe/publish, PUBACK sequencing, and reconnect.

Usage

from aionetiface import Interface
from sidewire import Router
from sidewire.utils import get_mqtt_server_list
from aionetiface.net.signing import Signing

nic = Interface("default")
kp  = Signing.keypair()

async def on_message(msg, src_pk_hex, pipe_id_hex, client):
    print("received:", msg, "from", src_pk_hex)

async with Router(kp, msg_handler=on_message, nic=nic) as router:
    pipe = await router.pipe(dest_pub_key_hex)
    await pipe.send("hello")

Server selection algorithm

Servers are ranked per destination key using the rendezvous hashing formula -log(H(server_id || key)) / weight. IPv4 and IPv6 results are interleaved so convergence is possible even when peers support different address families.

Installation

pip install sidewire

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sidewire-0.1.2.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sidewire-0.1.2-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file sidewire-0.1.2.tar.gz.

File metadata

  • Download URL: sidewire-0.1.2.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sidewire-0.1.2.tar.gz
Algorithm Hash digest
SHA256 81b9583d388b03001f0d20f34d47a4d636323df261199f7c6dfe6d6e7ed4e33e
MD5 8a4fc0a16b9af40ebf94f350cd96cf7e
BLAKE2b-256 879654518e922a1fea6441433755528dd60761afb2f90b647bc9cd71b89ac20d

See more details on using hashes here.

File details

Details for the file sidewire-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sidewire-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sidewire-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc57f51dd7a4eac6b223e7b953089f0145922e243a4dd99629770d77b0e6c4e6
MD5 2f7f3e1bed295ec729169279c3caab9d
BLAKE2b-256 5949949d0ac4c5b1346d57d7cec1f549dc8929802a2b791d363c53ab85284ea4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page