geohot / minikeyvalue

A distributed key value store in under 1000 lines. Used in production at comma.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data integrity feature?

VladUsatii opened this issue · comments

Just a suggestion for implementing (tell me if it doesn't make sense for the project):

  • File integrity: Append the hash of of the previous index value of data (SHA-256) to the newest index value. This prevents tampering with file contents, because every machine can check to make sure that the appended block hash of some index is equal to the block hash of the (index - 1) contents.

Further clarification with this image:
image

Keep in mind that h_0 represents hash of the newest data || h_1, and h_1 is the hash of data || h_2, and so on. This nested check ensures file integrity.

Mutability requires a re-computation of the hashes, but can only be done with a key.

Feedback? Will this fit in the 1000-line requirement?