Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Currently, a magnet link containing a 40-digits long SHA-hash value, is assigned

ID: 651312 • Letter: C

Question

Currently, a magnet link containing a 40-digits long SHA-hash value, is assigned to every torrent which is created. Therefore, this hash should be unique to identify a torrent and send the right bytes (packages) to the right people. So therefore, there are 16^40 (1461501637330902918203684832716283019655932542976) possible hashes to uniqueliy identify a torrent. What happens after this number has been reached or two torrents with different content have the same hash? (Although this practically never happens, there is a chance of (x+1)/(16^40) where x is the number of public torrents aka. assigned hashes, that your hashes collide.)

So to make long things short: What happens if two magnet-link-hashes are equal for different contents? What happens after every magnet-link has been used?

Explanation / Answer

16^40 is a huge number. For instance, if you consider each torrent to consist in a single byte each (so they are quite uninteresting torrents), and you pack them all on 10 TB hard disks (for a torrent to exist, it must exist on at least one hard disk on the planet), and if each such disk weighs about 100g, then the total weight of the disks is about 24 billions of times the mass of the whole Earth.

So I am quite confident in stating that this number will not be reached.

Risks of collisions are actually higher. If you accumulate 160-bit hash values (outputs of SHA-1) then, on average, the first collisions should appear after about 2^80 values (this is known as the birthday paradox). So the situation you describe may occur much earlier than after exhaustion of the 16^40 space. But 2^80 is still huge, and cannot be practically achieved (280 torrents mean more than one hundred thousand billions of torrents per human being on Earth).

If a hash collision occurred, then streaming either of the two colliding files would most probably cease to work; downloaders would obtain a mixture of both files. Other torrents would remain totally unaffected.

An interesting question is whether you could, given an existing torrent T, handcraft another T' which hashes to the same value -- it would be used as a weapon to prevent usage of T. To do that, you would have to break second preimage resistance of the hash function. SHA-1 has a few known weaknesses, but for now there is no known method for obtaining a second preimage, except luck (try random values until one matches). Luck (aka "brute force") has average cost 2^160, which is completely out of reach of today's (and tomorrow's and next decade's) technology.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote