Recently I’ve been working on a project (not out yet, and I’m not ready to discuss it atm, but yes, it’s hinted below) that utilizes the BEP 44 standard for torrent files. So I figured I’d share a bit about lessons learned on the inner workings of torrents, and the headache recent announcements have dropped on me.
When you’re given a magnet link for, say, Project Hail Ubuntu 24.04 (that Linux ISO life ๐ค๐ผ), you’re essentially downloading a manifest for smaller pieces of the much larger download. The ID for each chunk is an infohash. This hash is a SHA-1 fingerprint of the metadata of that manifest that describes the files and lists the checksum for each piece of the overarching torrent. Your client would then take the infohash of a targeted chunk (by using it’s SHA-1 fingerprint) to the distributed hash table (DHT), trying to find peers providing a given chunk. Great - now everyone can watch the world’s most popular distro in 4K.
(This changes slightly for v2 torrents which break things into per-file Merkle trees, but the majority of torrents are still v1)
The BitTorrent community uses BEPs to suggest and propose upgrades to the protocol. For instance, in BEP 5, the DHT was proposed as a distributedly hosted mechanism to store IP addresses associated with a given hash - this powers peer discovery as we know it today. My interest lies in BEP 44 - it introduces the idea of storing small amounts of arbitrary data - up to 1KB - in the DHT. It proposes entries for both immutable data (a given SHA-1 hash of the included data is the address) and, more interestingly for me, one that supports a mutable data payload via a 32-byte ed25519 public key. Anyone with the associated private key can sign a new payload with a higher sequence number (via the protocol described in BEP 46), while those trying to impersonate the author will fail to distribute an offered mutation of the data.
The problem, of course, is that recent news [1][2][3][4][5] paints a grim reality that Ed25519 is not long for this world, and we should probably be moving on sooner than later. It’s not as easy as swapping to another signing method either, as the new algorithms fail to fit their signed keys within a single UDP packet, which Ed25519 can.
There is discussion in the community [1] about how to handle this; until then, I’ve created my own approach, flawed as it may be. The underlying goal was a stable cryptographic identity that would in turn point towards a mutable manifest. Since the identity aspect is no longer secure, I’m going to attempt a Band-Aid over it. I’m adding to the Ed25519 signed entry a SHA-512 commitment/fingerprint of a post-quantum signing identity (ML-DSA-87, chosen for its category 5 security level and smaller signatures than alternatives… and it already had a Go library for me to use). Any updates received by the application from the given mutable entry must also provide the post-quantum signature for the update to be accepted.
The problem is, of course, that you need to first know which publisher of a given Ed25519 signed entry was original. If Alice produces an entry in this manner and Bob consumes it, recording her ML-DSA-87 ensures he is immune from an impostor trying to send updated content along the same torrent key. Charlie, though, can produce a malfeasant entry and trick newcomers (but not Bob) since the DHT has no mechanism to know which is “real” that isn’t dependent upon a likely breached algorithm. This shows the use case of distributed identity management which is exactly the problem I was hoping to avoid in this project. Well, fuck. Still, I think this gets me by until the BitTorrent protocol developers figure out what to replace BEP 44 with.
Harder still is trying to get a normie user to understand this risk without their eyes glazing over. That is a problem I’m still trying to crack.