🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #64171

xBin Content-SHA1-Tree format

#64171
From: Chris
Date: Tue, 25 Feb 2003 15:32
68 lines
3631 bytes
I've been writing an xBin implementation using python to see if I have my
head wrapped around everything.  Pretty much everything is straight
forward except for how to include the necessary nodes from the complete
hashtree.  I came up with two algorithms for doing this.

The first one is a bit more intuitive, but I think is harder to contruct
and also makes verifying articles more complicated.  Start out by making a
new tree of the same size as your hashtree, with the leaf nodes having
value 1 if that block is included in the article, and 0 if that block
isn't covered.  Then combine pairs of nodes to create the next level as in
the hashtree.  If either of the node's value is 1, then the parent's value
is 1 also.  This tree is supposed to represent which nodes we have
knowledge about, or can generate its value from other known values.
(I apologize for my diagrams in advance)

hashtree:

       root
     /------\
     H      |
  /----\    |
  F     G   |
 /\    /\   |
a  b  c  d  e 

a-e represent the hashes of the original data blocks
F,G,H and root are the hashes we get when we combine the children.

In this example, lets say we post an article containing blocks c,d.

temporary tree:

         1
     /------\
     1      |
  /----\    |
  0     1   |
 /\    /\   |
0  0  1  1  0 

You then traverse the tree in a depth-first search.  Any 0 you encounter
means that you should include the corresponding node from the hashtree 
in the list of nodes in the header, and you can ignore any nodes below
that node.  If you encounter a 0 on the last level, you must include that
node also.  In this example, we must include nodes F and e in the xBin
header.  I assume that the root node will always be present in the header.
 The order that the nodes appear in is the same order as they are found in
the depth first search.  In this example it would be:
Content-SHA1-Tree: root F e

The second algorithm is much like the first, except it doesn't do the
depth-first search.  As you construct the temporary tree and combine
siblings to form parents, if you combine a 0 node with a 1 node, then 0
node must be included in the headers.  I believe this yields the same list
of nodes as the first algorithm, but in a potentially different order.  I
think this algorithm is easier to implement.

In either case it's important to have a well defined order for the
Content-SHA1-Tree (if that's even what it should be called...it's not a
tree anymore...)

What do people think?

Cheers,
Chris


Technical Details
Message-ID: <pan.2003.02.25.15.32.50.152477@rogers.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!c03.atl99!sjc70.webusenet.com!news.webusenet.com!news03.bloor.is.net.cable.rogers.com!news04.bloor.is.net.cable.rogers.com.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <pan.2003.02.25.15.32.50.152477@rogers.com>
Subject: xBin Content-SHA1-Tree format
Date: Tue, 25 Feb 2003 15:32:52 GMT
From: "Chris" <nobody@rogers.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!c03.atl99!sjc70.webusenet.com!news.webusenet.com!news03.bloor.is.net.cable.rogers.com!news04.bloor.is.net.cable.rogers.com.POSTED!not-for-mail
User-Agent: Pan/0.13.3 (That cat's something I can't explain)
Newsgroups: news.software.nntp
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Lines: 67
NNTP-Posting-Host: 24.114.32.59
X-Complaints-To: abuse@rogers.com
X-Trace: news04.bloor.is.net.cable.rogers.com 1046187172 24.114.32.59 (Tue, 25 Feb 2003 10:32:52 EST)
NNTP-Posting-Date: Tue, 25 Feb 2003 10:32:52 EST