Ed2k URI Scheme - ED2k Hash Algorithm

ED2k Hash Algorithm

The eD2k hash function is a root hash of a list of MD4 hashes. It gives a different result than a simple usage of the MD4 algorithm.

The file data is divided into full chunks of 9500 KiB (9728000 bytes) plus a remainder chunk, and a separate 128-bit MD4 checksum is computed for each. If the file is greater than 9500 KiB (which means that there is more than one chunk), the eD2k hash is computed by concatenating the chunks' MD4 checksums in order and hashing the result again using MD4. Otherwise, the MD4 hash of the only chunk of the file is used with no further modifications.

This method of hashing allows the recipient to verify that a hash list corresponds to an original eD2k file hash, without the need to actually have the file present on disk.

In the past, there has been some ambiguity for files whose size is a multiple of the chunk size (9500 KiB). Old versions of some eD2k hash tools computed file hashes with an additional 0-byte chunk at the end. This is because an ambiguity of the therm reminder chunk which can be interpreted as either the last chunk or a non-full chunk at the end. Following the latter interpretation, some implementations added a zero byte chunk in case the last chunk of a file was a complete one. This practice is discouraged however and the first interpretation is used as a standard nowadays to prevent some files from having different hashes depending on the algorithm implementation used to calculate their hash.

Read more about this topic:  Ed2k URI Scheme