🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #65096

Re: xBin library version 0.1

#65096
From: Curt Welch
Date: Wed, 30 Apr 2003 22:48
261 lines
15560 bytes
Sorry for the delay on this follow up....

"Chris AtLee" <catlee@canada.com> wrote:
> On Thu, 10 Apr 2003 21:46:00 +0000, Curt Welch wrote:
> > "Chris AtLee" <catlee@canada.com> wrote:
> >> On Wed, 09 Apr 2003 23:14:13 +0000, Curt Welch wrote:
> >> > "Chris AtLee" <catlee@canada.com> wrote:
> >> "In order to protect against collisions between leaf hashes and
> >> internal hashes, different hash constructs are used to hash the leaf
> >> nodes and the internal nodes.
> >
> > Very odd.  I have no idea why they think 1) doing that will protect
> > against collisions, and 2) why that is useful.
> >
> > I had scanned that web page before but didn't read it careful enough to
> > notice that.
> >
> > Does anyone see _any_ point in doing that?

Just wanted to point out that I now understant this.  The current tiger
tree hash used by bitzi and others now does this.  They add an extra byte
in front of the data for each hash block and for each node in the hash
tree.  The value of the byte is 0 for data blocks (leaf nodes) and 1 for
hash nodes (internal hash).  If you don't do something like that, then it's
trivial to create a short file which duplcates the values from the top hash
node and end up with two different files having the same tree hash value (a
collision).

> > The section is under the description of Merkle Hash Trees so maybe this
> > was an idea that Merkle added in his original paper?
> >
> >> I haven't checked the source to see if tigertree hashes actually use
> >> this or not, but this is where I got it from.
> >
> > I've looked at some TigerTree code and didn't notice it doing anything
> > like that.  But, I might have missed it just like I did when I read the
> > above document because I didn't expect it to be there.
>
> I just checked, and they don't do anything like this.

It's been changed.  It does do it now.

> >> All
> >> of this means that the xBin headers will be slightly larger since the
> >> TigerTree hash is longer and minimal hash tree complement will be
> >> larger since the merkle hash tree is larger.
> >
> > Yeah, there are issues.
>
> <snip>
>
> > For usenet, we really need to put these hash values in the header, not
> > in the body.  We need to add this hash data to the posts in a way that
> > won't break current decoders.  With yEnc, because there's a begin and
> > end marker in every article, it would be straight forward to define a
> > text format for the hash data which was placed in the body, but outside
> > the yEnc data in the article.  Current yEnc decoders would just ignore
> > it.  With uuencode however, there are no begin and end markers on each
> > article, so adding any extra text in the body is likely to break some
> > decoders.  You might be able to make it work because most decoders
> > already have logic to ignore signatures added by some servers to all
> > posts, so maybe hiding the hash data in a signature at the end of the
> > body would work.
>
> <snip>
>
> > But, putting the hash data in the headers would work for sure in terms
> > of not breaking current usenet decoders.  And, on top of that, having
> > it in the header allows clients to fetch the hash tree data with HEAD
> > commands without having forceing them to fetch the entire body.  There
> > are various applications were this would be useful.
>
> Hmm, I hadn't thought that the hash data would be useful without the
> article data...The root hash (or part of it) needs to be in the headers
> so that clients can quickly find articles with HEAD commands, but why
> would having the "minimal hash tree complement" in the headers be
> necessary? You can't tell if it's valid or not unless you download the
> entire article.

That's true for a single article, but you can tell if it's valid if you
have the data from multiple articles.  All you need is data from two
articles which contain no overlaping file data and that will give you
enough hash tree information to verify all the hash tree information you
have from both articles.  At least I'm fairly sure that's true.  I'm sure
you verify most the data but if the articles are of different enough sizes
you might end up with a few hash tree values you can't verify.

You can for sure verify hash tree data without the article data as long as
you have enough of the hash tree.

One area we have discussed where collectiong and saving the hash-tree
values might to be important or useful is when dealing with par files.  We
have talked about how par files might be done under xbin and the most
complex issue is how to veryify the par data.  Basically you can't verify
it without using the par data to recover article data, and then verifying
the article data.  This is not ideal becaues it means that news severs
won't have the ability to verify par articles individually.  Ignorhing that
however, if xBin does support par articles, then we come across the issues
of what hash data to include with each article of par data.  The par
article may allow a large span of hash blocks to be reconstructed, so one
option is to include enough hash data to allow any single hash block to be
verifyed - that amounts to including almost the entire hash tree worth of
values with each par article.  That could be done, but it's a lot of data.
The advantage is that _any_ hash block that gets reconstructed using that
par data can be verifyed.

Another more resonable option in terms of how much hash data you send, is
to treat the par data is if it were one huge segment of the file and
include the same hash values you would as if you had included that entire
file segment in the article.  For example, you could generate par articles
(500KB in size) to protect a single 100 MB section of a 500 MB file.  Each
of these par articles would allow you to replace any missing 500KB articles
in that 100MB range of the entire file.  The xBin hash data you send with
the PAR articles would be the same as if you had posted the entire 100MB
range of the file in one article.

With that hash data, you can not verify single hash blocks in the range or
even single missing articles in the same range.  But, you can verify the
entire 100 MB range once it had been completely reconstructed.

This means that once you have enough file data, and par data, to complete
the entire file, the tool can reconstruct all the missing blocks, and then
veryify if everything is correct.  But if it finds something isn't correct,
it is impossible to know which par article is corrupted (or intentially
posted for the purpose of causing trouble).  All the download tool can do
is try to find more article or par data, and if you have more par data,
start playing mix and match games with the par articles you have to see if
any combination produces a complete file.

But, if you have 11 par articles, and are missing 10 files, the download
tool has to try 11 different combinations of par data to see if any
produces valid data.  And if you have to reconstruct all 11 missing
articles before you can verify the data, it can take some time to do this.

If, however, the download tool maintains a partially verifyed hash tree for
the file, it can try to use that durring the reconstruction process to
prove the data invalid sooner, and potentially greatly speed up this mix
and match game it must play.  It can reject a combination of par articles
after re-computing only 1 hash block at times instead of having to
recompute 10 full articles worth of data.

So, the idea of these download tools collecting and storing partial hash
trees has some potential use.  It can collect and build the full hash tree
and remember which values have been verifyied, which are unknown, and which
are known, but unverified.

Putting the hash tree data into the headers allows tools to just use the
HEAD command to collect this data from every article it finds associated
with a file it is interested in.

An example of when this would actaully be used with par data is when you
had already download most of a file, and also have 10 par files, but you
are still missing 11 articles so the 10 par articles can not be used yet.
Then, the next day, when you check headers, the download tool finds that
someone has reposted 5 of the articles you are missing.  The download tool
can download 1 of those articles to have everything it needs to complete
the file, but it can do a HEAD on all of them to collect more hash tree
data to help speed the verification of the par data.

Another possible use of the hash tree data in the headers is as a pre-check
for a valid article.  If the Message-Id has the correct xBin data in it,
before the tool wastes it time download the entire article (which could be
a total fake), it can at least download the headers and verify the xBin
hash data (assuming it has partial hash data from other files alread).  If
the headers aren't there, or are bogus, then it would be wise for the
download tool to put that article on the "questionable" list and not waste
time downloading it unless the user wanted to (it might be valid data with
a valid xBin information in the message id but just not have a valid hash
header).  It is of course questionbale as to whether this step is worth
doing because it's easy to fake the headers and still put bogus data in the
article, but it's an example of one more thing that is possible if the hash
data is in the headers.

> If it does have to go in the headers, you could always split it up into
> Content-Merkle-Tree1, Content-Merkle-Tree2, etc.

Yeah, something like that is always possible.  I'm not aware of any servers
that put a size limit on the entire head, most the limits seem to be on the
size of each individual header.

How big can a header be?

It's not well defined.  We need to do more testing to get a better feel for
what the limits are in practice on todays Usenet.  Some servers have had
limits in the range of 1000 bytes but it's unclear to me if this applys
only to header that the server is trying to parse and analize, (in which
case it will not effect a specail xBin header that all the current servers
ignore), or if it applys to all headers.

>  Are headers 8-bit clean?  Otherwise multiply your above figures by 1.33
> for base64 encoding.

No, we can't assume they are.  You do have to encode them using something
like base64.

When we looked at this in the past, the answer seemed to be that for a hash
block size in the 22500 range, we could post fairly large files (in the 1GB
range if I remember correctly) without going over the 1000 byte limit.

Some servers today (like mine) have no limits on the header size or on the
size of lines in the headers.  I accidently posted an article with a header
that was about 200K the other day and it worked fine for example.  I
suspect that most transit servers for example have no problems with huge
headers (but I could be wrong).  But most likely, a very large portion of
usent would allow the transport and reading of articles with headers of
many KB using the HEAD command.  What is more likely to not work is XHDR
commends, or long headers in XOVER data.  And maybe, some servers will
reject the articles on post if the header lines are too long.  This is all
stuff we need to better understand before we lock some xBin convention into
stone.

And, if we switch to a tiger tree hash with a hash block size of only 1KB,
then the hash tree data can get a lot larger.  But, I later realized, that
this is not an issue if the posting software chooses article sizes which
align on larger power-0f-two hash block count boundries.  So if the posting
software breaks up the file into articles of 512 blocks each instead of 500
blocks, the hash tree data in the header will be much smaller.  So the
posting software has the power to keep the headers short, even for very
large files.

> > The hash block size also sets the minimum size of a multipart post.
> > People sometimes flood groups with 1000 part multipart posts which only
> > have 2 lines of uuencoded data per article.  Having a large minimum
> > size (32K vs 1K) is also seen as an advantage to make some types of
> > abuse like this easy and natural to filter at the source.  This however
> > I don't see as important at the other issues.
>
> You could restrict xBin posts to some multiple of 1K, but still use 1K as
> the hash block size.  In addition, restricting xBin posts to some power
> of 2 multiple of 1K, like 32K, would make the "minimal hash tree
> complement" much smaller since you'd be guaranteeing that the bottom 5
> rows (in this example) of the partial tree computed from the article data
> would be complete, therefore you wouldn't need to include anything below
> row 5 in the minimal tree complement.  (How's that for a run on
> sentence?)

Right, I see you are already said what I just wasted saying again above. :)

But I don't think we need to force that in the standard.  We can just point
out that if any xBin posting software creates headers longer then X (and we
can try to figure out what X is), that the article may not post or
propigate very well on Usenet.  And that to keep the header shorter, it
needs to be wise about where it decides to split the data for each article.

> So you could define an "xBin block" to be 32678 bytes, the
> size and offset values in the Message-ID header would use this block size
> to count, which would in effect restrict the posts to use that block
> size.  Still, the last post of the file may have too many hashes to
> include in the header since it wouldn't necessarily be a multiple of
> 32K...

No, that's never the case.  Even though the last article is smaller, it
will not include more hash values.  It would only need to include more hash
tree data to for the side of the tree that comes after the article, but
because the last article never has more data following it, that is never
the case.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Technical Details
Message-ID: <20030430184854.622$iF@newsreader.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!cyclone.bc.net!newsfeed.telusplanet.net!rip!news.webusenet.com!feed1.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
References: <pan.2003.04.08.05.21.36.142899@canada.com> <l_Cka.19193$iy5.537691@twister2.libero.it> <pan.2003.04.08.17.40.39.978437@canada.com> <pan.2003.04.08.18.19.33.288947@canada.com> <20030409191413.445$rS@newsreader.com> <pan.2003.04.10.18.15.24.309042@canada.com> <20030410174600.804$YN@newsreader.com> <pan.2003.04.10.22.55.59.176315@canada.com>

Show Full Headers
Complete Article Headers
Message-ID: <20030430184854.622$iF@newsreader.com>
Subject: Re: xBin library version 0.1
Date: Wed, 30 Apr 2003 22:48:54 +0000
From: curt@kcwc.com (Curt Welch)
References: <pan.2003.04.08.05.21.36.142899@canada.com> <l_Cka.19193$iy5.537691@twister2.libero.it> <pan.2003.04.08.17.40.39.978437@canada.com> <pan.2003.04.08.18.19.33.288947@canada.com> <20030409191413.445$rS@newsreader.com> <pan.2003.04.10.18.15.24.309042@canada.com> <20030410174600.804$YN@newsreader.com> <pan.2003.04.10.22.55.59.176315@canada.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!cyclone.bc.net!newsfeed.telusplanet.net!rip!news.webusenet.com!feed1.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com
Newsgroups: news.software.nntp
X-Trace: NewsReader.Com wv1g4yd,UMu_JnGY6.CLAD5wEDN8OBpjX9R6ZXZ8KT0G_X@nf
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5
  %IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
X-Url: http://CurtWelch.Com/
User-Agent: NewsReader.Com
Lines: 260