Skip to main content
cairn logo

Universal peer-to-peer connectivity library

End-to-end encrypted messaging across five languages. No infrastructure required to get started.

Why cairn

A single protocol for direct, encrypted communication between peers -- regardless of language or platform.

Five Languages, One Protocol

Rust, TypeScript, Go, Python, and PHP implementations that fully interoperate over the same wire protocol.

Secure by Default

Noise XX handshake with Double Ratchet for forward secrecy. Encryption is always on, not opt-in.

Progressive Infrastructure

Start peer-to-peer with zero servers. Add signaling and relay only when your deployment needs it.

Get started in minutes

Pair two nodes, establish a session, and start sending messages.

use cairn_p2p::{Node, CairnConfig, create};

let node = create(CairnConfig::default())?;
node.start().await?;
let pairing = node.pair_generate_pin().await?;
println!("PIN: {}", pairing.pin);
// Responder enters PIN, then:
let session = node.connect(&peer_id).await?;
session.send("chat", b"hello").await?;

Infrastructure tiers

Deploy what you need. Each tier builds on the previous one.

Tier 0

Peer-to-peer only
Setup
None
NAT traversal
Public STUN, best-effort
Discovery
5-30s (DHT/mDNS)
Offline messages
No
Relay
No
Multi-device
Manual
Cost
Free

Tier 1

With signaling
Setup
2 Docker containers
NAT traversal
TURN relay, symmetric NAT
Discovery
<1s (signaling)
Offline messages
No
Relay
Yes
Multi-device
Manual
Cost
Free (Cloudflare) or ~$5/mo VPS

Tier 2

Full stack
Setup
3 Docker containers
NAT traversal
Full
Discovery
<1s
Offline messages
Yes (store-and-forward)
Relay
Yes
Multi-device
Automatic (hub)
Cost
Same + storage

Start building

Read the docs, pick your language, and have two peers talking in minutes.