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

SSZ hash: error in Container hashing function #704

Closed
wants to merge 1 commit into from

Conversation

zilm13
Copy link
Contributor

@zilm13 zilm13 commented Feb 28, 2019

What's wrong

PR #595 that changed usage of regular hash to merkle_hash for Containers adds an error, because container fields are not of homogeneous length if you follow the spec. Let me point it:

  1. Container

Recursively tree hash the values in the container in the same order as the fields, and Merkle hash the results.

return merkle_hash([hash_tree_root_internal(getattr(x, field)) for field in value.fields])
  1. The below hash_tree_root_internal algorithm is defined recursively in the case of lists and containers, and it outputs a value equal to or less than 32 bytes in size.

 # Merkle tree hash of a list of **homogenous**, non-empty items
def merkle_hash(lst):

Proposal

Use hash_tree_root instead of hash_tree_root_internal in Container function, so fields are homogenous.

@JustinDrake
Copy link
Collaborator

The SSZ spec was rewritten here, and no longer has a hash_tree_root_internal. Feedback welcome there :)

@zilm13
Copy link
Contributor Author

zilm13 commented Feb 28, 2019

@JustinDrake yeah I saw it, but it looks too far from final. Or did you decide to remove Python code at all? It helped a lot. So new spec doesn't contain this error?

@JustinDrake
Copy link
Collaborator

I believe the re-write does not have this error.

@zilm13
Copy link
Contributor Author

zilm13 commented Feb 28, 2019

Cool, so I close this and trying to get into rewrite

@zilm13 zilm13 closed this Feb 28, 2019
@zilm13 zilm13 deleted the fix/ssz-container branch February 28, 2019 17:03
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

Successfully merging this pull request may close these issues.

None yet

2 participants