BitTorrent version 2 is SHA256 compliant, more secure, and has a hash tree for efficiency



BitTorrent, a file transfer protocol using P2P , reached version 2 in 2017, and various improvements have been added, such as support for SHA-256 and the introduction of hash trees. Libtorrent , an open source BitTorrent implementation, describes the new features of BitTorrent version 2 on its blog, along with a completion report for BitTorrent version 2.

BitTorrent v2
https://blog.libtorrent.org/2020/09/bittorrent-v2/

BitTorrent version 1 used SHA-1 for hashing pieces, but SHA-1 could not detect tampering with the piece because Google confirmed a collision. BitTorrent version 2 is more secure by using SHA-256 for the hash function. Also, along with the change in the hash function, some new features were also installed.

The big change is the introduction of hash trees. In BitTorrent, the file was fragmented into units called pieces, the hash values of all pieces were recorded in a torrent file, and the hash values of the downloaded pieces were checked one by one to confirm the data integrity. This method had the problem that if a huge piece failed to hash, it would increase the amount of data that needed to be downloaded again.

BitTorrent version 2 introduces a hash tree to compress the metadata part of a torrent file. It has succeeded in shortening the waiting time when using the magnet link and compressing the data capacity when re-downloading pieces. The hash tree of BitTorrent version 2 has the structure shown in the figure, and it is explained that a piece of data called a 'block' is hashed and the hashed value is stored as a piece hash in a torrent file. I will.



In addition, BitTorrent version 2 makes it easy to identify duplicate files and search multiple sources of files by building all files included in torrent files as a hash tree. ..

Although the files included in Torrent are listed and described in Torrent files, the BitTorrent version 1 file list was represented as a single list. However, this approach caused duplicate occurrences of the same directory, which was a problem when long directory names were used.

[code]'files': [
{'attr':'x','length': 12323346,'path': ['F' ]},
{'attr':'p','length': 62958,'path': ['.pad', '62958' ]},
{'attr':'x','length': 2567,'path': ['long directory name','A' ]},
{'attr':'p','length': 62969,'path': ['.pad', '62969' ]},
{'attr':'x','length': 14515845,'path': ['long directory name','B' ]},
{'attr':'p','length': 33147,'path': ['.pad', '33147' ]},
{'attr':'x','length': 912052,'path': ['long directory name','C' ]},
{'attr':'p','length': 5452,'path': ['.pad', '5452' ]},
{'attr':'x','length': 1330332,'path': ['long directory name','D' ]},
{'attr':'p','length': 45924,'path': ['.pad', '45924' ]},
{'attr':'x','length': 2529209,'path': ['long directory name','E' ]}
],[/code]



Starting with BitTorrent version 2, we are creating the list efficiently by incorporating the directory structure into the list.

[code]'file tree': {
'F': {'': {'attr':'x','length': 12323346,'pieces root':'d1dca3b4a65568b6d62ef2f62d21fcdb676099797c8aa3e092aa0adcb9a9f6a5' },
'Long directory name': {
'A': {'': {'attr':'x','length': 2567,'pieces root':'f6e5b48ebc00d7c6351aafdec9a0fa40ab9c8effe8ac6cfb565df070d9532f70' }},
'B': {'': {'attr':'x','length': 14515845,'pieces root': '271d61e521401cfb332110aa472dae5f0d49209036eb394e5cf8a108f2d3fb03' }},
'C': {'': {'attr':'x','length': 912052,'pieces root':'d66919d15e1d90ead86302c9a1ee9ef73b446be261d65b8d8d78c589ae04cdc0' }},
'D': {'': {'attr':'x','length': 1330332,'pieces root': '202e6b10310d5aae83261d8ee4459939715186cd9f43336f37ca5571ab4b9628'} },
'E': {'': {'attr':'x','length': 2529209,'pieces root': '9cc7c9c9319a80c807eeefb885dff5f49fe7bf5fba6a6fc3ffee5d5898eb5fdb' }}
}
},[/code]



The implementation of BitTorrent version 2 can be confirmed in the following torrent file.

(Torrent) https://libtorrent.org/bittorrent-v2-test.torrent

in Software,   Web Service, Posted by darkhorse_log