Merkel
Merkel
Blockchains
Dor Cohen
Alice and Bob
• Bob stores a set of items for Alice.
• Alice keeps a single value.
• Alice can validate the Items returned to her.
Basics - Cryptographic Hash
• Arbitrary Input size.
• Output size is fixed.
• H(x) is easy to compute.
• But finding any x, x’ s.t. H(x) = H(x’), should be
computationally hard.
H( , , )
Validation Of An Item
Bob sends all of the items to Alice.
Alice computes the hash of the items.
Alice compares the result to the value she has saved.
H( , , )
H( , , )
Problems With First Solution
• Bob must send Alice the entire set for validation.
OK
?
Problems With First Solution
• Bob must send Alice the entire set for validation.
• Denote m to be the size of the set.
• We have O(m) network traffic for validating a single item.
• Can we do better?
Validating An Item
Bob sends Alice an item d and a logarithmic size proof.
Alice computes a function of the item and proof.
Alice compares the result to the value she has saved.d Proof
ce86b7dde40...
F( , )
Merkle Tree
H(H1,4,H5,8) Merkle root
H(H1,2,H3,4) H(H5,6,H7,8)
d1 d2 d3 d4 d5 d6 d7 d8
Validating An Item
Bob sends Alice an item d and a logarithmic size proof.
Alice uses the proof to compute the Merkle root.
Alice compares the result to the root she has saved. d Proof
Merkle root
F( , )
Alice Computes The Root
Given an item d and H1,H2,H3 hash values
H(H3|| . )
H3 H( . ||H2)
H( . ||H1) H2
d H1
What If d Isn’t Valid?
Given an item d and H1,H2,H3 hash values
H(H3|| . )
H3 H( . ||H2)
H( . ||H1) H2
d H1
Blockchain– Full nodes
• Full nodes are nodes in the Blockchain network that store
the entire Blockchain in order to validate new transactions.
• Since Blockchains are decentralized full nodes are very
Block
Header
Block
Header
Block
Header
Block
Header
Block
Header
Block
Header
No double
spending
here
Motivation - Storing the Blockchain
• The problem is the Blockchain can take up a lot of
memory.
Database size
Bitcoin 149 GB (December 2017)
Ethereum 400 GB (February 2018)
Transactions list
• 5b3a2…
• 3bc48…
• cd3a0…
Light Nodes
• Light nodes were created for simple clients who want to
save on storage.
• They only store the chain of block headers.
• They follow the longest chain rule, without validating
transactions.
Block Header Block Header
• Previous block header’s hash • Previous block header’s hash
• Nonce (proof of work) • Nonce (proof of work)
t1 t2 t3 t4
Forgetting Spent Transactions
• Suppose that t1,t2,t3 have all been spent.
• We can get rid of most of them.
• Now we’re storing H(t1||t2) in the block
instead of t1 and t2. H(H1,2|| H3,4)
H(t1||t2) H(t3||t4)
t3 t4
Conclusion
• Merkle trees are a smart way to hash.
• They allow for easier storage of Blockchains, allowing
headers to represent the entire block in a concise way.
• They even allows us to forget the transaction IDs of
spent transactions.
Questions?