rift-torrent
SRT-based torrent peer discovery for zero-infrastructure P2P.
Part of the riftd project — serverless P2P voice + text chat over UDP with Predictive Rendezvous.
What's in this crate?
- Zero-Infrastructure Discovery: Use Semantic Rendezvous Tokens (SRTs) derived from infohash instead of trackers or DHT bootstrap nodes
- BitTorrent Compatible: Parse and create standard .torrent files with optional SRT extensions
- Magnet URI Support: Parse magnet URIs with
xs=riftd-srt://parameter - Deterministic Rendezvous: Peers independently derive identical schedules from the infohash alone
- Fallback Support: Graceful degradation to traditional tracker/DHT when needed
How It Works
Instead of announcing to a tracker or bootstrapping DHT nodes, peers derive a Semantic Rendezvous Token (SRT) from the torrent infohash:
infohash → BLAKE3 → space_id (namespace isolation)
infohash + t0 → BLAKE3 → seed (schedule derivation)
Both peers compute identical rendezvous schedules and can discover each other without any central infrastructure.
Usage
use ;
use PeerId;
// Parse a magnet URI
let magnet = parse?;
// Derive SRT from infohash (zero-infrastructure discovery)
let srt = from_infohash;
// Get the SRT URI for sharing
let srt_uri = srt.to_uri?;
println!;
// Create extended magnet with SRT
let extended_magnet = magnet.with_srt;
println!;
Parsing .torrent Files
use ;
let torrent_data = read?;
let meta = parse_torrent?;
println!;
println!;
println!;
// Derive SRT for peer discovery
let srt = from_infohash;
Peer Discovery
use ;
use PeerId;
let info_hash = Sha1;
let srt = from_infohash;
let local_peer = PeerId;
let mut discovery = new;
// Add discovered peers
let peer = new;
discovery.add_peer;
// Check if SRT needs refreshing
if discovery.needs_refresh
Magnet URI Extension
Standard magnet URIs can include an SRT in the xs (exact source) parameter:
magnet:?xt=urn:btih:HASH&dn=NAME&xs=riftd-srt://v1?space=...&seed=...
This allows zero-infrastructure peer discovery while remaining compatible with existing BitTorrent clients (which will ignore the unknown xs parameter).
Discovery Modes
| Mode | Description |
|---|---|
SrtOnly |
Pure zero-infrastructure, SRT rendezvous only |
SrtThenDht |
Try SRT first, fall back to DHT (default) |
SrtAndDht |
Use SRT and DHT in parallel |
Traditional |
Traditional tracker/DHT only |
Related Crates
| Crate | Description |
|---|---|
rift-rndzv |
Predictive Rendezvous networking layer |
rift-core |
Core types, identity, cryptography |
rift-dht |
Distributed hash table for peer discovery |
Citation
If you use this work in academic research, please cite:
Riaan de Beer. Predictive Rendezvous: Time–Intent–Deterministic Peer Coordination Without Infrastructure. 2026. DOI: 10.5281/zenodo.18528430
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.