Libtorrent 2.0 Is Released With BitTorrent 2.0 Support

From LinuxReviews
Jump to navigationJump to search
Network-wired.png

BitTorrent is an aging protocol which works fine but there are some small problems with it. For one, it uses SHA-1 hashes which are not very secure. The new BitTorrent v2.0 protocol solves that and several other problems. libtorrent v2.0 is the first library with BitTorrent v2.0 support. The git version of the popular qBittorrent can be built against it so we expect a new qBittorrent release in the near-future.

written by 윤채경 (Yoon Chae-kyung). published 2020-09-07last edited 2020-09-16

Torrent-rasterbar-2.0-cmake.jpg
LibTorrent 2.0 uses the cmake build system.

Support for the fresh new BitTorrent 2.0 protocol, as defined in BEP 52, is the biggest highlight in libtorrent 2.0. There are several differences between the old BitTorrent protocol and the new one. Most importantly, BitTorrent 2.0 uses SHA-256 hashes instead of now insecure SHA-1 hashes. These hashes are longer, they are 32 bytes instead of 20 bytes. The info-directory is also computed using SHA-256 hashes. This would pose a big problem for existing tracker software and existing software interacting with BitTorrent DHT hashes so the new protocol implemented a simple cheat: The new SHA-256 info-hash is truncated down to 20 bytes in order to ensure compatibility.

A Piece Of Merkle Hash Trees

The BitTorrent protocol lets you download a very small file, usually just a dozen K, and use that to safely and correctly download very files. A BitTorrent torrent file is created by dividing the files put into a torrent into small pieces. These pieces are then hashed individually and the hashes are included in something called a info-directory within the torrent. These hashes make up the bulk part of a torrents file size. This simple approach was fine when the typical torrent contained a file that would fit something they used in the 1980s called a "Compact Disc". These were coasters capable of holding 700 MiB. Many of the torrents used in the current era hold files that are 50 or even 100 Gigabyte. Larger files means more piece hashes which, in turn, means bigger torrent files.

BitTorrent 2.0 uses merkle hash trees to represent the pieces. This way, a single torrent file needs nothing more than the root hash of the merkle tree to correctly download the hashes for the pieces and the pieces themselves. This allows for very small torrent files compared to the rather large file sizes some of the torrent files created with BitTorrent 1.0 get.

There's also a new more efficient directory structure within BitTorrent 2.0 torrents. That helps save additional space.

The Transition

BitTorrent 2.0 is incompatible with the old BitTorrent protocol. That does not make libtorrent 2.0 incompatible with BitTorrent, it can handle both the new and the old protocol. Older clients, however, can not interact with torrents made for the new protocol. libtorrent 2.0 supports a simple solution during the transition to BitTorrent 2.0: hybrid torrents. These are torrents capable of participating in separate swarms using both protocols. Those using older clients will be limited to one swarm and those using newer clients can participate in both.

BitTorrent 2.0 offers two new types of magnetic links:

  • v2 only: magnet:?xt=urn:btmh:{hash}
  • hybrid: magnet:?xt=urn:btih:{{v1-hash}}&xt=urn:btmh:{{v2-hash}}

The hybrid magnetic links have both the old SHA-1 hash (urn:btih:) and a new v2 merkle tree hash.

The Clients

Qbittorrent-git-2020-09-07.jpg
qBittorrent git as of September 7th, 2020 trying to compile against libtorrent 2.0. It fails miserably.

libtorrent 2.0 is a library. It does not do much on it's own. Thew new version uses cmake ( mkdir build; cd build; cmake.. && make) instead of the traditional automake ./configure && make build process and that is not the only difference. There are critical changes to the API which means that you can't just take a piece of software which compiles against libtorrent 1.x and throw libtorrent 2.0 at it and expect it to compile. It won't.

Libtorrent developer Arvid Norberg has written a "Upgrading to libtorrent 2.0" for developers who want to upgrade their software to the new library with the shiny new BitTorrent 2.0 protoocol.

qBittorrent git as of today will NOT compile against libtorrent 2.0. It will take some time before the clients using libtorrent beneath the hood adjust and make versions capable of leveraging the libtorrent 2.0 and the new BitTorrent 2.0 protocol available.

libtorrent 2.0 can be acquired from github.com /arvidn/libtorrent/releases. The website is at libtorrent.org and a official blog, with the first post in three years posted today with information about the new BitTorrent v2 support in libtorrent 2.0, is at blog.libtorrent.org.

The Russians are aware of both the new library and the new protocol (Выпуск libtorrent 2.0 с поддержкой протокола BitTorrent 2).
5.00
(one vote)

avatar

Anonymous user #1

2 months ago
Score 0++
I just wish the QBittorrent team would fix its use of Libtorrent-rasterbar to work with KaOS Linux again. Several Windows and KDE users had bugs that they reported on their github that they ignored. Still I love the news.
avatar

Anonymous user #2

2 months ago
Score 0++
What does tixati use? I like tixati.
avatar

WaiLin

2 months ago
Score 0++
Hard to say what Tixati since it is closed source with a "Personal Use Only" license. libtorrent is BSD licensed so they could be using that (BSD licensed software can be included in non-free software). Something tells me they don't because they made a new release two days ago and the changelog doesn't mention BitTorrent 2.0 support.
Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.