arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation

Home Page:http://libtorrent.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hybrid Hash value aren't matching v1 hash nor v2 hash

K-Jtan opened this issue · comments

Please provide the following information

libtorrent version (or branch): libtorrent-rasterbar 2.0.10

platform/architecture: Linux (Solus and Arch Linux), x86_64

compiler and compiler version: gcc 13.2,

please describe what symptom you see, what you would expect to see instead and how to reproduce it.

  • Use a file of your choice in conjunction with libtorrent to create 3 different torrent files. The first one containing only hash v1 (lt::create_torrent::v1_only), The second one containing only hash v2 (lt::create_torrent::v2_only), The third one containing both hash (also know has hybrid torrent)
  • Open the three files with qBittorrent (v4.6.3). In the hybrid torrent file, "Torrent information" section you will notice that the Info hash v1 and Info hash v2 isn't matching the value found in the v1 torrent file nor the v2 torrent file.

I was expecting those values to match as people seeding hybrid torrents should be able to help all the leeching pools (v1_only and v2_only).

Maybe there is something I don't understand correctly. Please let me know if I'm in the wrong here.

the v1 info-hash commits to everything in the info section of the torrent file. A hybrid torrent must necessarily have some v2 fields in it, so the v1 hash will be different from a v1-only torrent.

The same applies to a v2-only torrent. It won't have the backwards-compatible v1-fields in its info section, so its info-hash must also be different.

Torrents created independently, of the same underlying files, are unlikely to have the same info-hash. Some reasons are:

  1. The ordering of the files is non-deterministic
  2. The piece size may be different
  3. the torrent creator may include extension fields (like file-hash or file attributes)

In other words, if you create a torrent and someone else also creates a torrent of the same files, the default assumption ought to be that they differ.

v2 torrents made some attempts to improve the situation by making the order of files be well defined.

All that said; the v2-only and the hybrid torrents will still share the file root hashes of the files (assuming they are identical). So there's still a mechanism to share files between v2 torrents, but the support for this is not developed in libtorrent yet.

Thank you so much for this great response.

This means that if I were to create the 3 torrent versions (v1, v2, and hybrid) I would have to seed the 3 of them in parallel as they would not connect to the same user pool. My initial thought was to seed only the hybrid torrent and people could use the v1 and v2 depending what their client supports, but in practice this isn't the case.

As I'm writing these lines, I realize that I'm probably confusing the info-hash of a torrent with the checksum hash.

You could also just seed the hybrid and everybody can use the hybrid torrent. It’s compatible with v1 clients as well as v2 clients