News for hackers. Stuff that matters.
Re:BitTorrent v2 by tomxor on Monday September 07, 2020 @06:59PM (#24403650)
> not only uses a hash tree, but it forms a hash tree for every file in the torrent [...]

> Files that are identical can also more easily be identified across different swarms, since their root hash only depends on the content of the file.

Wait, content addressed blobs across swarms... does that mean torrents made by completely different people at different times that happen to contain one or more identical files can benefit from each other's peers? If so this feels like a significant feature that would boost the long term health of a lot of torrents and connect more peers that could be helping each other.

Re:BitTorrent v2 by Thorentis on Monday September 07, 2020 @08:09PM (#24403998)
This right here is the biggest new feature in my opinion, and should have been discussed in more depth in the announcement. I also think they should have pursued this avenue further before releasing v2.

Content addressing is one of the big advantages of p2p applications, and IPFS has been pushing it for a long time.

Just imagine if this was done all the way down to the piece level. You have two different torrents (say, Linux ISOs) where 20% of the pieces overlap due to similarity (maybe a point upgrade or something and you want both versions). Rather than 100% of both, you only need to download the shared pieces once. Not only that, but say that the latest version has many more seeds/peers, you could download the pieces from that swarm instead, saving the bandwidth of the older torrent's swarm for the remaining 80% you need to download.

This could probably be done client side somehow, but it would be good to see actual protocol support for it so that bittorent can move in that direction.

Re:BitTorrent v2 by sedatk on Monday September 07, 2020 @09:44PM (#24404506)
Only if blocks have the same offset in the same binary and if they align with the block boundaries. Otherwise, different hashes would be generated. I don't expect that to happen a lot.
Re:BitTorrent v2 by aurelian15 on Tuesday September 08, 2020 @12:39AM (#24405250)
There are ways around this. See "content-aware chunking", e.g. implemented using rolling hashes [1]. This is for example what rsync does.

The idea is to make blocks (slightly) variable in size. Block boundaries are determined based on a limited window of preceding bytes. This way a change in one location will only have a limited impact on the following blocks.

[1] https://en.wikipedia.org/wiki/Rolling_hash

Re:BitTorrent v2 by octoberfranklin on Tuesday September 08, 2020 @01:02AM (#24405351)
Rolling hashing is really only useful for finding nonaligned duplicates.

There isn't a way to advertise some "rolling hash value" in a way that allows other people with a differently-aligned copy to notice that you and them have some duplicated byte ranges.

Rolling hashes only work when one person (or two people engaged in a conversation, like rsync) already has both copies.

Re:BitTorrent v2 by btschaegg on Tuesday September 08, 2020 @01:34AM (#24405478)
I think you misunderstood how the rolling hash is used in this context. It's not used to address a chunk; you'd use a plain old cryptographic hash function for that.

The rolling hash is used to find the chunk boundary: Hash a window before every byte (which is cheap with a rolling hash) and compare it against a defined bit mask. For example: Check if the first 20 bytes are zero. If so, you'd get chunks with about 2^20 bytes (1 MiB) average length.

As a good explanation, I'd encourage you to look at borgbackup's internals documentation: https://borgbackup.readthedocs.io/en/stable/internals.html

Re:BitTorrent v2 by hinkley on Tuesday September 08, 2020 @02:11AM (#24405637)
I think they understood just fine.

If I discover that the file I want to publish shares a range with an existing file, that does very little because the existing file has already chosen its chunk boundaries and I can’t influence those. That ship has sailed.

I can only benefit if the a priori chunks are small enough that some subset of the identified match is still addressable. And then I may only get half of a two thirds of the improvement I was after.

Re:BitTorrent v2 by dchest on Tuesday September 08, 2020 @04:53AM (#24406505)
that does very little because the existing file has already chosen its chunk boundaries

If they both used the same rolling hash function on the same or similar data, regardless of the initial and final boundary and regardless of when they chose the boundaries, they will share many chunks with high probability. That’s just how splitting with rolling hashes work. They produce variable-length chunks.

Re:BitTorrent v2 by tleb_ on Tuesday September 08, 2020 @04:31AM (#24406374)
The idea is that on none random data, you are able to use a heuristic that would create variable-sized chunks that fit the data. The simplest way seems to detect padding zeros and start a new block on the first following none zero byte. There probably are other ways, knowing the data type should help.
Re:BitTorrent v2 by hinkley on Tuesday September 08, 2020 @11:46AM (#24409533)
That seems fairly unlikely. Not a lot of big files have zero padding, and if they did them compress them. It will reduce your transfers more than and range substitutions ever will.
Re:BitTorrent v2 by computerphage on Tuesday September 08, 2020 @12:12AM (#24405128)
It will still definitely help some use cases:

> Identical files will always have the same hash and can more easily be moved from one torrent to another (when creating torrents) without having to re-hash anything.

Re:BitTorrent v2 by naikrovek on Monday September 07, 2020 @10:30PM (#24404721)
Well if files in an ISO are aligned to some boundary it would help a lot, similar to how filesystems on disk have a sector size, where all files begin at the start of a sector. However, I don't know if this is true in ISO9660 or any of its extensions.
Re:BitTorrent v2 by em-bee on Monday September 07, 2020 @11:00PM (#24404859)
ISO is a mountable filesystem so this could be the case if it doesn't have any space saving optimizations that create variable block sizes.

also need to watch out for compression

Re:BitTorrent v2 by Ericson2314 on Monday September 07, 2020 @08:48PM (#24404198)
Hopefully it would also be good for interopt between the two, as anything with a small enough block size could be picked up by IPLD.
Re:BitTorrent v2 by sbierwagen on Monday September 07, 2020 @09:21PM (#24404377)
>Just imagine if this was done all the way down to the piece level.

I don't know about that. With a reasonably large number of users, wouldn't you start seeing hash collisions via birthday paradox? Might be better off keeping it at the file level. (Though this does incentivize malicious users to find hash collisions of particular files they want to defend, and seeding the swarm with garbage files)

Re:BitTorrent v2 by doomrobo on Monday September 07, 2020 @09:43PM (#24404498)
Hashes are now 256 bits. In order to get a collision with probability 1% you need to produce about 4e37 hashes. For comparison, if you had a 5GHz computer that did a SHA-256 hash every cycle and gave 100 of these computers to every human on Earth, it'd take over 300 million years to produce 4e37 hashes.
Re:BitTorrent v2 by ShinTakuya on Monday September 07, 2020 @10:09PM (#24404645)
Yep, basically while it's entirely possible (as per Murphy's Law) that there'll be an accidental collision, the likelihood is close to zero. It's a fair risk to be taking.
Re:BitTorrent v2 by fenomas on Monday September 07, 2020 @11:51PM (#24405051)
> In order to get a collision with probability 1% you need to produce about 4e37 hashes

Does "get a collision" here mean finding a particular collision with a known hash, or finding any collision between any two of the generated hashes?

Re:BitTorrent v2 by doomrobo on Tuesday September 08, 2020 @12:37AM (#24405242)
The latter. I used the formula from the Wikipedia page on the birthday attack: p ~= 1 - e^{-n^2/2H} where n is the number of items you've picked and H is the size of the universe
Re:BitTorrent v2 by fenomas on Tuesday September 08, 2020 @12:49AM (#24405299)
I see, thanks!
Re:BitTorrent v2 by fomine3 on Monday September 07, 2020 @09:44PM (#24404500)
All git objects on GitHub has unique hash in 2017 even though git uses relatively weak SHA-1. SHA-256 should be safe.

https://github.blog/2017-03-20-sha-1-collision-detection-on-...

Re:BitTorrent v2 by em-bee on Monday September 07, 2020 @10:03PM (#24404621)
the birthday paradox comes from the fact that there are an extremly small number of birthdays.

sha-256 was chosen because it provides a sufficiently high number of different hashes that this won't be an issue for the forseeable future.

more details here: https://stackoverflow.com/questions/4014090/is-it-safe-to-ig...

Re:BitTorrent v2 by yc12340 on Monday September 07, 2020 @11:00PM (#24404860)
> Wait, content addressed blobs across swarms... does that mean torrents made by completely different people at different times that happen to contain one or more identical files can benefit from each other's peers?

Yes. It also makes your files more discoverable for copyright trolls. They will be able to fully automate the process of sending takedown notices for each copy of zlib's README.txt, that was "stolen" from their software by evil pirates.

Re:BitTorrent v2 by knodi123 on Tuesday September 08, 2020 @01:39AM (#24405501)
> this feels like a significant feature that would boost the long term health of a lot of torrents

Except for so many that are a single archive file. It seems logical that you'd want to compress what you're sending as much as possible before uploading... but in today's bandwidth environment, it actually makes sense to leave certain things uncompressed so you can benefit from swarm overlaps?!? Wild!

Re:BitTorrent v2 by abluecloud on Tuesday September 08, 2020 @05:18AM (#24406641)
do two identical compressions produce the same output? if so, wouldn't the same thing happened just against the compressed files?

It's not uncommon to see multiple .torrent files with the same content FYI.

Re:BitTorrent v2 by AnIdiotOnTheNet on Tuesday September 08, 2020 @10:01AM (#24408422)
Normally no, compression formats like zip are not guaranteed to produce the same output for the same input. That's why things like torrentzip and torrent7zip were created, to ensure that the same input did create the same output.
Re:BitTorrent v2 by the8472 on Monday September 07, 2020 @07:43PM (#24403855)
A client can do that optimization locally, but there's no discovery mechanism in the protocolto find additional infohashes that contain some of the same files . But I suppose torrent indexing sites could offer something like that.
Re:BitTorrent v2 by terrortrain on Monday September 07, 2020 @09:16PM (#24404347)
I haven't looked at it for a while, but wasn't that the big feature of ipfs?
Re:BitTorrent v2 by runeks on Wednesday September 09, 2020 @02:10PM (#24423947)
Yep. But the difference is that everyone uses BitTorrent and no one uses IPFS.
Re:BitTorrent v2 by aaron695 on Monday September 07, 2020 @10:30PM (#24404722)
> completely different people at different times that happen to contain one or more identical files

Yes, this won't be useful for speed.

But it will be useful for health and appearance of health.

So a torrent that has no seeds because it's missing "RARBG_DO_NOT_MIRROR.exe" can be filled in quickly and have proper seed info.

Also large seasons can be filled in. They get corrupted at later episodes because people will prioritise the first episodes then the seeds can jump.

So anyone filling in the later episodes through single episodes torrents might repair the season torrent.

It'll allow over lap between torrents only differentiated be a missing RARBG.txt if they are both fragmented.

There's always been talk of allowing a torrent to have files added to it. It's be interesting to see if this might be useful client side to do this in a Claytons way.

Personally I don't think it's useful for Linux isos. Not sure on this. Do Linux isos get unhealthy?

Re:BitTorrent v2 by em-bee on Monday September 07, 2020 @11:07PM (#24404884)
patch releases, especially security patches would only have a small number of changes that might allow me to take a full new release but only update the changes to the release i already have.

but it would take some handcrafting to make sure the new files are at the end of the ISO so everything else stays in place.

technically this should be possible since ISO should allow for adding files given that it was designed for write-once media.