Skip to content

Segwit arbitrary commitment trees & faster hashing #75

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

Open
wants to merge 4 commits into
base: segwit-master
Choose a base branch
from

Conversation

maaku
Copy link

@maaku maaku commented Apr 19, 2016

The witness root is allowed to be placed at an arbitrary position up to seven layers deep in a Merkle tree structure. The witness nonce is now the branch through the commitment tree to the witness root, and a single byte is added to the commitment output specifying this path in compact form. This allows other consensus commitments to be added in the future with a minimal number of bytes and without committing at this time for a certain position for the segwit branch within the tree.

In addition, switch to fast Merkle trees for witness. A fast Merkle branch uses midstate to perform a single SHA-256 compression per branch, and is not vulnerable to CVE-2012-2459. It produces different hashes though, so can only be used for new hash trees going forward.

maaku added 4 commits April 19, 2016 10:11
The witness root is allowed to be placed at an arbitrary position up to seven layers deep in a Merkle tree structure. The witness nonce is now the branch through the commitment tree to the witness root, and a single byte is added to the commitment output specifying this path in compact form. This allows other consensus commitments to be added in the future with a minimal number of bytes and without requiring a certain position for each commitment in the tree.
This allows the intermediate state of a SHA-256 run to be saved for future resumption, or in the case of fast Merkle trees to perform a non-padded hash.
A fast Merkle branch uses midstate to perform a single SHA-256 compression per branch, and is not vulnerable to CVE-2012-2459. It produces different hashes though, so can only be used for new hash trees going forward.
@maaku maaku mentioned this pull request Apr 19, 2016
7 tasks
@sipa
Copy link
Owner

sipa commented Apr 20, 2016

As I've said before on #49, I really consider using midstates here a hack, and only a marginal improvement.

Regarding new commitment structures, I think we should work on separate proposal for compact non-consensus-critical commitments, independent from the structures used for segwit (and potential follow-up extensions). As long as we need to put commitments underneath the transaction tree, those will dominate the costs for fraud proofs anyway.

@sipa sipa closed this Apr 20, 2016
@sipa
Copy link
Owner

sipa commented Apr 20, 2016

Going to leave it open for further comments.

@sipa sipa reopened this Apr 20, 2016
@sipa sipa force-pushed the segwit-master branch 2 times, most recently from ad4f9c7 to bb2a89e Compare May 11, 2016 07:36
@sipa sipa force-pushed the segwit-master branch 4 times, most recently from d9ae807 to 3cb46c1 Compare June 4, 2016 10:03
@sipa sipa force-pushed the segwit-master branch 6 times, most recently from 8e3310c to e847337 Compare June 16, 2016 18:30
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.

2 participants