Make Hashable not use protobuffs? #330
Labels
App:Backend
App:Frontend
Kind:Core
Anything that changes or affects the fundamental core data structures & design of the application.
Kind:Enhancement
Improvements, new features, performance upgrades, etc.
Level:Advanced
Note:Question
Note:Research
Priority:High
Problem
Our current solution for dealing with potential JSON hash inconsistency is to use protobuffs that clearly define the order of keys. However, it might not be necessary to do that.
Solution
If we just store in the database the first version of the JSON string that was created, and only use that string from then on, then we don't need to use protobuffs at all because the ordering of keys is set in stone from that point on.
Getting rid of protobuffs would mean:
events.js
file instead of twoexport class Action extends Hashable
andexport class Attribute extends Hashable
etcTo do this we would need to send the JSON directly as a string. I.e., instead of:
Do:
One of the downsides to try and mitigate is that currently we get runtime validation of the data that's being sent, and it's clear from the
shared/events.js
file what (a) the events are, (b) what data they expect.That clarity should be preserved when closing this issue, perhaps via a JSON validator like ajv.
Potential issues?
Implementing this would mean that the hash can no longer be used to verify the integrity of JS objects. Instead, a JS object is considered "verified" if all of these are true:
EDIT: Since the signature is detached from the JSON itself, double-check that there are no issues if the parts of the JSON that are outside of that signed part are modified!
For example, is there any issue with replay attacks?
EDIT 2: Should be able to get rid of all the classes and just have it be version-specific selector + data
The text was updated successfully, but these errors were encountered: