Part 1 - Performance:
Currently signatures
is a separate field, and other fields are unsorted vectors. This leads to following inefficiencies:
-
O(n^2) check for verification. Each false hit entails a throw-away signature verification.
This can be optimised if we use a HashMap instead of a vector and integrate signatures
field with owners
field. The ShareableData
would now take the form:
ShareableData {
// .... other fields ...
current_owners: HashMap<Owner, Option<Signature>>,
prev_owners: HashMap<Owner, Option<Signature>>,
}
Those opting to sign would put the signature mapped to their ownership instead of in a different field. Data to sign would be same as previously:
sign(other_fields + current_owners.keys() + previous_owners.keys());
This eliminates an O(n^2) here and turns this from O(n^2) to O(n).