This repository was archived by the owner on Dec 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
add verifying a merkle tree #29
Open
ZhouHansen
wants to merge
1
commit into
dat-ecosystem-archive:master
Choose a base branch
from
ZhouHansen:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -215,7 +215,54 @@ __signatures__ | |||||
| ``` | ||||||
|
|
||||||
| ## Verifying A Merkle Tree | ||||||
| TODO | ||||||
| Merkle tree allows efficient verification of the contents of large data structures. | ||||||
| Let's add more data to the above Feed: | ||||||
|
|
||||||
| __data__ | ||||||
| ```txt | ||||||
| 0: A | ||||||
| 1: B | ||||||
| 2: C | ||||||
| 3: D | ||||||
| 4: E | ||||||
| 5: F | ||||||
| 6: G | ||||||
| 7: H | ||||||
| ``` | ||||||
| Now, Alice wants to recieve and verify the data `D`, to accomplish this, then she need to recieve: (marked with `~`) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| * the chunk3. | ||||||
| * chunk3's uncle and its uncle's uncle and so on. | ||||||
| * the signed root hash: #7. | ||||||
|
|
||||||
| __tree__ | ||||||
| ```txt | ||||||
| 0: #0──┐ | ||||||
| ~#1──┐ | ||||||
| 1: #2──┘ │ | ||||||
| #3──┐ | ||||||
| 2: ~#4──┐ │ │ | ||||||
| #5──┘ │ | ||||||
| ~3: #6──┘ │ | ||||||
| ~#7 | ||||||
| 4: #8──┐ │ | ||||||
| #9──┐ │ | ||||||
| 5: #10──┘ │ │ | ||||||
| ~#11──┘ | ||||||
| 6: #12──┐ │ | ||||||
| #13──┘ | ||||||
| 7: #14──┘ | ||||||
| ``` | ||||||
|
|
||||||
| We will first verify the signature on hash #7: `verify(#7, signature, publickey)`, | ||||||
| then we verify the chunk 3: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| 1. hash the chunk3: #6 = hash(chunk3) | ||||||
| 2. hash #6 and recieved #4: #5 = hash(#6 + #4) | ||||||
| 3. hash #5 and recieved #1: #3 = hash(#1 + #5) | ||||||
| 4. hash #3 and recieved #11: #7 = hash(#3 + #11) | ||||||
| 5. if our calculated #7 is equal to our received signed #7, then we know the chunk3 we received is valid. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
|
|
||||||
| ## Root Nodes | ||||||
| If the number of leaf nodes is a multiple of 2 the flat tree will only have a | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.