2

The decoupled storage pattern (https://blog.colony.io/writing-upgradeable-contracts-in-solidity-6743f0eecc88) uses a hash function (keccak) to turn arbitrary length values into 32 byte keys for the storage mappings.

Am I supposed to worry about hash collisions? Or is keccak256 magic, and not ever do that? Seems like having a collision could break a lot of things.

1 Answer 1

3

It's a good question because it's not impossible.

What we can say is there is no known hash collision, i.e. none has ever been discovered.

I personally defer to those with stronger math credentials and I wouldn't challenge anyone else's view of probability. It's my understanding that most of Ethereum will come apart, not to mention many Dapps if collisions turn out to be more likely than they thought.

In the meantime. No. Not something "we" need to worry about.

Hope it helps.

6
  • I guess you can really fit a lot of different combinations into 32 bytes....
    – jazzhole
    Apr 10, 2018 at 4:18
  • 2
    2^256 (the number of possible keccak-256 hashes) is around the number of atoms in the known observable universe. A collision means picking two atoms at random and having them turn out to be the same atom.
    – user19510
    Apr 10, 2018 at 7:54
  • 1
    I think that thought experiment oversimplifies it a bit -- you're not just picking two atoms, you're picking millions (billions? trillions? more?) of atoms and hoping that none of them are the same.
    – jazzhole
    Apr 24, 2018 at 4:33
  • @jazzhole no, it's not oversimplified. The numbers of possible hash outputs is higher than the total amount of atoms in the observable universe. So the argument is not about their composition (1 bytes = 8 bits), but rather about the sheer vastitude of all possible permutations of each of those compositions. Sep 23, 2019 at 11:58
  • I think jazzhole is correct in the question. User19510 posits that the likelhoold of a collision si the probability of picking two atoms at anding and having them be the same. Jazzhole accurately states that theproblem of hash collissions is more like picking millions/billions/trillions of atoms (the number of possible hashes that are ever used to refer an object in the same scope, say, the number of ethereum transactions over the next 500 years say) and hoping that no two of those atoms are the same.
    – GGizmos
    Aug 9, 2021 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.