-
Notifications
You must be signed in to change notification settings - Fork 975
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
Added tree hashing algorithm #120
Conversation
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.
It's pretty dense. I would give some more motivation/explanation in the header.
Specifically, why this instead of a straight merkle tree? This allows for easy updates when isolated SSZ containers/lists are modified.
It would be nice to have an example of |
@mkalinin you can find this here: https://github.com/ethereum/beacon_chain/blob/vitalik_hash_ssz/hash_ssz.py I imagine @djrtwo will copy the code or something like it into the python impl once this gets finalized/approved. |
specs/simple-serialize.md
Outdated
chunkz.append(b'\x00' * CHUNKSIZE) | ||
chunkz = [hash(chunkz[i] + chunkz[i+1]) for i in range(0, len(chunkz), 2)] | ||
# Return hash of root and length data | ||
return hash(chunkz[0] + datalen) |
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.
nitpick: lst
/ chunkz
can be empty in the general case
Adds to the SSZ spec an algorithm for tree-hashing SSZ objects.
Experiments suggest that the hashing time required is increased by a factor of ~4-6, partly because Merkle hashing inherently raises the amount of data hashes due to multiple layers of hashing and partially because hash functions have a fixed computation cost in addition to the per-byte cost.