BitTorrent has evolved. The open source library, perhaps the most famous, that implements this protocol, that is, libtorrent, has just released its version 2.0 and its most important feature is that it supports BitTorrent v2.
BitTorrent v2 is a new version of the protocol in which it has been working for a long time and whose initial objective was to move from SHA-1 to SHA-256, that is, the secure hashing algorithm to handle the parts of the torrents. But BitTorrent v2 brings more important changes than that.
The Big BitTorrent Hash Tree v2
In BitTorrent v1, the parts of the files and the resulting hashes are included in the metadata of the .torrent file. In most cases, the hash of the parts is the bulk of the size of the .torrent files.
To keep the size of the .torrent file within the limits of large files, the chunk size can be increased, which means that each hash represents a larger portion of the file. A consequence of large part sizes is that if a hash fails, a larger portion of the file has to be downloaded again, until the part passes the hash check.
Now, BitTorrent v2 uses something called “merkle hash trees” or hash tree, that is, a tree data structure to represent each of the hashes of the parts. This makes .torrent files small because all it takes is the root hash of the tree.
Example of a hash tree with four blocks and a 32 kiB part (two blocks per part)
The advantages of this are several. First, the torrent metadata gets much smaller, this cuts the latency when we add a magnetic link as fewer bytes need to be downloaded before torrent download can start.
And second, the downloaded data can be validated at the block level. That is, if a peer submits corrupted data, it can be discovered immediately and you only have to download the 16 kiB of the size of the hash tree which is always the same.
BitTorrent v2 not only uses a hash tree, it forms a hash tree for each file in the torrent. This is advantageous because identical files will always have the same hash and can be more easily moved from one torrent to another without having to re-hash anything.
Another very important advantage is that files that are identical can be more easily identified through different swarms. This could have the potential to optimize file downloads by getting parts from different torrents as long as they have identical parts with the same hash.
With BitTorrent v2, apart from improvements in hashes management, file generation, encoding and magnetic links have also been improved. You can read more details in the official announcement. At the moment not all functions are backward compatible with BitTorrent v1These have already been carefully renamed so that they can live with v1.
Currently it is possible to create hybrid torrents that can participate in swarms of version 1 and version 2 at the same time serving the same files.