public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
* Re: [Bitcoin-development] Ultimate Blockchain Compression w/ trust-free lite node
@ 2012-06-19 16:46 Andrew Miller
  2012-06-19 17:33 ` Alan Reiner
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Miller @ 2012-06-19 16:46 UTC (permalink / raw)
  To: Bitcoin-development

> Peter Todd wrote:
> My solution was to simply state that vertexes that happened to cause the
> tree to be unbalanced would be discarded, and set the depth of inbalance
> such that this would be extremely unlikely to happen by accident. I'd
> rather see someone come up with something better though.

Here is a simpler solution. (most of this message repeats the content
of my reply to the forum)

Suppose we were talking about a binary search tree, rather than a
Merkle tree. It's important to balance a binary search tree, so that
the worst-case maximum length from the root to a leaf is bounded by
O(log N). AVL trees were the original algorithm to do this, Red-Black
trees are also popular, and there are many similar methods. All
involve storing some form of 'balancing metadata' at each node. In a
RedBlack tree, this is a single bit (red or black). Every operation on
these trees, including search, inserting, deleting, and rebalancing,
requires a worst-case effort of O(log N).

Any (acyclic) recursive data structure can be Merkle-ized, simply by
adding a hash of the child node alongside each link/pointer. This way,
you can verify the data for each node very naturally, as you traverse
the structure.

In fact, as long as a lite-client knows the O(1) root hash, the rest
of the storage burden can be delegated to an untrusted helper server.
Suppose a lite-client wants to insert and rebalance its tree. This
requires accessing at most O(log N) nodes. The client can request only
the data relevant to these nodes, and it knows the hash for each chunk
of data in advance of accessing it. After computing the updated root
hash, the client can even discard the data it processed.

This technique has been well discussed in the academic literature,
e.g. [1,2], although since I am not aware of any existing
implementation, I made my own, intended as an explanatory aid:
https://github.com/amiller/redblackmerkle/blob/master/redblack.py


[1] Certificate Revocation and Update
    Naor and Nissim. 1998
    http://static.usenix.org/publications/library/proceedings/sec98/full_papers/nissim/nissim.pdf

[2] A General Model for Authenticated Data Structures
    Martel, Nuckolls, Devanbu, Michael Gertz, Kwong, Stubblebine. 2004
    http://truthsayer.cs.ucdavis.edu/algorithmica.pdf

--
Andrew Miller



^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [Bitcoin-development] Ultimate Blockchain Compression w/ trust-free lite node
@ 2012-06-19 18:29 Andrew Miller
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Miller @ 2012-06-19 18:29 UTC (permalink / raw)
  To: bitcoin-development

Alan Reiner wrote:
> A PATRICIA tree/trie would be ideal, in my mind, as it also has a
> completely deterministic structure, and is an order-of-magnitude more
> space-efficient.  Insert, delete and query times are still O(1).
> However, it is not a trivial implementation.  I have occasionally looked
> for implementations, but not found any that were satisfactory.

PATRICIA Tries (aka Radix trees) have worst-case O(k), where k is the
number of bits in the key. Notice that since we would storing k-bit
hashes, the number of elements must be less than 2^k, or else by
birthday paradox we would have a hash collision! So O(log N) <= O(k).

You're right, though, that such a trie would have the property that
any two trees containing the same data (leaves) will be identical. I
can't think of any reason why this is useful, although I am hoping we
can figure out what is triggering your intuition to desire this! I am
indeed assuming that the tree will be incrementally constructed
according to the canonical (blockchain) ordering of transactions, and
that the balancing rules are agreed on as part of the protocol.

-- 
Andrew Miller



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-06-21 22:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-19 16:46 [Bitcoin-development] Ultimate Blockchain Compression w/ trust-free lite node Andrew Miller
2012-06-19 17:33 ` Alan Reiner
2012-06-19 17:59   ` Gregory Maxwell
2012-06-19 18:12     ` Alan Reiner
2012-06-19 18:18   ` Mark Friedenbach
2012-06-19 18:30     ` Alan Reiner
2012-06-21 21:42       ` Mike Koss
2012-06-21 22:02         ` Gregory Maxwell
2012-06-19 18:29 Andrew Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox