celestiaorg / smt

A Go library that implements a Sparse Merkle tree for a key-value map.
https://godoc.org/github.com/celestiaorg/smt
MIT License
138 stars 53 forks source link

Sparse/Incremental merkle tree, on-chain append #2

Closed HarryR closed 3 years ago

HarryR commented 6 years ago

Hi,

I am working on an incremental merkle tree, aiming to reduce the on-chain cost of adding items to it.

See my notes at: https://github.com/HarryR/ethsnarks/issues/16

musalbas commented 6 years ago

Do you need a key-value store or just a list of items? If the latter, have you seen the Merkle tree specified in RFC 6962 for Certificate Transparency (also known as Merkle Mountain Ranges)? You can add n nodes to the tree, and generate an O(log(n)) sized "Merkle Consistency Proof" that the new root is append-only.

HarryR commented 6 years ago

What I was doing is similar to MMR, but it allows you to append an item to an incremental merkle tree using the proof of the previous item which was added and a proof of the new item, while being able to skip duplicate path elements etc.

Image a verifier, which verifies that you have correctly added one item to an incremental merkle tree.

But the only state it stores is the proof of the last item which was added, and the current root.