nervosnetwork / sparse-merkle-tree

45 stars 37 forks source link

Extension to summation merkle tree #51

Open Stentonian opened 1 year ago

Stentonian commented 1 year ago

Hi there! I am in the process of finishing off this repo which is an implementation of a paper specifying a protocol that exchanges can use for proof of liabilities ("Generalized Proof of Liabilities" by Yan Ji and Konstantinos Chalkias ACM CCS 2021). I need a rust implementation of a sparse summation merkle tree and I would like to use this repo as a base.

A summation merkle tree is like a regular merkle tree but each node has an addition element, an integer. The numbers in the leaf nodes can be set to any arbitrary value, but the numbers in any node that is a parent must be set to the sum of the numbers of its children. The hash also changes from H(left_child_hash | right_child_hash) to H(left_child_hash | right_child_hash | left_child_number | right_child_number).

Would it be okay if I do a PR to this repo that adds the above functionality? I want to rather ask before putting in the effort to do the work. Ideally I'd rather do a PR here as apposed to forking the repo.

XuJiandong commented 1 year ago

Since it's already used in production, I don't think it's feasible to update the hash method.