As I understand it it’s possible to add a file (to the IPFS network), get a hash, remove the file, and then add the file again after an arbitrary amount of time (10 days, 10 years, etc) and get the same exact hash, meaning the old/original hash URL will still work once you re-add the file to the network, which seems to mean that there is a unique hash for every possible file.
(See https://news.ycombinator.com/item?id=18028820 and just fake adding files with “-n” like so:)
$ ipfs add -n my_file.tar.gz #try 1 added QmZYUCRTp3iKusMdQP1oWKHpkCDzinM4j2VdATxXSNEVYv my_file.tar.gz 10.23 MiB / 10.23 MiB [==================================================================] 100.00% $ ipfs add -n my_file.tar.gz #try 2, same hash! added QmZYUCRTp3iKusMdQP1oWKHpkCDzinM4j2VdATxXSNEVYv my_file.tar.gz 10.23 MiB / 10.23 MiB [==================================================================] 100.00%
My question is, how can that work if there are astronomically more possible files then there are hashes (even on very old filesystems)?
ext4 has a max file size of 16 TiB, and if google calculator is correct that’s 1.407e+14 bits, so “2 to the power of 1.407e+14” possible files, while possible hashes are usually something like “2 to the power of 128” (340.282.366.920.938.463.463.374.607.431.768.211.456 possible hashes) or “2 to the power of 256” (115.792.089.237.316.195.423.570.985.008.687.907.853.269.984.665.640.564.039.457.584.007.913.129.639.936 possible hashes).
Even if you go down to a more responsible size like say 10 MB, that’s 80 million bits, or “2 to the power of 80 million” possible files, again: way more files then there are hashes.
- Does IPFS have a unique hash for every possible file (which my amateur math seems to indicate is not possible)?
- Is my math simply wrong and we have more than enough hashes for every possible file?
- Does IPFS perhaps do some trickery to have enough hashes for not all files but simply the number of files that realistically will ever be added to the network?
- Something else?
A more simple and general question: is it possible to have a hash/id schema that could generate an id for every possible file?