I am building a generic backend for dataset annotation. It is designed using event…
- User
I am building a generic backend for dataset annotation. It is designed using event sourcing. Initially, in the core library, I designed the events to be signed by ED25519 keys.
Now that I am building the API I think that this will be too cumbersome for user adoption. My API is authenticated via API key. I could remove this field in the events and replace it with a user name. I could also sign everything with a single server key or have the server manage user cryptographic keys alongside the API keys.
I don't think the signatures are necessary for integrity because you could still hash all the events in order and have a mark for integrity. The signatures would make it harder to tamper with.
- Assistant
- User
In this case the event history will be redistributable so that anyone can reproduce the dataset. What do you think is best for that situation? It is kind of like a git history, individual commits aren't signed.
- Assistant
If the event history is meant to be redistributable and your goal is to enable anyone to reproduce the dataset similar to a git history, then the following considerations come into play:
-
Integrity over Authenticity: The primary goal is to ensure that the event history hasn't been tampered with. This is similar to how git uses SHA-1 hashes for commits to ensure the integrity of the commit history, even though individual commits may not be signed.
-
Global Verification: Anyone should be able to verify the integrity of the event history without needing specific keys or cryptographic proofs from individual users.
-
- User
I'm thinking of adding fields called integrity and author, to replace signature and signer. In most cases integrity can be a chained hash. This could also be a chained signature in other cases.
- Assistant
Adding "integrity" and "author" fields sounds like a pragmatic approach. This gives you the flexibility to adapt to various use cases while maintaining clarity in your data structure. Here's a breakdown of your proposal:
- User
This is tricky to time in the context of a web application. I will need to get the previous event's hash, then hash the current event, add the hash. Probably need to lock while doing that.
- Assistant
- User
Does git incorporate the previous commit's hash?
- Assistant
Yes, Git does incorporate the parent commit's hash when calculating the hash for a new commit. This is a fundamental feature that provides the integrity and immutability properties of Git's commit history.
Here's a simplified explanation:
-
Each commit in Git has one or more parent commits, except for the initial commit. The commit hash is created using the contents of the commit message, the commit metadata (like the author and date), the content snapshot (represented by the tree object), and the hashes of the parent commits.
-
When you create a new commit, Git calculates its hash by taking into account the hash of the current HEAD (the last commit in the current branch) as its parent.
-
This chaining of commits through their hashes ensures that once a commit is made, changing any part of its content, metadata, or any of its ancestors would require recalculating the hashes of all descendant commits. This makes the commit history tamper-evident.
This structure is what makes Git a Merkle Tree (or more commonly in the context of Git, a Directed Acyclic Graph - DAG). If any part of a commit or its history is changed, the commit's hash and all descendant commit hashes will change, providing a clear indication that the history has been altered.
-