Skip to content

Add the LogicSRC OpenSwarm specification family (paid, encrypted p2p media) - #142

Merged
ralyodio merged 1 commit into
masterfrom
ipmedia-specs
Sep 5, 2026
Merged

Add the LogicSRC OpenSwarm specification family (paid, encrypted p2p media)#142
ralyodio merged 1 commit into
masterfrom
ipmedia-specs

Conversation

@ralyodio

@ralyodio ralyodio commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

OpenSwarm: paid, encrypted, peer-to-peer distribution as an add-on to BitTorrent

Draft specification family under docs/openswarm/, registered on logicsrc.com the way OpenCreds is. Specs only. No code, no schemas, no reference implementation. The ip CLI is a proposal, not a binary.

Working name was "IPMedia". The family is called OpenSwarm because the swarm is the one object every member shares, "media" undersells ipfile and ipdb, "IP media" reads as IPTV, and the LogicSRC convention is Open + noun. The protocols keep their ip* names. Easy to rename if you prefer IPMedia.

What it is

ipfile is BitTorrent with three additions carried as BEP 10 extension messages, so vanilla clients, trackers, the DHT and WebTorrent in a browser all still work:

  • Encryption. The swarm carries AES-256-CTR ciphertext in a hybrid v1/v2 torrent. Integrity comes from two BEP 52 merkle roots (cipherRoot verified by the torrent itself, plainRoot verified after decryption) pinned by a signed manifest. A tracker learns an infohash and a size.
  • Payment. A leecher buys a pass over x402 in USDC (CoinPay's v2 offer, X-PAYMENT proof, verify and settle: the exact exchange x402-gateway runs for crawl passes). A seeder serves inside a bounded credit window (4 MiB default); after verifying each batch the leecher signs a cumulative voucher; the seeder redeems the latest one at a hub, which splits it publisher / seeder / hub. Nobody pays for unverified bytes, nobody serves more than one window unpaid, replays pay zero, and over-cap spending is bounded per seeder.
  • Ownership. Adding a file mints a key pair for it, derived from one publisher seed by default (HKDF over a random fileId), so the seed plus any manifest recovers every file key and content key. The public half is the file's identity and its BEP 46 mutable-item key; the private half signs manifests and authorises grants and payout changes; a separate random content key encrypts the bytes and is sealed (X25519 sealed box) to paying peers. --standalone-key mints an unrelated pair for files that change hands. Rotation and seed loss are specified.

Everything else reuses ipfile: ipaudio and ipvideo renditions are ipfiles; iplive segments use the same cipher, grants, credit window and vouchers with relays as payees; ipdb segments are free ipfiles. Reuse is stated as the default posture in the overview.

Documents

File Lines Content
docs/openswarm.md 190 Overview, stack diagram, reuse posture, c0mpute roles, what exists
docs/openswarm/spec.md 510 Core: records (JCS + SHA-256 ids, Ed25519 with domain prefix, optional ML-DSA-65), derived keys, BEP 52 ids, BEP 10 names, BEP 44 pointers, CloudEvents
docs/openswarm/ipfile.md 545 Manifest, grant, piece encryption, hello and payment messages, paid session, vanilla coexistence, pricing, publish and fetch procedures
docs/openswarm/ippay.md 464 Pass (x402 purchase, payer binding), voucher (integer value arithmetic), hub record and API, receipts and split, payees, standing, payout, HTTP headers
docs/openswarm/ipdb.md 386 Signed hash-chained feeds, entries, heads on the DHT, segment + gossip replication, forks, query shape, playlists, ratings
docs/openswarm/ipaudio.md 313 Track and release, renditions, seek index, aligned anchors, gapless, royalty split, gateway bridge and RSS
docs/openswarm/ipvideo.md 271 Title, CMAF renditions with segment index, subtitles, thumbnails, chapters, MSE playback, byte-range HLS bridge, c0mpute transcode
docs/openswarm/iplive.md 378 Channel and head records, key epochs, iplive extension with window backpressure, roles and relay economics, low-latency parts, recording to ipvideo
docs/openswarm/ipname.md 187 Name record, openswarm registry pin kind, DNS TXT, clearnet-first, ip:// URL
docs/openswarm/c0mpute.md 390 Node identity and payee registration, seven workload types with JobOffer shapes, thirteen use cases with CLI flows, proposed node changes
docs/openswarm/cli.md 170 Proposed ip command tree, exit codes, output, environment
docs/openswarm/conformance.md 157 Thirteen profiles with checklists, fixture suite, interop test
docs/openswarm/security.md 133 What is protected by what, key material, threats and answers, deliberate leaks, required defaults
docs/openswarm/faq.md 89
prd/0005-add-logicsrc-openswarm-spec.md 184 OpenPRD 0.2

Site registration (mirrors #140): apps/logicsrc-web/src/app/openswarm/page.tsx, nav entry in site-shell.tsx, openswarm in DOC_SLUGS, sitemap route, PRD index row, prd_next_id expectation moved to 0006 in packages/logicsrc-mcp/src/standards.test.ts. I did not run npm install or a build in the worktree; the page is a structural copy of the OpenCreds page using the same ui helpers.

What maps to existing code vs what is speculative

Exists and is reused unchanged

  • x402 v2 offer body, X-PAYMENT proof, CoinPay /api/x402/verify + /settle, USDC on Base/Polygon/Ethereum (x402-gateway, x402-client, CoinPay SDK)
  • CloudEvents 1.0 envelope and Standard Webhooks headers/signing (autoblog)
  • MTP/1 transport (X25519 + ML-KEM-768, ML-DSA-65, ChaCha20-Poly1305, TCP) as an optional node-to-node tunnel; pin format base64(SHA-256(SPKI)) (moshpit-transport, moshpit-proxy)
  • Moshpit registry API (/api/moshpit/pins, POST .../pins), clearnet-first decideResolution
  • Browser WebTorrent player, hybrid Node seeder on wss trackers, range streaming, bitmagnet DHT crawl (media-streamer)
  • c0mpute gossipsub auction (JobOffer/JobBid/JobAccept/JobReceipt), role tags, blake3 store, RS 10/14, ffmpeg transcode, gateway, live-stream DIP 0019, storage pricing
  • BitTorrent BEPs 3, 5, 9, 10, 11, 19, 27, 44, 46, 52

Speculative (all new, nothing implemented)

  • Every record type: manifest, grant, pass, voucher, receipt, hub, entry, head, track, release, title, channel, live head, name record, binding
  • The ipfile, ipdb, iplive extension messages and the paid session rules
  • Derived file/feed/channel keys and the seed model
  • The hub as a custodial settlement service with payouts (CoinPay's x402 rail today pays merchants directly and collects no fee)
  • The openswarm pin kind in the Moshpit registry (one-line registry change)
  • The seven c0mpute workload types and the --openswarm worker flag
  • The ip CLI

Checks

  • grep -rn "—\|–" over every added file returns nothing; no curly quotes.
  • All 25 JSON examples parse. Shared placeholder keys are consistent across documents (same publisher, file, seeder, leecher, hub keys everywhere).
  • Field names are consistent across specs (pricing, policy, keys, hello, credit, voucher, grant mean one thing everywhere).

Open questions

  1. Name. OpenSwarm vs IPMedia (or OpenSeed). Protocols stay ip* either way.
  2. Custodial hub. ippay has the hub hold balances and pay out. That is a different position from CoinPay's direct-to-merchant x402 rail. Is CoinPay the hub, or does the hub pay seeders per voucher directly with two-output payments?
  3. Reference price. ipfile examples use $0.01/GiB served and c0mpute storage is $0.008/GB-month + $0.005/GB egress. Should ipfile.pin be priced from the c0mpute rate automatically?
  4. Registry pin kind. Adding kind: "openswarm" to moshpit_name_pins is a one-line change on the registry; until then ipname works over DNS TXT only.
  5. Schemas and fixtures. This PR is documents only. Should the next PR add @logicsrc/schemas JSON Schemas and the fixture suite before any implementation, as OpenCreds did in one PR?

🤖 Generated with Claude Code

https://claude.ai/code/session_01YafYxayh7Gqe5MWNNQMev2

BitTorrent distributes bytes better than any CDN and has never been a
product: nobody is paid to seed, and nothing in it is private. Every
Profullstack media property answers that with a central HTTP proxy and a
pass system bolted on, and pays for every byte it serves.

OpenSwarm is an add-on to BitTorrent, carried as BEP 10 extension
messages, that fixes both. The swarm carries AES-256-CTR ciphertext whose
integrity is pinned by two SHA-256 merkle roots in a signed manifest, so
a tracker or DHT node learns an infohash and a size. A leecher buys a
pass over x402 in USDC (the same exchange x402-gateway runs for crawl
passes, settled by CoinPay), a seeder serves inside a bounded credit
window, and the leecher signs a cumulative voucher for every verified
batch. Whoever seeds gets paid. Vanilla clients remain valid members and
browsers remain first-class peers.

Adding a file mints a key pair for it, derived from one publisher seed by
default so there is one thing to back up: the public half is the file's
identity and its BEP 46 key, the private half signs the manifest and
authorises grants and payout changes, and a separate content key
encrypts the bytes and is sealed to paying peers.

The family: a core (records, keys, hashing, transports, discovery,
events), ipfile, ippay, ipdb (a signed hash-chained catalogue with heads
on the DHT), ipaudio, ipvideo, iplive (paid relays with backpressure)
and ipname (Moshpit pins and DNS TXT). Plus the c0mpute.com integration
with seven workload types and thirteen use cases, a proposed ip CLI,
conformance profiles, a security model and an FAQ.

Registered on the site the way OpenCreds is: nav entry, docs registry,
sitemap, a /openswarm landing page, PRD 0005, and the MCP prd_next_id
expectation moved to 0006.

Specs only. No code, no schemas, no reference implementation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YafYxayh7Gqe5MWNNQMev2
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

ThreatCrush Security Scan

21 finding(s)

HIGH/CRITICAL: 3 | MEDIUM: 9 | LOW: 9

Severity Rule Location
HIGH secret-private-key plugins/credential-sharing/src/providers/ssh.ts:129
HIGH js-host-header-trust apps/commandboard-web/server.js:27
HIGH js-ssrf-outbound-request apps/pwa/public/sw.js:45
MEDIUM js-unescaped-html-sink apps/commandboard-web/src/main.ts:19
MEDIUM js-unescaped-html-sink apps/logicsrc-web/src/app/[[...slug]]/page.tsx:73
MEDIUM js-unescaped-html-sink apps/logicsrc-web/src/app/layout.tsx:83
MEDIUM js-unescaped-html-sink apps/logicsrc-web/src/app/pricing/page.tsx:46
MEDIUM js-unescaped-html-sink apps/logicsrc-web/src/components/site-shell.tsx:48
MEDIUM redos-nested-quantifier packages/opencontext/src/ids.ts:10
MEDIUM redos-nested-quantifier packages/opencontext/src/ids.ts:11
MEDIUM js-timing-unsafe-mac-compare packages/opencontext/src/validate.ts:208
MEDIUM redos-nested-quantifier packages/openontology/src/ids.ts:20
LOW secret-generic-credential apps/pwa/test/appbar.test.mjs:10
LOW secret-aws-access-key packages/opencontext/src/permissions.test.ts:260
LOW secret-private-key packages/opencontext/src/permissions.test.ts:261
LOW secret-stripe-key packages/opencontext/src/permissions.test.ts:262
LOW secret-aws-access-key packages/opencontext/src/security.test.ts:228
LOW secret-private-key plugins/credential-sharing/src/providers/ssh.test.ts:7
LOW secret-database-url plugins/credential-sharing/src/rekey.test.ts:33
LOW secret-openai-key plugins/credential-sharing/src/vault-encryption.test.ts:21
LOW secret-generic-credential plugins/credential-sharing/src/vault-encryption.test.ts:21

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio marked this pull request as ready for review September 5, 2026 22:05
@ralyodio
ralyodio merged commit 4fed268 into master Sep 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant