-
Couldn't load subscription status.
- Fork 0
Add sharding support to SMT #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Child mode (for child aggregator in sharded setup) differs from normal mode (for monolithic aggregator) by taking a shard ID and using its most significant bit as the "path" for the root node to get the corrrect hash value for the corresponding node of the parent aggregator's SMT.
Parent mode (for parent aggregator in sharded setup) differs from normal mode (for monolithic aggregator) in three ways: - is allows values in leaves to be updated; - the leaves are not hashed (instead they contain hash values computed by and received from child aggregators); - to maintain fixed structure, the tree is really not sparse at all.
|
Note that this change breaks compatibility for client-side SDKs and probably should not be merged until the SDKs also have updates ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| // JoinPaths joins the hash proofs from a child and parent in sharded setting | ||
| func JoinPaths(child, parent *api.MerkleTreePath) (*api.MerkleTreePath, error) { | ||
| if len(child.Root) < 4 { | ||
| return nil, fmt.Errorf("invalid child root hash format") | ||
| } | ||
| if len(parent.Steps) == 0 { | ||
| return nil, fmt.Errorf("empty parent hash steps") | ||
| } | ||
| if parent.Steps[0].Data == nil || *parent.Steps[0].Data != child.Root[4:] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe create a constant or add a comment what this 4 means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we now use one hash function identifier for the whole inclusion proof, perhaps in fact better to extract it into a separate field and change the root hash into a plain hash value instead of keeping them merged into an imprint?
An SMT can now be created in child, parent or normal mode.
Normal mode is for use in a monolithic (non-sharded) aggregator and behaves as before.
Child mode is for use in a child aggregator in sharded setup. Difference from normal mode:
Parent mode is for use in parent aggregator in sharded setup. Differences from normal mode: