rhash / RHash

Great utility for computing hash sums
http://rhash.sf.net
BSD Zero Clause License
585 stars 116 forks source link

add algorithm: bittorrent v2 merkle root hash #247

Open milahu opened 1 year ago

milahu commented 1 year ago

btih and ed2k hashes are already supported, so adding this seems legit

implementations of the bittorrent v2 merkle root hash algorithm:

this hash is used to share identical files between multiple torrents

effectively, it splits the file into 16*1024 byte blocks, adds zero-blocks to get a power-of-two number of blocks, and builds a binary tree of hashes (merkle tree) over these blocks, where the last hash is the "merkle root hash"

"btrh" (bittorrent root hash) could be used as a short name, similar to "btih" (bittorrent info hash)

similar issue: https://github.com/namazso/OpenHashTab/issues/193

ppetr commented 7 months ago

The short name should rather be btmh (for "BitTorrent Multi-Hash"), following the standardized prefix magnet:?xt=urn:btmh:.

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

milahu commented 7 months ago

The short name should rather be btmh

no, btmh is a different hash

one torrent has one btmh hash (and/or one btih hash) btmh and btih hash the metadata: file paths, root hashes, ...

there is one "root hash" for every file in the torrent one torrent has one or more files the root hashes of files hash only the file contents = content addressing

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

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. 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.