Distributed Hash Tables are a great way to store immutable data in a resilient way.
However, I am wondering about how it would be possible to store new versions of old data in this system.
Because it is impossible in a distributed network to unconditionally trust the other party, a way is needed to ensure that another party does not manipulate stored data. The easiest way to do this is to store data values under keys that are generated from these values using a one-way hash function. This means that when someone wants to change data, they invalidate the key->value relation of that data, which is easy to check against.
Say, someone stores a document in the DHT, but later made some changes and wants to store that new version. How can other people connected to the DHT find out that there is a new version of this document? The only information that I found about this said that an idea would be to store versioned data like this:
v1: hash(random_number) -> document1 v2: hash(key(v1)) -> document2 v3: hash(key(v2)) -> document3 ...etc.
Then, to check if there is a new version, all a client would need to do is to apply the hashing algorithm one more time to the hash of the current value.
Drawback: This approach does not have the relation between key and value, meaning that a value might be changed (by a malicious server or a man-in-the-middle) without invalidating the key.
How can these two approaches be combined? Or is there a different, better way to manage this?