Skip to content
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

Relative key encodings for child references #36

Open
mappum opened this issue Apr 1, 2020 · 1 comment
Open

Relative key encodings for child references #36

mappum opened this issue Apr 1, 2020 · 1 comment

Comments

@mappum
Copy link
Collaborator

mappum commented Apr 1, 2020

Each node must contain the keys of its children in order to be able to traverse the tree. This adds significant overhead compared to the actual data itself, especially when keys are long.

Since a node's children's keys will often be very similar to it's own and only differ at the last few bytes, we can cheaply shave down that data by instead storing keyA XOR keyB, removing leading zeroes. When traversing, we can expand into the full key by XORing once again with the parent node's key.

We also have to handle keys which are a different length, and this can be done with a second vector of additional bytes which are not part of the XOR.

@mappum
Copy link
Collaborator Author

mappum commented Apr 1, 2020

This gives us the space-saving benefits of a trie without relying on random orderings to balance the tree.

We can also use this compact encoding in generated proofs in order to make them significantly smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant