🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
404 messages
404 total messages Page 1 of 9 Started by Chris Morse Sun, 22 Dec 2002 04:25
Page 1 of 9 • 404 total messages
Power-Post 2003 - requesting input from authorities..
#62387
Author: Chris Morse
Date: Sun, 22 Dec 2002 04:25
45 lines
3057 bytes

Hello,

I wrote the original Power-Post 2000 application for windows about 3
years ago.  Right now, I am designing and implementing a whole new
version; completely rewritten.

I once again have asked for the help of a group of beta testers; many
are well known in their respective groups.  But I would also like to
get feedback from those who see things from the server end.

Please let me first say that I respect usenet as a whole, and I also
respect the opinions and experience of those in this newsgroup.  I
want to be very careful about the new implementation.  The beta
testing of the new version will be more formal than before.  I believe
it will be better for everyone if extra time and care is taken; and
not releasing anything before it is really ready.  I have heard some
horror stories of yEnc hacks of my old code.  This time around, I will
not be releasing the source code.  I think that was a mistake..

One feature I am implementing is something I have labeled "part
levelling", to eradicate small/tiny "last part" articles.  (eg,  Say a
max article size has been set for 10,000 lines.  A file being posted
that ends up being 20,004 lines total will normally be posted as 3
parts:  (1/3) 10,000 lines, (2/3) 10,000 lines (3/3) 4 lines.  With
part leveling, it will instead be posted as 3 parts of 6,668 lines
each.)

I am not sure I should attempt to implement a "cancel" feature.  
My experience with cancelling is very basic; should I even attempt to
have this feature?  (maybe it's not a good idea..)

I would very much like to hear any ideas, suggestions or comments.
Best practices, application client/server behaviour changes, etc.  My
goal is to provide a quality free posting tool for the usenet
community, but to also "play nice" with the servers.  I realize that a
lot of people use Power-Post, so I feel that extra care should be
taken.  Your input will directly affect it's implementation, as will
the input from the beta team.

Thank you!
// CHRIS

Re: Power-Post 2003 - requesting input from authorities..
#62388
Author: Chris Morse
Date: Sun, 22 Dec 2002 06:23
30 lines
2107 bytes
On Sun, 22 Dec 2002 04:25:48 GMT, Chris Morse <chris@invalid.com>
wrote:

>
>Hello,
>
<.. running with scissors ..>

Someone mentioned "xBin", but I can't find much about it.

"xBin.org - nothing here yet".  

Can someone enlighten me on this?

All I know is that it's some sort of binary posting convention.
I have my own ideas on UUE/yEnc posts, but would be interested to hear
about other proposed approaches.  As I am also implementing
Power-Grab, I sort of get to control both sides of it (posting &
downloading).  By proving useful data (in headers) for UU/yEnc encoded
file parts, I can help at least with the detection of errors.  UUE
data could greatly benifit from this.

I am considering the ability/option for Power-Post to actively search
for refill requests (by use of XPAT) and allow for the automatic
requeueing of just those parts requested.  (The request being in a
format syntax, and easily producable with Power-Grab.)

// CHRIS

Re: Power-Post 2003 - requesting input from authorities..
#62389
Author: greg andruk
Date: Sun, 22 Dec 2002 06:45
50 lines
3124 bytes
Chris Morse wrote:

> On Sun, 22 Dec 2002 04:25:48 GMT, Chris Morse <chris@invalid.com>
> wrote:

>>
>>Hello,
>>
> <.. running with scissors ..>

> Someone mentioned "xBin", but I can't find much about it.

> "xBin.org - nothing here yet".  

> Can someone enlighten me on this?

They probably are talking about this thing:

<http://www.acid.org/info/xbin/>

I'm not sure why a posting program would need to care about it at all.

On cancels: don't bother, the servers where most of the binary activity 
happens ignore them.

> All I know is that it's some sort of binary posting convention.
> I have my own ideas on UUE/yEnc posts, but would be interested to hear
> about other proposed approaches.  As I am also implementing
> Power-Grab, I sort of get to control both sides of it (posting &
> downloading).  By proving useful data (in headers) for UU/yEnc encoded
> file parts, I can help at least with the detection of errors.  UUE
> data could greatly benifit from this.

Google this group for lots of fairly recent ideas on header conventions for 
binaries.  Some were reasonable, like minor MIME extensions, others 
involved grotesque misuses of standard headers.

> I am considering the ability/option for Power-Post to actively search
> for refill requests (by use of XPAT)

...with other commands as a backup strategy.  Clients that rely on XPAT 
being there and working tend to have a feature or two that won't work.

> and allow for the automatic
> requeueing of just those parts requested.  (The request being in a
> format syntax, and easily producable with Power-Grab.)

Careful with anything that responds to requests automatically -- it might 
be a good ieda to get the user's confirmation before starting the reposts.
Re: Power-Post 2003 - requesting input from authorities..
#62392
Author: Bas Ruiter
Date: Sun, 22 Dec 2002 18:46
68 lines
3461 bytes
> > Someone mentioned "xBin", but I can't find much about it.
> > "xBin.org - nothing here yet".  
> > Can someone enlighten me on this?

Back in early october we were discussing what could be done to
prevent attacks on multi-part posts. After asking around in
sci.crypt (I think it was), I put forward the use of Hash Trees.

  Thread starting from:
  Bas Ruiter <hpk9quk1cq0ti2reeu03epd0tgf4b8a8p0@4ax.com>
  "[FNTP] verifying that part reposts belong to a file - solution"

Curt Welch had been playing around with exactly the same idea around
that time, or a little earlier. As a result he came up and suggested
"xBin". He also wrote some code as a proof-of-concept.

  Thread starting from:
  Curt Welch <20021011035242.323$xD@newsreader.com>
  "[xBin] some examples (was [FNTP])"

There's some more thoughts from Curt and others about xBin and the whole
Hash Tree concept.

  Thread starting from:
  Curt Welch <20021011161123.133$Fc_-_@newsreader.com>
  "Re: [FNTP] more on hash chunk sizes"


I'm not sure what the status is of xBin, or the whole Hash Tree thing.
As far as I know, nothing has been definitely settled yet. I guess it's
time to do so, now.

Coincidenally, with the recent attacks in certain warez groups on
multi-part posts this topic has come back to my attention.
"Quade" (author of NewsBin) has been working, updating his program, to
succesfully counter-act the changing attacks in the newsgroups.

I told him there was a solution to the attacks, but that the problem
would lie in getting it implemented in any posting software, as that is
where most of the work will be done. I knew you were working on a new
version of PP and thougt of e-mailing u. And now, here you are...


> They probably are talking about this thing:
> 
> <http://www.acid.org/info/xbin/>
> 
> I'm not sure why a posting program would need to care about it at all.

Prolly 'cause that's not it.

> > I am considering the ability/option for Power-Post to actively search
> > for refill requests (by use of XPAT)

Good idea. On the article level, I hope. (See Par 2.0)



 Bas Ruiter

-- 

[ l o r d s n o w @home.nl    http://members.home.nl/ l o r d s n o w ]

 Only when the population of 50 mysteriously dropped to 7 did the
 remainder start to suspect Hungry.
Re: Power-Post 2003 - requesting input from authorities..
#62399
Author: Chris Morse
Date: Mon, 23 Dec 2002 04:52
52 lines
3105 bytes
On Sun, 22 Dec 2002 19:46:55 +0100, Bas Ruiter <lordsnow@home.nl>
wrote:

>I'm not sure what the status is of xBin, or the whole Hash Tree thing.
>As far as I know, nothing has been definitely settled yet. I guess it's
>time to do so, now.
>
>Coincidenally, with the recent attacks in certain warez groups on
>multi-part posts this topic has come back to my attention.
>"Quade" (author of NewsBin) has been working, updating his program, to
>succesfully counter-act the changing attacks in the newsgroups.

I figured that sort of "stuff" would happen (attack), but have no idea
how bad it is, who's doing it, etc..  But on the fact that it's quite
easy to inject bogus parts in a multipart post.

They are able (or do) generate similar Message-ID values?
Doesn't that normally have a reference of the original host?
Hmm.. 

The hash system looks good, I'd be willing to implement it.

>I told him there was a solution to the attacks, but that the problem
>would lie in getting it implemented in any posting software, as that is
>where most of the work will be done. I knew you were working on a new
>version of PP and thougt of e-mailing u. And now, here you are...

True-  I don't have MD5 algorithms handy, but if I can get a c++ class
or set of functions to do the job, I may be in.

>> They probably are talking about this thing:
>> 
>> <http://www.acid.org/info/xbin/>
>> 
>> I'm not sure why a posting program would need to care about it at all.
>
>Prolly 'cause that's not it.

yah- Not it.

>> > I am considering the ability/option for Power-Post to actively search
>> > for refill requests (by use of XPAT)
>
>Good idea. On the article level, I hope. (See Par 2.0)

Definitely article leve.  But this won't be implemented right away- I
can see that it will require more planning on my part.

Cheers!
// CHRIS

Re: Power-Post 2003 - requesting input from authorities..
#62400
Author: Quade
Date: Mon, 23 Dec 2002 05:32
76 lines
4192 bytes
Chris Morse <chris@invalid.com> wrote in <5h3d0vk2tp5kvr4dt0asfu2oa52f5fo9u1@4ax.com>:

What I'd suggested to Lordsnow (Bas) was that the posting agent could chunk up the file 
(chop it into posts) and post a list of the chunks with subject and the MD5 hashes of each 
post's contents. Post it before the (01/NN) part went out. Then, worse comes to worse, you 
download each post and validate it after it's downloaded. If you don't have MD5, Ripem-D's 
available freely on the web. 

The current attacks aren't particularly difficult to filter out, though I kind of screwed 
myself with some space saving data structures I'd picked. I expect in the future it'll be 
more difficult as they get more experienced. 

Odd thing I noticed is that the bad parts appear to come out of Easynews (though this could 
be faked as well). Depending on the popularity of the file, there are typically 3-5 bad 
posts thrown into the mix per RAR file. 

It doesn't seem to be affecting the groups I frequent so, I wouldn't even have known about 
it except my users complained loudly. 

Quade


>On Sun, 22 Dec 2002 19:46:55 +0100, Bas Ruiter <lordsnow@home.nl>
>wrote:
>
>>I'm not sure what the status is of xBin, or the whole Hash Tree thing.
>>As far as I know, nothing has been definitely settled yet. I guess it's
>>time to do so, now.
>>
>>Coincidenally, with the recent attacks in certain warez groups on
>>multi-part posts this topic has come back to my attention.
>>"Quade" (author of NewsBin) has been working, updating his program, to
>>succesfully counter-act the changing attacks in the newsgroups.
>
>I figured that sort of "stuff" would happen (attack), but have no idea
>how bad it is, who's doing it, etc..  But on the fact that it's quite
>easy to inject bogus parts in a multipart post.
>
>They are able (or do) generate similar Message-ID values?
>Doesn't that normally have a reference of the original host?
>Hmm.. 
>
>The hash system looks good, I'd be willing to implement it.
>
>>I told him there was a solution to the attacks, but that the problem
>>would lie in getting it implemented in any posting software, as that is
>>where most of the work will be done. I knew you were working on a new
>>version of PP and thougt of e-mailing u. And now, here you are...
>
>True-  I don't have MD5 algorithms handy, but if I can get a c++ class
>or set of functions to do the job, I may be in.
>
>>> They probably are talking about this thing:
>>> 
>>> <http://www.acid.org/info/xbin/>
>>> 
>>> I'm not sure why a posting program would need to care about it at all.
>>
>>Prolly 'cause that's not it.
>
>yah- Not it.
>
>>> > I am considering the ability/option for Power-Post to actively search
>>> > for refill requests (by use of XPAT)
>>
>>Good idea. On the article level, I hope. (See Par 2.0)
>
>Definitely article leve.  But this won't be implemented right away- I
>can see that it will require more planning on my part.
>
>Cheers!
>// CHRIS
>
>

Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62401
Author: Curt Welch
Date: Mon, 23 Dec 2002 09:11
377 lines
21669 bytes
Chris Morse <chris@invalid.com> wrote:
> On Sun, 22 Dec 2002 04:25:48 GMT, Chris Morse <chris@invalid.com>
> wrote:
>
> >
> >Hello,
> >
> <.. running with scissors ..>
>
> Someone mentioned "xBin", but I can't find much about it.
>
> "xBin.org - nothing here yet".

Yeah, that's my site.  That is what you were looking for, but as you see,
there's nothing there yet.

As was answered later in this thread, it was something that was growing out
of discussions here a few months back - and that was an outgrowth of stuff
talked about I think over a year before then.

> Can someone enlighten me on this?

You can dig up the threads on google and speed a few hours reading, but
I'll give an outline here. (which now that I've finished writing it, I see
will take you a few hours to get through anyway :)).

The idea grew out general issues with how multipart binaries don't work as
well as they should on Usenet and how many issues over time could be
improved if we move to a system where the news servers knew they were
transporting files instead of just articles.

One example of these problems is the issue that it's very hard to run a
news server that carries a partial binary feed.  A typical way to reduce
the size of a feed to fit in the bandwidth a server can deal with is to
filter articles by size.  You simply remove all articles over a given size.
It's generally wise because if you can't carry everthying, it's better to
drop a few huge posts instead of lots of small posts.

But for multipart posts, the size of the articles, and the size of the
actualy file being posted is not related.  If people are posing 10GB DVDs,
it would be better to filter than entire single post from the feed, instead
of dropping 100's of MP3 posts.  But when you drop articles by article
size, that 10GB DVD may not be dropped if the article size used is small
enough.

So, if the news servers knew thost articles were part of a 10GB file, then
dropping only that one 10GB file would be better than droping 100's of 10MB
MP3 posts or thousands of 200KB jpgs.

Other examples is the problem of headers.  No one wants to have to download
1000 headers just to get 10 files.  If 10 files are posted to usenet, it
would be nice if the news servers knew all the articles were part of the
same file and allowed you to download a special XOVER list which in a
compact form told the newsreader that there were 10 files and even nicer
nicer if there was a NNTP FILE command (like ARTICLE) which would allow you
to download the complete file (or segments of the file) already decoded and
re-assembled for you.

One day we might get there. But first, the news servers needs a "real" way
of knowing which articles contain file segments, and which are normal text
files.

So looking at this, and looking at problems of dealing with multipart posts
in general, some ideas of what might make sense to start with now were
generated.

The idea started with the simple concept of making sure that binary posts
(partically multipart posts) were labeled in a consistent fashion,
somewhere in the headers, so both news servers, and newsreaders/download
tools, could know for sure what they were dealing with instead of having to
play the current guessing games which is now done with the subject and
author of articles.

This evolved into the idea of encoding binary file information into the
Message-ID for multipart posts.  This would include basic information such
as a hash which uniquely identified the actual file, the total size of the
file, and the offset, and size of the segment of the file which was stored
in the current article.

Putting this information, which in all rights is stuff that belongs in
"normal" article headers, is at first glance very questionable.  You really
really don't want to move header data into the Message-ID.  And I've argued
strongly against adding information into the Message-ID for years every
time some finds something they should stick in there.  But, for this
application, I think we might have found a justifiable reason for doing it.

The reason is that news servers really could, over time, take good
advantage of this information if it's in the Message-ID.  For an incomming
news feed, the message-ID is the only thing sent to the server for it to
decide if it wants the article or not.  Someone running a text only-server,
or trying to run a limited binary server, has no easy way to regulate the
size of their feed now to fit their bandwidth limits.  But with this binary
file information in the message-id, messages chould be rejected, and the
file-size limits for rejection, could be chagned easily on the receiving
server without having to contact peers.  There's just no way to do that now
- which is why many servers that can't deal with a full feed just let their
peers drop articles at random instead by choice.  So you end up with 50% of
all multipart posts with missing segments instead of having a way to drop
just 10% of complete multipart sets and get the rest perfect.

Putting the correct file information in the Message-ID also allows downlaod
tools - especially ones searching multiple servers - to only download the
message-ids from the servers (XHDR Message-ID) and still be able to
correctly identify all the parts of a multipart file post.  This would
greatly reduce the amount of headers one has to download if all you are
trying to do is locate multipart file segments across a good sized set set
servers.

But, Message-IDs are easy to forge, just like Subjects are easy to forge
now which makes the automatic download tools easy to fool by simply posting
a set of "bogus" articles.  And with todays tools, even if you download all
the parts - the bogus ones and the real ones, trying to identify which ones
you need to correctly re-construct the file can be close to impossible if
the person generating the fakes knows what they are doing.

So we looked into ways to solve this, and came up with hash trees.

Hash trees are a special type of file hash which is built using any
standard hash function like MD5 or SHA-1.  They are bit complex.  But they
work by dividing a file into blocks, and calculate a hash for each block.
Then, for each two adjacent blocks, you take the two hash values, treat
them as one set of data, and calculate a hash of that data.  You continue
doing this calculating hashes of combined hashes in a big binary tree,
until you get to the top and have only one hash value left.  That becomes
the "hash" of your file.

We would define a specific hash tree algorthm, and make it the standard for
all multipart posts to Usenet.  We would need to pick, and standardize,
both the basic hash function used (SHA-1 MD5 etc), and we would need to
pick, and standardize a block size.  It's important that this be decided on
before it it gets into common usage because you don't want to try to change
it later.

This hash would then become a universe ID for the file being posted.  If
that file was every posted again, 5 years in the figure, you want it to
have the same hash value.  If someone is re-posting missing segments of the
file, you want it to have the same universal ID.

This hash is included (at least in part) in the Message-ID so the download
tool will have the power to identify reposts of segments, or reposts of the
entire file, simply by looking at the Message-ID.

The reason for using this special hash-tree system, is that it can be used
to identify fakes (or corrupted articles) without help from any external
information.

The problem with a noral file hash, is that there is no way of knowing if a
single post from a multipart post is a fake, or whether it actaully matces
the file hash in the Message-ID.  The only way to answer that is to
download all the segments, put them together, and calcuate the full file
hash to see if it matches.  If you have a 20 part file posted, and someone
posts 3 corrupted segments which are forged to look valid, how can an
automatic download too easilly figure out which of the 3 parts that are
duplicated are the fakes and which are the real ones?  It has to simply try
all possible combinations until it finds one that works.  The large the
post gets, the more unrealistic that becomes.

But, with the tree hash, you included with the post, in the headers, enough
hash values from the hash tree to allow the file hash to be re-calcuated
using the data in the article, and the hash values in the header.  So,
given a single article from a multipart posts, you can scan the data and
re-calculate the file hash.  And if it doesn't match the file hash in the
message-ID, you know that the post is corrupted (either by accident, or my
design) and should be thrown out.  And you know this without having to know
anything else about the file.  This means download tools can verify every
article as they are downloaded, and not have to wait to get the complete
set before the parts can be verified.  And, down the road, it means that we
can modify the news servers to reject "broken" posts at post time, or at
transit time, to filter out corrupted, or forged posts.

Mostly, what this starts as, is a way to correctly label binary posts.  It
requires that the correct message-id be used, and some other information be
added to the headers.  The rest of the encoding (yEnc vs uuencode, and
subject conventions) do not need to change.

But there are side-effects.  First off, you have to calcuate the file hash
before you can post the first part.  And that requires a full scan of the
file to be posted.  For most resoonably sized files, this is fairly fast,
but for really big files, this starts to take a noticable amount of time,
so some people users may not like this.  But, the advantages gained I think
will over time, force people to spend that time before posting.  The
posters will be doing the downloaders a big dis-service by not being
willing to wait for the time required to pre-scan the file.

But the larger side-effect is that because of the way the tree-hash works,
the file segments you post must be sized so they start and stop on the
tree-hash block boundries.  This means it's imposible to correctly label
"typical" posts after the fact because the amount of data placed into each
post is likely to be based on things like uuencod line lengths and not on
whatever would be picked as the Usenet standard for tree-hash block size.

But, if you are willing to force users to wait for a full file-scan before
the post can start, and adjust article sizes based on a tree-hash block
sizes, then, the only thing required to post articles in the correct format
is to add the message-id and put a tree-hash data into the headers.

To take advantage of articles marked like this however requies a bit more
work.  The first thing that could be done is to use it as a way to identify
corrupted posts - even if they are posted in uuencode format.

The bigger advantage comes when you write a download tool from the ground
up to look for, and download, articles in this format.  The advantage is
that all you need the identify the file you want to download is it's file
hash value - which serves as a universal ID for the file.  If you have only
one part of a multipart posts, and you decided you would like to download
the entire thing, all you have to do is give the download tool the
Message-ID of the that one part - not the group, or the name of the file,
or anything else.  Just the Message-ID.  The download tool can then search
multiple servers and find all the parts without ever downloading headers
other than Message-IDs.  And if parts are re-posted, or even if the entire
file is reposted by someone else using different part sizes, the download
tool can still identify the file as being the same, and figure out which
parts have to be downloaded to fill in the gaps you are still missing - all
automatically.  And if any parts are corrupted or forged, the only damage
done is that you are forced to download the article.  But once it's
downloaded, the download tool knows for sure if it's valid data or fake so
it can never be tricked into constructing a corrupted file.  When the file
is complete, the tool knows for a fact that file data matches the file-hash
you asked for.

On the issue of making it a standard, we seemed to have as many different
opinions on the "correct" way of doing things are there were people posting
to the thread when we last talked about it.  So to give us more facts to
work with instead of just theories, I went off and started to write a
proof-of-concept tools for this idea.  I grabed the xbin.org domain because
xbin seemed like a neat name for a binary posting standard (X as in
experimential) and there aren't alot of short domain names like that left.
But that was before I realized that "xbin" is an old tool for encoding mac
files in the binhex format so when you search for "xbin" on the net, you
get lots of references to that tool.  So xbin might not be the best name
for the standard.  Or maybe it will work.

What I have done is created a unix command-line tool which can post files
in both uuencode or yEnc and which generates an valid xBin Message-Id and
headers.  I'll be happy to share the code with anyone who is interested in
it.

To demonstarte the format it's using, I just posted a small 3 part mp3 file
to Usenet.  Here are the important headers added to the first of the three
parts:

X-Bin-Signature: x/I8REUBPHGJ+qcCiUb3TXz4Z80
  pRnksBkZcSiccM1/hkrWdEBd7u0 x+m6b4q/02G04s29ZNPQcRMToMg
  j/3IFK3di5igu5Z7KpjDoIkN33I 0MFRwrdF1rCYmcW5qCcs0+fM0B8
  yiZ65jmF1sZjCiHjUoKzBd75Wgw
Message-ID: <$XB$Hx/I8REUBPH$SEoJr$oAA$sBa$$3mK@xbin.org>

The X-Bin-Signature: is the tree-hash data needed to verify the data in the
article.  The hash is encoded in base64.  The first value is the full
tree-hash for the file. (the one that starts with x/I8...)

In the Message-ID is the xbin encoded information for the file.  It's found
between the $XB$ marker which starts the data, and the $$ which follows it.
The rest of the Message-Id can be any normal Message-ID format.  The
xbin.org host is not part of the standard.

There are single letter identifiers starting each value encoded in the xBin
data and each data field is terminated with a $.

The first is H - for the tree hash value of the file being posted.  But to
keep the message ID a resonable length, only the first 10 characters (60
bits) of the hash are included in the Message-ID. I used SHA-1 as the hash
function which produces a 160 bit hash.  The full 160 bit hash is the first
item in the X-Bin-Signature:.

The next value is the Message-ID is S - the full file size, encoded in
base64.

Then o - the block offset of the segment included in the article, and
then s - the number of hash blocks included in the current file.

Blocks are used instead of bytes for the offset and the segment because the
file must fall on these boundries anyway, and this allows the message-id to
be be smaller than if byte offset and segment sizes were used.

The last block in the file however will be shorter, and this fact is not
shown in the segment size since it shows only the number of blocks.  So to
figure out the true byte size of the current article, the file size must be
used to determine if this is the last block in the file, and if so, how
many bytes are in it.

So there you have it - an overview of what xBin is all about.

What's left to do is write a article verifiying tool - first to show it can
be done and second - to veryify that what my posting tool is produceing is
even valid.

Then we have to decide if this idea is worth trying to make a Usenet
standard.  And if so, what changes need to be made to what I've already
suggested.

Getting it included in a popular posting tool will bascailly get it on it's
way to being a defacto standard fairly quickly.  And because it shouldn't
break anything in terms of all the current download tools, there shouldn't
be a lot much resistance to it.

The only big issue is trying to iron out the details so we have a standard
that people will be able to live with before it "leaks out" into wide
spread use.

> All I know is that it's some sort of binary posting convention.
> I have my own ideas on UUE/yEnc posts, but would be interested to hear
> about other proposed approaches.

The Xbin standard would start simply as a way to label posts  so it's not
changing or attempting to fix anything about uuencode or yEnc - but it does
add a very strong file data hash on top of both of those and it does put
important information about the file being posted into the headers where
both news servers and news readers will have access to it without having to
download the file or scan and parse the body.

> As I am also implementing
> Power-Grab, I sort of get to control both sides of it (posting &
> downloading).  By proving useful data (in headers) for UU/yEnc encoded
> file parts, I can help at least with the detection of errors.  UUE
> data could greatly benifit from this.

Yes.  That's the point of xBin.

> I am considering the ability/option for Power-Post to actively search
> for refill requests (by use of XPAT) and allow for the automatic
> requeueing of just those parts requested.  (The request being in a
> format syntax, and easily producable with Power-Grab.)

Tieing that in to a standard like xBin gives it even more power.  The
repost requests would include, in an easy to parse form by power-post, the
xBin file hash, which uniquely identifies the correct file with no
confusion over file-names, and the block-ranges which need to be re-posted.

Par file technology could be supported by this as well, but it would have
to be built into the xBin standard to work correctly.  That gets complex.

The other dream of xBin is to "fix" posting so that people would no longer
need to break huge files into lots of small rar files (or master spliter or
whatever).  It would allow you to post a huage file as 1000 parts if that
is what it takes.

The idea is that since the download tool can identify parts on it's own,
accuratly, there's never any question over whether you are downloadting the
correct articles.  This means that all the parts of the post don't have to
be on the server to start the download.  The download tool simply maintains
a list of all the files it's trying to download, and as it scans
message-ids, it looks for file segments to help fill in the missing blocks
from the files in-progress. If something is reposted later, it just works
automatically without the guy doing the download having to identify and
mark posts as possible "fills" for his missing files.

If you add the feature to post an automated re-post request, then the user
can look at the stuff he's trying to downlaod, and if thinks no more parts
are comming, he can hit a button to request a repost of everything he is
still missing.

And likewise, repost requests can automatically be spoted, and if the
download has any segments in the download folder for what is being
requested, it can show a list of files that can be re-posted to help fill
the requests.  If the guy wnats to help out, he just clicks it to have it
added to the stuff to be reposted.

And, with xBin, the reposts don't need to be the same article size as the
original.  A single part from the original post might has been posted as a
600KB article.  But the repost of that single part could be sent out as 3
200K articles (increasing the chance that all the parts make it to the guy
this time).  This won't confuse the download tool because it tracks missing
data by tree-hash blocks or bytes, not by articles, and the Message-Id
tells it everything it needs to know about the article to make the data fit
correctly in what is still missing.

All this stuff is a bit complex.  It might prove to be too complex for
Usenet.  But I think it could make multipart posts work a lot better than
the current work and the conversion to the system I think can be fairly
painlessly because of the ability to maintain backward compatibility with
current conventions.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: Power-Post 2003 - requesting input from authorities..
#62402
Author: Curt Welch
Date: Mon, 23 Dec 2002 09:28
79 lines
4342 bytes
greg andruk <gja@meowing.net> wrote:
> Chris Morse wrote:
>
> > On Sun, 22 Dec 2002 04:25:48 GMT, Chris Morse <chris@invalid.com>
> > wrote:
>
> >>
> >>Hello,
> >>
> > <.. running with scissors ..>
>
> > Someone mentioned "xBin", but I can't find much about it.
>
> > "xBin.org - nothing here yet".
>
> > Can someone enlighten me on this?
>
> They probably are talking about this thing:
>
> <http://www.acid.org/info/xbin/>

Nope he had the right site the first time.

> On cancels: don't bother, the servers where most of the binary activity
> happens ignore them.

I agree.  There's little point for cancles when it comes to binary posting
tools.

> Google this group for lots of fairly recent ideas on header conventions
> for binaries.  Some were reasonable, like minor MIME extensions, others
> involved grotesque misuses of standard headers.

xBin is a mostly a very non-conventional header standard - one intended for
the needs of Usenet, though I guess it should transport as e-mail fine.

> > I am considering the ability/option for Power-Post to actively search
> > for refill requests (by use of XPAT)
>
> ...with other commands as a backup strategy.  Clients that rely on XPAT
> being there and working tend to have a feature or two that won't work.

BTW, under the xBin system, refill requests should be labled as an xbin
binary as well with the same file hash and file size for the file that
reqests are being requested for.  The segment size should be 0 to indicate
that even though the article is associated with the specified file, it
includes no data for the file.  It might be wise to add a marker in the
xBin data to show that it is a refill reqest.

Part 0 posts should also be labeled like that to show their association
with the file, as well as simple text follow-up messages - but that won't
happen for some time because normal newsreaders would have to be modified
to make that work correctly.

But, with refill requetsts marked correctly in the Message-ID, the download
tool which was already downloading Message-IDs and scaning for the ones
associated with the files it had partially downloaded, could spot them
easilly and not have to worry abot XPAT support - just XHDR which as far as
I know is well supported for Message-IDs.

> > and allow for the automatic
> > requeueing of just those parts requested.  (The request being in a
> > format syntax, and easily producable with Power-Grab.)
>
> Careful with anything that responds to requests automatically -- it might
> be a good ieda to get the user's confirmation before starting the
> reposts.

Yes, neither the repost request or the reposing of the data should be done
automatcially.  That could end up with floods of both in the newsgroups.
And when answering a repost request, the tool should be smart enough to
spot articles which have shown up after the request which fulfill parts of
the equest, and not let the user repost those parts again (or at least not
without a tripple warning or something like that).

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: Power-Post 2003 - requesting input from authorities..
#62403
Author: Curt Welch
Date: Mon, 23 Dec 2002 09:47
33 lines
2938 bytes
peon@somecompany.com.invalid (Quade) wrote:
> Chris Morse <chris@invalid.com> wrote in
> <5h3d0vk2tp5kvr4dt0asfu2oa52f5fo9u1@4ax.com>:
>
> What I'd suggested to Lordsnow (Bas) was that the posting agent could
> chunk up the file (chop it into posts) and post a list of the chunks with
> subject and the MD5 hashes of each post's contents. Post it before the
> (01/NN) part went out. Then, worse comes to worse, you download each post
> and validate it after it's downloaded. If you don't have MD5, Ripem-D's
> available freely on the web.

Someone wanting to cause trouble could just post fake hash index articles.
Then what would you do?  You would be forced to identify the fake index
posts by hand and tell the download tool which index to use - assuming you
could identify them.

The xBin tree-hash, though more complex, is no more difficult and
eliminates the need for the separate index file.  Individual articles can
be rejected as fakes without having to locate the index file first.  And
all the downloading and elimination of fakes and corrupted articles can be
done automatically without any "manual" intervention.  The only thing
someone trying to cause problems can do is force you to waste time and
bandwidth downloading their articles.

And over time, if an xBin-like standard caught on, the servers could
rejected the corrupted or forged binary articles before they had a chance
to bother you.  This wouldn't be resonable if hash values were sent out in
a separate article.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: Power-Post 2003 - requesting input from authorities..
#62407
Author: Thomas
Date: Mon, 23 Dec 2002 14:52
22 lines
2306 bytes
Rene wrote:

> Mind you, there's not a programm reconstructing a text from a MD5 hash or
> something like that to easily do it. However the crypto-analysts say they
> found hints that MD5 is weaker than thought and that it might be possible
> to break it in the foreseeable future.

Hashes can be insecure in many subtle ways. What is never possible is 
reconstructing the input from the hash: not enough bits available.

But being able to construct a message that matches a certain hash is already a 
heavy breach. Being able to create two messages with the same hash is probably 
an easier task (for example if you find out how to construct artciles with the 
hash 0), and is already enough to make a hash worthless from a security point of 
view: you could switch one contract for another.

But this is not relevant to file transport integrity checking.


Thomas

Re: Power-Post 2003 - requesting input from authorities..
#62408
Author: Curt Welch
Date: Mon, 23 Dec 2002 17:40
28 lines
2885 bytes
g <gypsy@dont.you.dare.spam> wrote:
> What I saw wasn't "faked" - it *was* from EN.  Paths on the good and bad
> segments were only local, the corrupting segments posted ~5 hours after
> the original using a different posting program.

What I saw once were fakes posted with the correct subject, (maybe 3 fake
files out of 50), but the fakes were uuencode instead of yEnc like the
orginal, and the fakes were less than 50% of the size of the orginals.  All
the fakes were posted many hours later than the orginal.  Yet, it seemed,
this was good enough to fool some of the download tools.  The download
tools it seemed just picked articles at random (maybe the first in their
list after sorting - but because the subjects were the same the order after
sorting was undefined?), then it just decoded each article and combined the
data together and didn't care that some segments were uudecode and others
where yEnc.  It didn't care how large each segment was, so the resulting
full file came out short and there were no warnings produced anywhere in
the processes so the users seeing the problem had no idea why it didn't
work becuase the download tool found all the pieces and correctly decoded
them without err.

A system like xBin would fix all that.  If would not only be able to know
about the errors but if it downloaded the fake, it could keep trying the
alternate posts until it found the data it needed.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: Power-Post 2003 - requesting input from authorities..
#62409
Author: Curt Welch
Date: Mon, 23 Dec 2002 17:53
35 lines
2965 bytes
Thomas <zak@spam.invalid> wrote:
> Rene wrote:
>
> > Mind you, there's not a programm reconstructing a text from a MD5 hash
> > or something like that to easily do it. However the crypto-analysts say
> > they found hints that MD5 is weaker than thought and that it might be
> > possible to break it in the foreseeable future.
>
> Hashes can be insecure in many subtle ways. What is never possible is
> reconstructing the input from the hash: not enough bits available.
>
> But being able to construct a message that matches a certain hash is
> already a heavy breach. Being able to create two messages with the same
> hash is probably an easier task (for example if you find out how to
> construct artciles with the hash 0), and is already enough to make a hash
> worthless from a security point of view: you could switch one contract
>   for another.
>
> But this is not relevant to file transport integrity checking.

It's not relevant for checking integrity for accidential corruption in
transport, but it is a bit relevant for catching intentional corruption
intended to cause problems, and that is one of the things we are looking
at.

However, this is still a long way from needing to be "secure".  If it takes
a large parallel network of machines crunching for weeks to find a hash
collision that can be used to corrupt a single Usenet post, the that's
still good enough for this application.  But at the same time, I see no
reason not to use a stronger hash like SHA-1 since they are available.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62410
Author: Kjetil Torgrim Homme
Date: Mon, 23 Dec 2002 17:55
75 lines
4650 bytes
[Curt Welch]:
>
>   Putting the correct file information in the Message-ID also allows
>   downlaod tools - especially ones searching multiple servers - to
>   only download the message-ids from the servers (XHDR Message-ID)
>   and still be able to correctly identify all the parts of a
>   multipart file post.

just a clarification: all the _candidate_ parts of a multipart file
post.  it needs to download the header (X-Bin-Signature) of the
candidates to identify the bogus parts.

>   Hash trees are a special type of file hash which is built using
>   any standard hash function like MD5 or SHA-1.  They are bit
>   complex.  But they work by dividing a file into blocks, and
>   calculate a hash for each block.  Then, for each two adjacent
>   blocks, you take the two hash values, treat them as one set of
>   data, and calculate a hash of that data.  You continue doing this
>   calculating hashes of combined hashes in a big binary tree, until
>   you get to the top and have only one hash value left.  That
>   becomes the "hash" of your file.

let me see if I understand you correctly.  let's say it's a 13 part
posting.
                              
                              l
                +----------------------------+
                j                            k
        +--------------+                +---------+
        |              |                |         |
        g              h                i         |
    +------+        +------+        +------+      |
    |      |        |      |        |      |      |
    a      b        c      d        e      f      |
  +--+    +--+    +--+    +--+    +--+    +--+    |
  |  |    |  |    |  |    |  |    |  |    |  |    |
  1  2    3  4    5  6    7  8    9 10   11  12  13

"1" is the hash of part 1, "a" is the result of hashing the
concatenation of "01" and "02", "g" is the result of hashing the
concatenation of "a" and "b", and so on.

part 1 should include its own hash, as well as a, g, j, and l.
part 4 should include its own hash, as well as b, g, j, and l.
part 13 should include its own hash, as well as k and l.

the assembly program can notice discrepancies both by comparing hashes
(the "g" of 1 should be equal the "g" of "4"), and by verifying that
the hashes are correct (the hash of "a" from 1 and "b" from 4 should
equal the "g" found in either).

(this ignores the possibility that the size of a part is not a power
of two multiple of the chosen block size.  in that case, each part
must contain the hashes of its internal tree.)

>   But the larger side-effect is that because of the way the
>   tree-hash works, the file segments you post must be sized so they
>   start and stop on the tree-hash block boundries.

you mentioned the problems finding a block size which fits the
uuencode line length.  I think you should ignore that problem.  if the
software is written correctly, it will handle the "short" line without
problems.  also, neither MIME nor yEnc has this problem, so I think
it's unnecessary to make the block size something obscure just for bug
compatibility with uudecode.

>   This means it's imposible to correctly label "typical" posts after
>   the fact

yes, it must be integrated in the posting tool.

-- 
Kjetil T.			|  read and make up your own mind
				|  http://www.cactus48.com/truth.html
Re: Power-Post 2003 - requesting input from authorities..
#62411
Author: Dufus Systems
Date: Mon, 23 Dec 2002 17:59
31 lines
2590 bytes
I think the "over time" part's important here. Today certain news groups are 
under attack. We can do nothing, we can implement a stopgap solution to tide 
us over or we can wait for some future product that's may or may not be 
supported depending on the way the wind blows. I was simply suggesting 
something that could be done today so that a posting agent could identify 
good posts.

I can identify bad parts now so, It's not yet a pressing problem for me. In 
the future, as the attacks become more sophisticated, this might not be the 
case. 

What I see happening is someone will come up with a method of identifying 
bad parts that doesn't require huge changes to how files are posted (like 
embedding it in the first part (01/NN), they'll implement it in their 
software and it'll become the defacto standard just as yEnc has become. The 
rest of us will then implement it to keep our users from bitching. Then 
angry slashdotters will complain about it for 6 months to a year.  

Expecting the Servers to change at all to support this IDing process is 
unreasonable. 

Quade 

>
>And over time, if an xBin-like standard caught on, the servers could
>rejected the corrupted or forged binary articles before they had a
>chance to bother you.  This wouldn't be resonable if hash values were
>sent out in a separate article.
>

Re: Power-Post 2003 - requesting input from authorities..
#62412
Author: Thomas
Date: Mon, 23 Dec 2002 18:01
34 lines
3026 bytes
Curt Welch wrote:

> It's not relevant for checking integrity for accidential corruption in
> transport, but it is a bit relevant for catching intentional corruption
> intended to cause problems, and that is one of the things we are looking
> at.

Notice the tiny difference between: I can make 2 files that give the same hash, 
versus: I can make a file that collides with the hash of another file (basically 
make a file with any hash I want).

The two are different. The first is not relevant in this case, where the 
adversary is external. If I were to choose the original file I posted, that 
could make it easier for me to post a corrupt part later. But why would I?

The second is. Alice posts, Bob would be ably to post misleading followons.

> However, this is still a long way from needing to be "secure".  If it takes
> a large parallel network of machines crunching for weeks to find a hash
> collision that can be used to corrupt a single Usenet post, the that's
> still good enough for this application.  But at the same time, I see no
> reason not to use a stronger hash like SHA-1 since they are available.

True. If something better is available, by all means use it. If only to make 
people forget about the worse options. Better spend time optimizing SHA-1 than 
something currently broken.

BTW the xBin stuff looks good. There is a clear win for users, and a win for 
ISPs. And it is backward compatible. This will make it take off with both I'd think.


Thomas

Re: Power-Post 2003 - requesting input from authorities..
#62413
Author: Dufus Systems
Date: Mon, 23 Dec 2002 18:03
32 lines
2895 bytes
Currently I'm watching fakes that are exactly the same size as the original 
posts, even the same line count (though this is easy to fake). So, size 
filtering's out as a solution. I'm also seeing pre-emptive posts where the 
attackers notice a part 1,2,3 and post a fake part 30 BEFORE the real part 
30's sent out. I expect the encoding format will soon be matched up as well. 

Quade



>What I saw once were fakes posted with the correct subject, (maybe 3
>fake files out of 50), but the fakes were uuencode instead of yEnc like
>the orginal, and the fakes were less than 50% of the size of the
>orginals.  All the fakes were posted many hours later than the orginal. 
>Yet, it seemed, this was good enough to fool some of the download tools.
> The download tools it seemed just picked articles at random (maybe the
>first in their list after sorting - but because the subjects were the
>same the order after sorting was undefined?), then it just decoded each
>article and combined the data together and didn't care that some
>segments were uudecode and others where yEnc.  It didn't care how large
>each segment was, so the resulting full file came out short and there
>were no warnings produced anywhere in the processes so the users seeing
>the problem had no idea why it didn't work becuase the download tool
>found all the pieces and correctly decoded them without err.
>
>A system like xBin would fix all that.  If would not only be able to
>know about the errors but if it downloaded the fake, it could keep
>trying the alternate posts until it found the data it needed.
>

Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62414
Author: Kjetil Torgrim Homme
Date: Mon, 23 Dec 2002 18:27
39 lines
2728 bytes
[Kjetil Torgrim Homme]:
>
>   (this ignores the possibility that the size of a part is not a
>   power of two multiple of the chosen block size.  in that case,
>   each part must contain the hashes of its internal tree.)

let me expound a little on that.  if we let the block size be 64 KiB
and someone posts 192 KiB parts, it will look like this internally:


            +---------------+
            |               |
       +---------+          |
       |         |          |
    +----+    + - - +    +----+
    |    |    :     :    |    |
    a    b    c     d    e    f

   == part 1 ==    == part 2 ==

so, part 1 needs to contain the hash of "ab" (using Rene's
nomenclature :) and the hash of "c".  including the hash of "a" and
"b" individually is wasteful.  this means the the hash must be marked
with its position in the tree somehow in the signature.  or maybe not.
the software can deduce this from the size of the file, the offset and
the size of the segment.  just start at the top and do depth first:

part 1: "abcdef", "abcd", "ab", "c"
part 2: "abcdef", "abcd", "cd", "d", "ef"

perhaps we can use a smaller block size since this mechanism reduces
the overhead, but that makes it more likely that the segment size will
be chosen to be an oddball multiple of the block size, which makes the
hash trees more complex.

-- 
Kjetil T.			|  read and make up your own mind
				|  http://www.cactus48.com/truth.html
Re: Power-Post 2003 - requesting input from authorities..
#62415
Author: Klaas
Date: Mon, 23 Dec 2002 19:37
44 lines
3146 bytes
After careful consideration, Dufus Systems muttered:

> I think the "over time" part's important here. Today certain news
> groups are under attack. We can do nothing, we can implement a stopgap
> solution to tide us over or we can wait for some future product that's
> may or may not be supported depending on the way the wind blows. I was
> simply suggesting something that could be done today so that a posting
> agent could identify good posts.
> 
> I can identify bad parts now so, It's not yet a pressing problem for
> me. In the future, as the attacks become more sophisticated, this
> might not be the case. 
> 
> What I see happening is someone will come up with a method of
> identifying bad parts that doesn't require huge changes to how files
> are posted (like embedding it in the first part (01/NN), they'll
> implement it in their software and it'll become the defacto standard
> just as yEnc has become. The rest of us will then implement it to keep
> our users from bitching. Then angry slashdotters will complain about
> it for 6 months to a year.  
> 
> Expecting the Servers to change at all to support this IDing process
> is unreasonable. 

I think you miss his point.  Hash trees can be implemented immediately, 
just like your hash indices, but allow for the possibility of server 
action in the future (it doesn't depend on it!).

And as Curt mentioned, the forgery of the index file is a weakness to 
your scheme.

-Mike

> Quade 
> 
>>
>>And over time, if an xBin-like standard caught on, the servers could
>>rejected the corrupted or forged binary articles before they had a
>>chance to bother you.  This wouldn't be resonable if hash values were
>>sent out in a separate article.
>>
> 

Re: Power-Post 2003 - requesting input from authorities..
#62416
Author: Dufus Systems
Date: Mon, 23 Dec 2002 20:30
25 lines
2420 bytes
I think it's safe to say, you can't have an attack till you have at least 
part one of the multipart on the server. You can't attack nothing. That 
suggests to me that if I was to include the hash values at the beginning of 
part #1 (not in a different post any more) before the encoded data, say 40-
60 lines of text, I'd could reasonably assume that this part one is the one 
I want and contains the actual hash values I'm looking for. Any other forged   
part #1's, I received later would have a higher record number and could be 
discarded. 

You do run into problems when the original Part#1 falls off the server but, 
nothing's perfect. 

I'll take a look at Curt's idea. 

Klaas <spamhole@klaas.ca> wrote in <Xns92EE2530C3759nothing@209.98.50.131>:
>I think you miss his point.  Hash trees can be implemented immediately, 
>just like your hash indices, but allow for the possibility of server 
>action in the future (it doesn't depend on it!).
>
>And as Curt mentioned, the forgery of the index file is a weakness to 
>your scheme.
>
>-Mike
>
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62417
Author: Kjetil Torgrim Homme
Date: Mon, 23 Dec 2002 22:22
25 lines
2219 bytes
[Rene]:
>
>   X-No-Archive: yes

please turn it off, it really puts a hamper on my style when I can't
quote.

anyway, consider that a file on Usenet often is a gigabyte in size,
and that each part seldom is larger than 500 kB.  that means 2000
parts.  the hash of each part is 160 bytes.  if all hashes are
included in all articles, you add 320 kB to each part, which clearly
is unworkable.  the tree approach, on the other hand, only needs 10-20
hashes in each file.  now, you may be advocating sending the hashes
out-of-band.  I'm a bit concerned about adding a single point of
failure to the system.  what happens if that hash list is missing from
your server?

the every other article attack was well spotted.  I think it suffices
that part 3 includes the hash of part 4 and vice versa to solve it,
though.

-- 
Kjetil T.			|  read and make up your own mind
				|  http://www.cactus48.com/truth.html
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62418
Author: Curt Welch
Date: Mon, 23 Dec 2002 23:05
157 lines
9485 bytes
Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
> [Curt Welch]:
> >
> >   Putting the correct file information in the Message-ID also allows
> >   downlaod tools - especially ones searching multiple servers - to
> >   only download the message-ids from the servers (XHDR Message-ID)
> >   and still be able to correctly identify all the parts of a
> >   multipart file post.
>
> just a clarification: all the _candidate_ parts of a multipart file
> post.  it needs to download the header (X-Bin-Signature) of the
> candidates to identify the bogus parts.

Well, the signature doesn't tell you it's bogus.  YOu have to download the
entire article to check if it's really bogus.  If the x-bin-signagure was
missing from the header, that would tell you it's bogus, but anyone trying
to create fakes would most likely get that right.

And flase postives on a Message-ID would cause an article to look like a
valid candidate but the odds of a 60 bit hash and a filesize matching is
small enought that that is unlikley to be an issue as well.  I would expect
most download tools to download the entire article after seeing the correct
Message-Id and not bother with the extra stop of a header download to check
for consistency.  But it could of course be done.  It would be up to the
download tool author to decide if they felt the extra step and the code to
implement it was worth doing.

> >   Hash trees are a special type of file hash which is built using
> >   any standard hash function like MD5 or SHA-1.  They are bit
> >   complex.  But they work by dividing a file into blocks, and
> >   calculate a hash for each block.  Then, for each two adjacent
> >   blocks, you take the two hash values, treat them as one set of
> >   data, and calculate a hash of that data.  You continue doing this
> >   calculating hashes of combined hashes in a big binary tree, until
> >   you get to the top and have only one hash value left.  That
> >   becomes the "hash" of your file.
>
> let me see if I understand you correctly.  let's say it's a 13 part
> posting.
>
>                               l
>                 +----------------------------+
>                 j                            k
>         +--------------+                +---------+
>         |              |                |         |
>         g              h                i         |
>     +------+        +------+        +------+      |
>     |      |        |      |        |      |      |
>     a      b        c      d        e      f      |
>   +--+    +--+    +--+    +--+    +--+    +--+    |
>   |  |    |  |    |  |    |  |    |  |    |  |    |
>   1  2    3  4    5  6    7  8    9 10   11  12  13
>
> "1" is the hash of part 1, "a" is the result of hashing the
> concatenation of "01" and "02", "g" is the result of hashing the
> concatenation of "a" and "b", and so on.
>
> part 1 should include its own hash, as well as a, g, j, and l.

Right idea, wrong answer.

To verify the data in the part, you must re-calculate the hash from the
data. to see if it matches.  So the hashes you listed are the ones which
you must calculate, not the ones which will be included in the header.  So
what you include with part 1 is hash 2, b, h, and k.  What the code
calcuates are the hash values a, g, j, l when it wants to verify the data
is part of a file with a tree-hash value of l.

> part 4 should include its own hash, as well as b, g, j, and l.

A posted part can included multiple blocks.  So lets say a single article
included blocks 4 and 5.  To recalcute the tree-hash for the file, you
would need to include the hash values a, 3, on one side, and 6, d, and k
from the other.  The order of the hash values in the Signature: header
follow that same order so you don't need to identify which hashes is which
in the header.  Each hash covers a unique range of blocks from the file,
and the order of the hash values in the header match the order of the
blocks in the file.  Which hash values need to be included is known by the
program because The signature header starts with the full file hash (which
is only requried there since I'm suggesting not including the full 160 bits
in the Message-ID), and then is followed by the hash values required from
the file in the correct order.

> part 13 should include its own hash, as well as k and l.
>
> the assembly program can notice discrepancies both by comparing hashes
> (the "g" of 1 should be equal the "g" of "4"), and by verifying that
> the hashes are correct (the hash of "a" from 1 and "b" from 4 should
> equal the "g" found in either).

You don't even need to do that if you trust the strength of the hash (which
is the whole point here).  All you need to do is re-calcaute the file-hash
and make sure it matches the full-file hash of the file you are trying to
download.

This works much like a normal hash of the entire file in terms of verifying
that the data is what you were looking for.  The advantage of the tree hash
is that you can calcaute the entire file hash given only a small segment of
data from the file, and a small handfull of hash values for the rest of the
file.  The hash values in the signature are data as well because they all
get hashed.  So it's just as hard to fake those as it is to fake the file
data.

> (this ignores the possibility that the size of a part is not a power
> of two multiple of the chosen block size.  in that case, each part
> must contain the hashes of its internal tree.)

You just include the hashes which outline the internal tree.  The internal
tree hash values are re-calcuated from the data to prove the data is
correct.

The number of hash values in the signature is worse case something like 2 *
log2(N) where N is the number of hash blocks in the file.  Most times, the
number is closer to just log2(N).

> >   But the larger side-effect is that because of the way the
> >   tree-hash works, the file segments you post must be sized so they
> >   start and stop on the tree-hash block boundries.
>
> you mentioned the problems finding a block size which fits the
> uuencode line length.  I think you should ignore that problem.  if the
> software is written correctly, it will handle the "short" line without
> problems.  also, neither MIME nor yEnc has this problem, so I think
> it's unnecessary to make the block size something obscure just for bug
> compatibility with uudecode.

I thought that too. I assumed block sizes which were a power of 2 would be
more logical.  But in fact, the job of calculating the hash in the first
place is a problem of reading "blocks" which match the hash you use.  for
SHA-1, it works in 20 byte blocks.  So it's working with an obscure block
size already which fails to fall correctly across any power-of-two sized
blocks.  Yet that really has no measurable effect on the speed of
calculating the hash because the problem is always a simple sequential scan
of the file which is well optimized on all systems already.

I finally picked a hash block size of 4500 bytes.  That's 100 uuencoded
lines of data.  That way, uuencode segment sizes must be a multiple of 100
lines - which is already a "norm" for uuencoded files.  And 4500 bytes is
an even multiple of the 20 byte blocks which sha-1 already uses so you
could even argue that as being better than any power-of-two block size.
But in fact, it's not really important.  The code is just as fast if you
use block sizes of 4513 which is prime and falls across nothing "normal".

The issues which did seem important as that the larger the block size, the
less hash values you need in the signature.  So bigger is better for that.
But since parts must be split on block boundries, the bigger the block, the
less granularity you get when trying to pick an article size, which means
if you try to make all the articles the same size (a good thing), the
ability to do that is limited by your block size.

4500 seemed to be a good number for uuencode as well as a reasonable
balance between granularity and hash signature size.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62419
Author: Rene
Date: Mon, 23 Dec 2002 23:13
94 lines
6110 bytes
Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
> [Rene]:
> >
> >   X-No-Archive: yes
>
> please turn it off, it really puts a hamper on my style when I can't
> quote.

Sorry, it was defaulted to on in the webinterface here... should be off
from now on unless I made a mistake.

> anyway, consider that a file on Usenet often is a gigabyte in size,
> and that each part seldom is larger than 500 kB.  that means 2000
> parts.  the hash of each part is 160 bytes.  if all hashes are

Nope, an SHA-1 hash is 160bits long, according to
http://www.itl.nist.gov/fipspubs/fip180-1.htm , that's 20 bytes. Still it
is much, I agree. However, you do need to transfer these hashes anyway.
Using a hash tree does not reduce the number of hashes, it increases those
(because I leave out all the nodes within the tree, I only use the root
node and the leave nodes)

> included in all articles, you add 320 kB to each part, which clearly

But there is no need to add them all over and over again. That's the beauty
of the hash'es one-way function. You post under the file hash, this is the
single most important identifier. Then for example, send as the "0" part
all the block-hashes, once only. Everyone can now validate this post. If
those block-hashes all add up to the file-hash, then you know you've got
them all right. And if you have the file hash and all the block-hashes,
then you're set. You have all the meta information you'll ever need to get.
(note that with that information, you CAN build up the full hash-tree if
you like - I but can't see what you will gain by that)

More yet, since this information probably should be forced to be in the
first message posted, it becomes very hard to manipulate and attack it.
Since it is the first post. How do you intercept that when you don't know
when its going to be posted ? And once its out on the net, everyone has all
the information they need to validate all following posts.

So unless I'm blatantly overlooking something here (which is well possible,
the binary news aspect is quite new for me), this just reduced the problem
to ensure the first post gets through fine. If it doesn't, you can resend
it as much as you want. An attacker can do whatever he likes to create
bogus files: As long as he doesn't break the hash algorithm, his injected
bogus hash-map is easily detectable, since his hashes hashed itself don't
reproduce the file hash, under which the article is being posted. Injecting
wrong parts won't do it either, they are protected by the block-hashes and
are therefor easily detectable. (Though still need to be downloaded before
they can be verified, unless a server does this by itself and discards
non-matching parts)

> is unworkable.  the tree approach, on the other hand, only needs 10-20
> hashes in each file.  now, you may be advocating sending the hashes

I basically only need one hash per *block*. That's even less.

> out-of-band.  I'm a bit concerned about adding a single point of
> failure to the system.  what happens if that hash list is missing from
> your server?

No I don't advocate transmission of the hashes out of band. The file hash
*additionaly* yes, but I don't actually advocate that, its just a thing
that will invariably happen, because it is so damn convenient. They will
get indexed somewhere outside news (on a webserver most likely). However,
discussing the issue of presenting an URL-ized form of the file (which
actually does not need to be invented, because there already is a working
URL-scheme to select a post) is a bit skipping ahead. First priority should
be to make file posting possible using hashes to protect them against
attacks, then to see for easy and convenience methods getting them.

> the every other article attack was well spotted.  I think it suffices
> that part 3 includes the hash of part 4 and vice versa to solve it,
> though.

Yes that would solve it. But it adds yet another hash to every part. As I
said, when you have all the leave-hashes, you can reconstruct the file hash
AND you can ensure that all parts are going to be what they should be. You
really have all you need, once you have the file hash and the hashes on the
leave of tree. There is no need to have the hashes at the branches (inner
nodes). And if you want you can reconstruct even these, since you already
have all the leaves, just add the pairs toghether until you reach the root.

Just to be more precise, the "l" hash in the ASCII picture is a different
one than the one I would be constructing. The "l" hash would really need
the calculation of the tree to get. My version simply takes all the leaves
in order and creates the "root" or file-hash out of that. No pairings,
simply feed them into the hash algorithm, one after another and get the
resulting hash.

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62420
Author: Curt Welch
Date: Mon, 23 Dec 2002 23:23
66 lines
4349 bytes
Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
> [Kjetil Torgrim Homme]:
> >
> >   (this ignores the possibility that the size of a part is not a
> >   power of two multiple of the chosen block size.  in that case,
> >   each part must contain the hashes of its internal tree.)
>
> let me expound a little on that.  if we let the block size be 64 KiB
> and someone posts 192 KiB parts, it will look like this internally:
>
>             +---------------+
>             |               |
>        +---------+          |
>        |         |          |
>     +----+    + - - +    +----+
>     |    |    :     :    |    |
>     a    b    c     d    e    f
>
>    == part 1 ==    == part 2 ==
>
> so, part 1 needs to contain the hash of "ab"

The hash of part 1 can be calcuated from the data.  The hash of part 1
needs to include the hash of the rest of the file, which is hash d, and
(ef) which you didn't give us a label for in your graph.

> (using Rene's
> nomenclature :) and the hash of "c".  including the hash of "a" and
> "b" individually is wasteful.  this means the the hash must be marked
> with its position in the tree somehow in the signature.  or maybe not.

Right.  It's not needed.

To calcuate a tree hash given the full file, you just make a single pass
over the file calculating the hash values.  You don't have to store the
entire tree as you do this, you only have to store one hash value for each
level of the tree.  So for each level in the tree, the hash values end up
being calcuated left to right in your diagram above.

When you pre-scan the file before posting however you do need to save most
of the hash tree so you can spit out the correct hash values in each
signature.

To calcuate the hash given the signature hash values and the data from a
single post (and I've not tried to write this code yet so I may be missing
something) you can do depth first search of the tree, but for each node in
the tree you calcuate the range of blocks that node represents.  Once you
hit a node which has no blocks overlapping the data in your current file
segment, you know that the next hash from the signature is the hash value
for that node, so you grab the next hash from the list, and return it up to
the previous level has the hash value.  For any node which overlaps some
data in the file (but is not completly included in the current article),
you just need to recurse down to the next levels.  When you get down to the
data block, you just scan it calculate the hash value for it.

That algorithm will both take hash values off the signature line in the
correct order, and end up scanning the data blocks from the current article
in sequence as well, and when it's done, it has a tree-hash value for the
entire file.  If that matches the one in the signagure, and also matches
the message-id, and you don't have extra hash values left over in the
signature, then you know all the data is valid.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62421
Author: Curt Welch
Date: Mon, 23 Dec 2002 23:56
114 lines
7056 bytes
Rene <invalid@email.addr> wrote:
> Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
> > let me see if I understand you correctly.  let's say it's a 13 part
> > posting.
>
> I imagined it the same way from Curt's description. Thanks for the nice
> ASCII (I just hope it survives my quoting)
>
> >
> >                               l
> >                 +----------------------------+
> >                 j                            k
> >         +--------------+                +---------+
> >         |              |                |         |
> >         g              h                i         |
> >     +------+        +------+        +------+      |
> >     |      |        |      |        |      |      |
> >     a      b        c      d        e      f      |
> >   +--+    +--+    +--+    +--+    +--+    +--+    |
> >   |  |    |  |    |  |    |  |    |  |    |  |    |
> >   1  2    3  4    5  6    7  8    9 10   11  12  13
> >
> > "1" is the hash of part 1, "a" is the result of hashing the
> > concatenation of "01" and "02", "g" is the result of hashing the
> > concatenation of "a" and "b", and so on.
> > part 1 should include its own hash, as well as a, g, j, and l.
> > part 4 should include its own hash, as well as b, g, j, and l.
> > part 13 should include its own hash, as well as k and l.
>
> I exactly looked at it this way too. However, if that is how it is
> intended, then what happens if I manipulate, say part 3?

Thats because you got the idea slightly wrong about how the hash tree is
used to verify the data.

If you send out a bogus part 3, the newsreader will try to use your bogus
data to recalcuate the tree-hash of the file.  If you supply bogus data,
the tree hash will be wrong, so the article will be rejected.  Trying to
supply data which correctly hashses to the right value is too hard to be
worth the trouble (if it's even possible in our life times).

> > the assembly program can notice discrepancies both by comparing hashes
> > (the "g" of 1 should be equal the "g" of "4"), and by verifying that
> > the hashes are correct (the hash of "a" from 1 and "b" from 4 should
> > equal the "g" found in either).
>
> True, but is this really necessary? Consider the following: A file is to
> be transported using this system (without hash trees):
>
> The file again has 13 parts, 1..13 (or 0..12, if you must), whereas part
> means block size with regard to the hashing algorithm. So we get 13
> hashes, the hashes 1..13. Now we take these 13 hashes and put them again
> into the hash algorithm. We get hash "l", the file hash. We can now
> safely publish the thirteen hashes, because everyone can validate them.
> The thirteen hashes, put into the hash-algorithm must equal l, the file
> hash.
>
> Having the file hash AND the thirtheen hashes is all we need. Because an
> attacker now cannot change the "leave-hashes", because that would be
> easily spottable. He also cannot inject bogus parts, because they can now
> be detected as such.

No you are catching on to how it works.

> There's no hash-tree and no overhead of calculating one, nor a need to
> validate the inner nodes (hash keys a..g). Of course if someone finds
> another message, giving the same hash code, then the system fails. But
> its the hash algorithm that failed in that case, so choosing a good one
> seems paramount to me.
>
> Maybe I'm just not seeing what is intended with the tree. The solution I
> propose here just needs a good way to distribute those basic
> block-hashes.

The tree hash is an improved version of the system you just proposed.  For
your system, a 100MB file with a 4K hash block would require you to publish
a hash article with 25,000 hash values. With the tree hash, you only have
to distibute log2(25,000)+log2(partsize) hash values with each article.
For a 100K part size, that works out to 15 + 5 or 20 hash values (worst
case) with each article.

The total number of hash values published would then be 20,000 (1000 parts
with approximately 20 hash values each), so the space wasted is not much
different for that example.  But the beauty of the hash tree is that it
allows each article to be independently verified without the need for
locating the correct external "hash article".  This means news servers can
verify a post when it's posted, without storing the "hash file" somewhere
for reference.  And the news server can reject it to prevent the forgery or
the corrupted article, from being sent out to usenet.  You just can do
stuff like that without using the hash tree.

Computationally, the hash tree does not require any significant more CPU or
memory to calculate than a straight hash of the the same file.  To calacute
an SHA-1 hash of a 20MB file, the SHA-1 code has to calculate 1 million
hash values on the 20 byte SHA-1 hash blocks.  To calcuate the tree hash
using 4K hash blocks on the same file, you have to calcuate an additional
2N more 20 byte hash blocks where N is the number of blocks.  For a 4K
block size that's 10,000 more hash calculations bringing the total to 1,
010,000 calcuations for the tree-hash instead of just 1,000,000 which is
the amount of work to do a straight SHA-1. (1% more cpu work).

Extra storage for calculating the tree hash is log2(N) or 13*20 byte hash
values (an extra 260 bytes of memory).

The tree-hash is without question the better answer to this problem.  It's
just a bit complex and usenet doesn't always do well with "complex".

But par files are beyond the understanding of most usenet programmers as
well, yet they have found a place in usenet.  So I have hope.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62422
Author: Rene
Date: Mon, 23 Dec 2002 23:56
149 lines
9056 bytes
curt@kcwc.com (Curt Welch) wrote:
> > let me see if I understand you correctly.  let's say it's a 13 part
> > posting.
[nifty ASCII art deleted]
> > part 1 should include its own hash, as well as a, g, j, and l.
> Right idea, wrong answer.
>
> To verify the data in the part, you must re-calculate the hash from the
> data. to see if it matches.  So the hashes you listed are the ones which
> you must calculate, not the ones which will be included in the header.
> So what you include with part 1 is hash 2, b, h, and k.  What the code
> calcuates are the hash values a, g, j, l when it wants to verify the data
> is part of a file with a tree-hash value of l.

I *thought* there must be more to that tree than just that... yes this
makes *much* more sense now. You didn't tell until now though :) Still, if
you first get all the leave-hashes, you can construct the tree or the file
hash just as well. Your method however distributes the hashes over all the
parts. This adds another layer of security (at the costs of more
complexity) on top of the system. An attacker cannot start to manipulate
message-parts until he has all the hashes in the nodes and only then can
start to create parts that look as if they are valid by having most hashes
correct. (but only most, he fails anyway)

By using this system, a newsreader can intelligently identify bogus parts
by just looking at the xbin-header. (because he most likely got some of the
upper hashes after having downloaded some valid parts) and can dismiss
posts that have the wrong hashes there.

> A posted part can included multiple blocks.  So lets say a single article
> included blocks 4 and 5.  To recalcute the tree-hash for the file, you
> would need to include the hash values a, 3, on one side, and 6, d, and k
> from the other.  The order of the hash values in the Signature: header

This makes the algorithm quite a bit more complicated. Only needing to
fetch and calculate one leave (and the way upwards to the root) is quite
easy, having to cope with an arbitrary number of spanned leave-branches
makes it more complicated. But still doable.

> the blocks in the file.  Which hash values need to be included is known
> by the program because The signature header starts with the full file
> hash (which is only requried there since I'm suggesting not including the
> full 160 bits in the Message-ID), and then is followed by the hash values
> required from the file in the correct order.

Well why not include the hash in full? 160 bits are 20 chars, but what's
more, each char is only a 0..9 or a a..f. You can further mangle them into
something smaller using a larger alphabet...

I'd rather spend the full 20 chars than to risk there is a "natural
collision" because of the truncated hash length.

> You don't even need to do that if you trust the strength of the hash
> (which is the whole point here).  All you need to do is re-calcaute the
> file-hash and make sure it matches the full-file hash of the file you are
> trying to download.

It's even quite fast, because all those partial hashes can be stored in
memory. And hashing of in-memory data is fast. The slowest part of it will
be the hashing of the just downloaded block - and that needs to be done
anyways to ensure integrity.

> This works much like a normal hash of the entire file in terms of
> verifying that the data is what you were looking for.  The advantage of
> the tree hash is that you can calcaute the entire file hash given only a
> small segment of data from the file, and a small handfull of hash values
> for the rest of the file.  The hash values in the signature are data as
> well because they all get hashed.  So it's just as hard to fake those as
> it is to fake the file data.

Yes, and especially, if someone wants to make a "good fake", which looks
mostly ok, he needs to know all the hashes of the tree. But he will get
them only once all parts of the file are already posted, at which time his
attack will probably not even confuse newsreader.

> You just include the hashes which outline the internal tree.  The
> internal tree hash values are re-calcuated from the data to prove the
> data is correct.

...and since parts of the internal nodes are stored in the header-line, a
newsreader can compare his limited knowledge of the tree he already has and
quickly decide if that part is a candidate, or if it is an impossible
addition - and not even bother downloading it.

> The number of hash values in the signature is worse case something like 2
> * log2(N) where N is the number of hash blocks in the file.  Most times,
> the number is closer to just log2(N).

I'd have to look into what happens if one article spans many branches. But
I think 2*log2(N) is the upper bound.

> > you mentioned the problems finding a block size which fits the
> > uuencode line length.  I think you should ignore that problem.  if the
> > software is written correctly, it will handle the "short" line without
> > problems.  also, neither MIME nor yEnc has this problem, so I think
> > it's unnecessary to make the block size something obscure just for bug
> > compatibility with uudecode.
> I thought that too. I assumed block sizes which were a power of 2 would
> be more logical.  But in fact, the job of calculating the hash in the
> first place is a problem of reading "blocks" which match the hash you
> use.  for SHA-1, it works in 20 byte blocks.  So it's working with an
> obscure block size already which fails to fall correctly across any
> power-of-two sized blocks.  Yet that really has no measurable effect on

No that's wrong Curt. SHA-1, like the MD4 and MD5 algorithms with which I
worked, don't care at all what the input size is. Actually, they measure it
in bit, not byte. You can feed them 0 bit input data, you can feed them 1
bit input data or you can feed them 324463452344523bit input data. They
simply don't care. They *do* an internal alignment but in the case of
SHA-1, I just skimmed through the documentation
(http://www.itl.nist.gov/fipspubs/fip180-1.htm) and SHA-1 works internally
with a block size of 512bits or 64 bytes. Still you don't need to align
yourself to that size. If you don't feed it an aligned bit-stream, the
algorithm adds padding on its own. Its output value is always 20 bytes,
however, it eats what you feed it. You absolutely don't need to constrain
yourself to anything just for the hash-algorithm.

For the sake of speed using file i/o, I'd recommend a multiple of 1024 or
4096, whatever the OS' are best suited to process atomically.

> the speed of calculating the hash because the problem is always a simple
> sequential scan of the file which is well optimized on all systems
> already.

...provided you use a buffer size they are optimized for. I think a
multiple of 1024 is a safe bet here.

> The issues which did seem important as that the larger the block size,
> the less hash values you need in the signature.  So bigger is better for
> that. But since parts must be split on block boundries, the bigger the
> block, the less granularity you get when trying to pick an article size,
> which means if you try to make all the articles the same size (a good
> thing), the ability to do that is limited by your block size.

Let's just say, I'd try to keep it below 1024 blocks(that's 2^10 so 10
levels in the tree) for todays normal sized file (whatever that is...)
maybe a bit bigger considering future developements. The algorithm, of
course, doesn't care about the levels, however the more there are, the more
memory and cpu cycles will need to be used to traverse it.

> 4500 seemed to be a good number for uuencode as well as a reasonable
> balance between granularity and hash signature size.

Well as I said, I'd make it a multiple of the OS' file io system.

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62424
Author: Curt Welch
Date: Tue, 24 Dec 2002 00:09
29 lines
2735 bytes
Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
> the every other article attack was well spotted.  I think it suffices
> that part 3 includes the hash of part 4 and vice versa to solve it,
> though.

You don't even need to do that with the tree hash.  If you check part 3 and
show it matches it's tree hash, and you do the same for part 4, then you
know they are both valid parts of the file with tree hash "xyz", and you
don't need to do anything else in the way of cross checking other hash
values.

If the two segements are self-consistent, and have the same tree-hash
value, you now they are part of the same file.  If you verify the artcile
is self consistent, the only thing you need to cross check is the tree-hash
value for a match.

So, once you decide to download the file with tree hash XYZ, then every
article the tool finds can be proven to be part of that file without having
to cross-check anything besides the tree-hash value.  You could pick out
hash values from the signatures and make sure things matched, but that
would just be a waste of time unless you wanted a level of security about a
million times higher than what is needed for Usenet.  The only way the hash
signature values could fail to match is if someone was able to create a
hash collision (or if you had bugs in your code).

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62425
Author: Curt Welch
Date: Tue, 24 Dec 2002 00:20
11 lines
1666 bytes
Rene <invalid@email.addr> wrote:
> Sorry, it was defaulted to on in the webinterface here... should be off
> from now on unless I made a mistake.

If you have checked the "Never auto-add X-No-Archive:" option, it will stay
off.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62426
Author: Rene
Date: Tue, 24 Dec 2002 00:56
142 lines
8773 bytes
curt@kcwc.com (Curt Welch) wrote:

I see you now Curt. It just needed a more detailed description of what you
exactly do with the tree. What I assumed was wrong, I did suspect you're
going to do something else with the tree than what I imagined, because it
simply didn't make much sense otherwise. (As I showed, once you have all
the leave-hashes, you have all you ever need)

You add another layer of security on top of that by distributing the hashes
all over the tree. So chosing between the two proposals, I'd chose your
way, because it seems far more secure that way.

> Thats because you got the idea slightly wrong about how the hash tree is
> used to verify the data.

Yep, I thought you'd wait until you've got enough leaves to calculate the
node one up. However what you really do is you validate the whole path from
leave to root node up.

> If you send out a bogus part 3, the newsreader will try to use your bogus
> data to recalcuate the tree-hash of the file.  If you supply bogus data,
> the tree hash will be wrong, so the article will be rejected.  Trying to
> supply data which correctly hashses to the right value is too hard to be
> worth the trouble (if it's even possible in our life times).

Ha not only that. Using your system, it is not only insufficent to get a
(colliding)hash which corresponds to the data, but you need to do this
several times for just one part ! You'd need to provide a full faked path
from the leave to the root, multiplying the effort. Although the attacker
can peruse the data he already has from the already posted article(s) to
recreate the path, it gets more complicated, AND he can't even fake any
path, only those that run along the same paths of former (valid) parts.
Which means, that on approximitly 50% of the parts he needs to create a
colliding hash for the part-data AND the path nodes and for 50% he "only"
needs to create a colliding hash for the part-data. Ouch !

> > Maybe I'm just not seeing what is intended with the tree. The solution
> > I propose here just needs a good way to distribute those basic
> > block-hashes.
> The tree hash is an improved version of the system you just proposed.
> For your system, a 100MB file with a 4K hash block would require you to
> publish a hash article with 25,000 hash values. With the tree hash, you
> only have to distibute log2(25,000)+log2(partsize) hash values with each
> article. For a 100K part size, that works out to 15 + 5 or 20 hash values
> (worst case) with each article.
>
> The total number of hash values published would then be 20,000 (1000
> parts with approximately 20 hash values each), so the space wasted is not
> much different for that example.  But the beauty of the hash tree is that

Actually, the number of hashes needed sending (as header data) is a
function of the number of articles using your xbin. One article at least
needs the hashes up the path to the root, so thats a guaranteed log2(N).
Then it additionally needs some hashes if the blocks in the article
"overlap" into other (sub)trees, but I think that must be less than log2(N)
additional hashes (need to think it over though). I think the worst case is
where the blocks overlap from the left-subtree into the right-subtree (ie,
crosses the "middle") because if it stays in its subtree, then sooner or
later up the path you reach a node you already have, if you pass over to
the right side however, you have a full sub-tree to traverse upwards.

> it allows each article to be independently verified without the need for
> locating the correct external "hash article".  This means news servers

Yep, that's the added security I mentioned. I like that way better.

> Computationally, the hash tree does not require any significant more CPU
> or memory to calculate than a straight hash of the the same file.  To

True, the nodes along the tree are in memory only, while the hashes of the
blocks need to be computed anyway (and they are the slow ones, due to file
i/o)

It *is* slower than my solution (a bit more memory, more memory traversal
of the tree, more hashes to compute), but that fraction of cpu I gladly
give up for a more secure model.

> calacute an SHA-1 hash of a 20MB file, the SHA-1 code has to calculate 1
> million hash values on the 20 byte SHA-1 hash blocks.  To calcuate the

Hm I think you don't have an accurate picture on how the hash algorithms
work. Actually they work that way: You initialize an hash algorithm. This
sets some internal registers to predefined values. Now you feed it some
data (or none at all, that's still valid!) The hash algorithm fills its
internal buffer with this data until it reaches its internal buffer size
(which is 512bits / 64 bytes for SHA-1). Once it reaches this limit, it
performs a set of bit operations and functions upon the input data and its
internal state, which is changed through these operations. Now it repeates
this step with any other full buffer you give it. Somewhen later, you stop
giving it data and ask for the hash value. At this point, the algorithm
likely has a somewhat filled buffer. This buffer is now filled to its limit
(padded) according to some rule and then the computation step is performed
one last time. Afterwards, the buffer is cleared and the algorithm gives
you its internal state as the hash value. Should you decide to need another
message hashed, you now NEED to reset the internal state or it would just
continue from where it was.

So the hash value you get is actually the internal state of the hash
algorithm - which gets changed with each processing of a full 512bit
buffer. At least, that's how MD4 and MD5 work, which I implemented. SHA-1
seems to work exactly the same way, from my skimming through the docs.

As a result, you can feed it anything you want, including 0 bits. It will
still work and it does not impose you any limit at all of what you feed to
it.

> tree hash using 4K hash blocks on the same file, you have to calcuate an
> additional 2N more 20 byte hash blocks where N is the number of blocks.

2N - 1 to be exact :) And that's the total number of hashes, not the
additional ones. If you have 8 nodes at the base, you'll have 7 nodes upon
them, if you have 4 nodes at the base, you'll have 3 nodes ontop of them,
etc...

> The tree-hash is without question the better answer to this problem.
> It's just a bit complex and usenet doesn't always do well with "complex".
> But par files are beyond the understanding of most usenet programmers as
> well, yet they have found a place in usenet.  So I have hope.

The way par files work is pure mathematics. Actually it's all matrix
operations as far as I understand it. Still I'd need to read up on quite a
lot of things to understand it entirely.

What you propose is not mathematics. It were if you'd bring your own hash
algorithm. But that's not wise, we are in the nice position that we can
just take the work of the cryptographers. All you do with your system is
add some data here, build up a tree, a basic memory structure for any
serious programmer, and traverse it, ocassionally read or write a value to
a node.

Actually, reading and writing here now lead me to "see" an algorithm that
should work at the edge of my mind. However, it's close to 2am now and I'm
not going to try anything out right now. I'll write my thoughts down
tomorrow, or the day after because tomorrow's christmas. Or today, because
it already is 2am :)

...which reminds me: Merry christmas you all !

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62427
Author: Curt Welch
Date: Tue, 24 Dec 2002 01:36
101 lines
6279 bytes
Rene <invalid@email.addr> wrote:
> No that's wrong Curt. SHA-1, like the MD4 and MD5 algorithms with which I
> worked, don't care at all what the input size is. Actually, they measure
> it in bit, not byte. You can feed them 0 bit input data, you can feed
> them 1 bit input data or you can feed them 324463452344523bit input data.
> They simply don't care. They *do* an internal alignment but in the case
> of SHA-1, I just skimmed through the documentation
> (http://www.itl.nist.gov/fipspubs/fip180-1.htm) and SHA-1 works
> internally with a block size of 512bits or 64 bytes.

I could easilly be wrong about SHA-1.  I don't think I've ever looked into
it.  I just made the assumption it worked on 20 byte blocks in a similar
way to how MD5 works.

MD5 however is a block hash which works on 16 byte blocks.  It is
structured to run though it's algorithm once for each 16 byte block.  If
you give it 17 bytes to hash, it pads the last block and runs the hash
algortihm twice making it take twice as long as for 16 bytes.

If you selected a 17 byte "tree hash" vs 16 bytes, it would take close to
2X the CPU time to clacuate the hash.  But that's a worse case issue which
is not at all significant when you are talking about blocks sizes 1K and
up.

If SHA-1 does use 64 byte blocks internally, then a 4500 byte hash block
would be mis-alligned for its blocks.  But like we both said, that's not
going to make a notable difference in CPU usage.

> For the sake of speed using file i/o, I'd recommend a multiple of 1024 or
> 4096, whatever the OS' are best suited to process atomically.

> > 4500 seemed to be a good number for uuencode as well as a reasonable
> > balance between granularity and hash signature size.
>
> Well as I said, I'd make it a multiple of the OS' file io system.

Write the code, set the block size to 4096 and time it.  Change the block
size to 4500 and see if you can measure _any_ difference.  You won't be
able to.

Here are three runs of my code calculating the tree hash of a 50MB file
(where the file is all in the memory cache of the server so no disk IO
happened):

1.838u 0.739s 0:02.72 94.1%     21+1168k 0+0io 0pf+0w
1.865u 0.640s 0:02.58 96.8%     21+1151k 0+0io 0pf+0w
1.910u 0.577s 0:02.60 95.3%     21+1167k 0+0io 0pf+0w

And here are three runs of the same code with a 4096 byte buffer:

1.880u 0.592s 0:02.58 95.7%     21+1242k 0+0io 0pf+0w
1.877u 0.719s 0:02.72 94.8%     21+1248k 0+0io 1pf+0w
1.908u 0.599s 0:02.57 96.8%     21+1246k 0+0io 0pf+0w

Looking at the user time (u), the 4500 block code seemed to run faster than
the 4096 byte code.  But more important, the difference is so small as to
be unimportant.  It takes 2.5 seconds to calcuate the hash for an entire 50
MB file on this 1GHz machine no matter what the block alignment is.  How
long will it take to just read that from the disk when the blocks are
pre-cached in memory like this example?  How long will it take to post it?
How long will it take to download it?

From the above numbers, it can be estimated that the CPU time requried to
verify a 500KB article on a 1Ghz machine will be about 25 ms.  How much
savings are you going to get when you are talking about 25 ms of "wasted
CPU" to start with?

The users will never ever notice a difference in performance if the block
size is 4500 vs 4096.  If we pick a block size which is not a multiple of
the uuencode 45 bytes per line, this forces the last line in most uuencoded
articles to be short. If there is only one poorly written uudecode utility
in the world which is unable to correctly deal with that (for example it
falsely assums a short line means "end of file"), and one user has to spend
hours trying to undersand why the files he is downloading "don't work", how
much CPU time will you have to "save" for the other millions of users to
make up for the problems you caused that 1 user?

If you write code like this:

   while (fread(hash_buf, 1, HASHBLOCKSIZE, file_stream)) {
      ...
   }

Then every byte has to be copied from the stream input buffers to your
hash_buf, and the alignment has very little to do with how fast those
copies are.  The main speed issues is how many total bytes you have to
move, and how many times you have to call fread().  The aligment just
doesn't make a measurable difference.  fread() works with blocks which are
power-of-two sized to match the OS, so the overhead work of the OS is
already being isolated from the application and the work of re-aliging 4096
sream buffers to 4500 byte buffers is all dealt with by fread() so a
typical application programmer has nothing to deal with.  The code is
identical no matter what the block size is.

I know a block size which is not a power of two seems "wrong".  But I think
it's more than justified for this application.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62428
Author: Curt Welch
Date: Tue, 24 Dec 2002 03:29
163 lines
9730 bytes
Rene <invalid@email.addr> wrote:
> curt@kcwc.com (Curt Welch) wrote:

> Which means, that on approximitly 50% of the parts he needs to create a
> colliding hash for the part-data AND the path nodes and for 50% he "only"
> needs to create a colliding hash for the part-data. Ouch !

If the newsreader was cross checking hash tree values between articles,
that's true.  But because of the strength of hash, it's likely that many
tools would not bother.  To verify an article, you can simply read it
sequentially and decode the data and verify it in one pass.  You write the
data out to a file as you decode it and when you get to the end of the
article, you know if the file data is valid or not.  If it's not, you throw
it away, if it's good, you store it with the rest of the file segments you
have for that hashtree file.  You never need to store the hash tree values
on disk, because if you trust your computer to not corrupt your data, you
never need them again.

Well, I take that back.  If you want to re-post parts of the file before
you download all the parts, then you do need to save the hash tree values
from the signature as you get them from each post.  So a more powerful tool
that allowed you to repost segments from your "partial download" would need
to save that - and as long as you are re-constructiong the hash tree and
saving the data as you download each article, why not double check it and
make the job of fake a few orders of magnatude further past "impossible".
:)

> Actually, the number of hashes needed sending (as header data) is a
> function of the number of articles using your xbin. One article at least
> needs the hashes up the path to the root, so thats a guaranteed log2(N).

In another article, I thought the answer was log2(N)+log2(M) where N is the
number of blocks in the complete file and M is the number of blocks in each
article.  But that's not right because if M == N then the number of hashes
needed is 0.  if M is N/2 and M is a power of 2, then the number of hashes
needed for each article is 1.

> Then it additionally needs some hashes if the blocks in the article
> "overlap" into other (sub)trees, but I think that must be less than
> log2(N) additional hashes (need to think it over though). I think the
> worst case is where the blocks overlap from the left-subtree into the
> right-subtree (ie, crosses the "middle") because if it stays in its
> subtree, then sooner or later up the path you reach a node you already
> have, if you pass over to the right side however, you have a full
> sub-tree to traverse upwards.

For a file which has a power of two number of blocks, I think you are right
and the worse case happens when the article has 2 blocks which overlaps the
the center of the file.

Ah, I'm beginning to see it.  This is the same problem as counting the
number of bits turned on in a binary number.

If you look at the number of blocks to the left of the file segment, and
represent that number in binary, and count the number of 1s in that binary
number, that is the number of hash values you need to represent the top of
the tree hash for that part of the file.  And then you do the same for the
blocks to the right of the segment in questions to see how many hash values
are needed for that side.

Ah, but it's not even that simple because that gives you the correct value
for the left side (which starts at the beginning of the file and is
correctly aligned with the binary tree), but the number required for the
right side depends on the alignment of the block with the binary tree for
the entire file.

Worse case is still close to 2log(N).  Ah, but maybe it's even worse than
that at times depending on the file size and the alignment of the segement
because of the complexity of what happens on the right side?

I think some work is required here to get a better understanding of this
because the worse case effects the max size of the Signature header, and
that can limit the max possible file size which can be posted using this
system while still keeping the header length to a size which various news
servers can correctly deal with (which I think is around 1000 bytes).

Let see, the hash and a few spaces takes up about 30 bytes per hash so that
gives us around 32 hash values max in one header. If 2log2(N) is the worse
case, then 16 = log2(N) or N == 2^16 is the max file size that can be
posted without risking the hash header overflowing.  With a block size of
4500, that gives us a max file size of around 300 MB before the hash header
may end up being greater than 1000 bytes.

That's not as high as I'd like to see.

One option I guess is to use a larger hash block size, but doubling the
block size only doubles the max file size, and I'd like to see something
that would allow a file size much much larger (100 GB) for example.

The larger the parts the less hash values you need, but I'm not sure how to
calcuate that.  Maybe the answer is if want to post a 100GB file you have
to do it with 10MB posts. :)  That's not an unresonable requirement.  Also,
if the articles each hold an even power of 2 number of hash blocks, that
reduces the worse case problems.  So many be the answer is that for really
large files, the posting program has to be smart to avoid a header overflow
problem.

And manybe I'm wrong about header length probelms.  For a header which the
news serers don't have to deal with, and which the news reader is only
going to get by doing a HEAD command, there may not be any news servers
which care that there is a 2K header in the artcle?  Anyone know?

> > calacute an SHA-1 hash of a 20MB file, the SHA-1 code has to calculate
> > 1 million hash values on the 20 byte SHA-1 hash blocks.  To calcuate
> > the
>
> Hm I think you don't have an accurate picture on how the hash algorithms
> work.

I do.  I just iddn't know SHA-1 worked with an internal block size of 64
bytes.

I was also fairly sure that MD5 used an internal block size which matched
the hash size of 16 bytes, but I could be wrong about that as well.

> The way par files work is pure mathematics. Actually it's all matrix
> operations as far as I understand it. Still I'd need to read up on quite
> a lot of things to understand it entirely.

If you care, here's a really good description of the algorithm written for
programmers to understand (it's in PDF):

http://www.cs.utk.edu/~plank/plank/papers/CS-96-332.html

Once you get a basic understanding of it, it's really not as complex as it
seems at first.

I might have some numbers wrong, but I think this is basically it:

Reed-Solomon is simply a set of linear equations where each equation acts
as a check-sum algorithm.  Though the math behind it is defined for real
numbers, the mathamaticians figured how to map it to binary numbers of any
bit length.  For 8 bit numbers, the system defines 256 different equations
that can each caluate an 8 bit "check-sum" for up to 256 8 bit data values.
For all sets of 256 data values, the equations always guarantee to generate
256 different check-sums.

Each equation is used to generate a single PAR file for up to 256 data
files. It's done byte by byte.

If you have any data files missing, then what you are left with is a set of
simultanious equations with N unknowns where N is the number of files you
are missing.  As long as you have N or more equations (i.e. par files),
then you can solve using substitution for the unknown variables (files).

> What you propose is not mathematics. It were if you'd bring your own hash
> algorithm. But that's not wise, we are in the nice position that we can
> just take the work of the cryptographers. All you do with your system is
> add some data here, build up a tree, a basic memory structure for any
> serious programmer, and traverse it, ocassionally read or write a value
> to a node.

I re-envented the wheel much like you did thinking of this problem, but
hash trees I found out have been well known for many years in crytology.

And the use of hash trees for this same purpose (distribution of partial
files over an unscure medium) has been defined for use with P2P I found.
Search for "bitprint".

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62429
Author: Rene
Date: Tue, 24 Dec 2002 03:33
130 lines
7556 bytes
Lucky me, can't find some sleep... *sigh*

curt@kcwc.com (Curt Welch) wrote:
> I could easilly be wrong about SHA-1.  I don't think I've ever looked
> into it.  I just made the assumption it worked on 20 byte blocks in a
> similar way to how MD5 works.
>
> MD5 however is a block hash which works on 16 byte blocks.  It is
> structured to run though it's algorithm once for each 16 byte block.  If
> you give it 17 bytes to hash, it pads the last block and runs the hash
> algortihm twice making it take twice as long as for 16 bytes.

Nope, sorry. That's wrong too. MD5's internal state is 4 times 4 bytes,
that much is correct, however it too processes data in intervals of 512bit
/ 64 bytes. See http://www.ietf.org/rfc/rfc1321.txt either section 3.1
where the padding is explained or the sample code on page 8 where you see
that the struct MD5_CTX uses a buffer of size 64.

An optimal input size would be 447 bits, because 1 bit at least is always
added for padding, followed by the lenght (which is 64 bits, not 32) and
thus result in a full 512 bit buffer.

However, don't do that ! This results in only one round and is probably far
more easier to reverse. (That's 447 bits input producing a 128bit hash in
MD5).

> If you selected a 17 byte "tree hash" vs 16 bytes, it would take close to
> 2X the CPU time to clacuate the hash.  But that's a worse case issue
> which is not at all significant when you are talking about blocks sizes
> 1K and up.

Nope you can enter full 55 bytes to still fit in one round (on MD4, MD5 and
SHA-1 which all use a 512 bit buffer) Second round would be 64+55 bytes and
so on. So chosing a size based on hash-rounds, you'd need n*64+55 bytes as
an optimal input size.

> If SHA-1 does use 64 byte blocks internally, then a 4500 byte hash block
> would be mis-alligned for its blocks.  But like we both said, that's not
> going to make a notable difference in CPU usage.

4500 bytes would end up in 70 rounds of full 64 bytes, leaving 20 where 55
could fit. We can't get 35 more bytes since the file limit is 45 as you
say.

This is a uuencode limit as you say. May the last line be shorter? If so
you could increase the blocksize to 4535.

> > Well as I said, I'd make it a multiple of the OS' file io system.
> Write the code, set the block size to 4096 and time it.  Change the block
> size to 4500 and see if you can measure _any_ difference.  You won't be
> able to.

Probably not. Then again I don't know on what blocksizes the OS performs
one read  call. Its probably 512 bytes or 1024 bytes. So does it make a
difference ? Probably nothing measurable. If the blocksize of the OS is
1024, then I've issued a command that caused 4 reads instead of 5. It might
not be measurable, in fact I'm quite sure it isn't worth a long debate. Its
a minor optimisation, causing one less syscall, one less memory access on a
block which by then is in the cache anyway, so winning about 5usec latency
at most.

You say your chosen size is adapted to uuencode, so that's in a field where
I have no clue what you need to do and what you must not. I trust your
judgment in that area.

> Here are three runs of my code calculating the tree hash of a 50MB file
> (where the file is all in the memory cache of the server so no disk IO
> happened):

Well actually loading and processing the file would have been more
interesting... The slowest part of all this WILL be the disk i/o. Memory
access is always fast.

> Looking at the user time (u), the 4500 block code seemed to run faster
> than the 4096 byte code.  But more important, the difference is so small

Yes the difference is too small. It probably will still be small with
actual disk i/o but you already seem to have your test-program around, so
can you repeat this test with a non-cached file?

> is.  How long will it take to just read that from the disk when the
> blocks are pre-cached in memory like this example?  How long will it take

0 - if the data is pre-cached, then the disk will not be asked for blocks.

> to post it? How long will it take to download it?

Far longer. However, you need to assume that a multithreading newsreader
will be processing the posts. So there are concurrent downloading /
decoding / memory updates. You can't be too sure your block will be in the
cache when you are going to feed it to the hash-algorithm (especially
considering that this will probably be after the write to disk, so the
cache-blocks holding that part are already marked as "written and
reclaimable") Its but a little optimisation trying to minimize disk i/o. If
conforming to uuencode line length is more important, then forget it, its
not worth trying to find something that satisfies both things. If it can
easily be done though, then I'd do it, it doesn't really cost anything.

> The users will never ever notice a difference in performance if the block
> size is 4500 vs 4096.  If we pick a block size which is not a multiple of
> the uuencode 45 bytes per line, this forces the last line in most
> uuencoded articles to be short. If there is only one poorly written
> uudecode utility in the world which is unable to correctly deal with that
> (for example it falsely assums a short line means "end of file"), and one
> user has to spend hours trying to undersand why the files he is
> downloading "don't work", how much CPU time will you have to "save" for
> the other millions of users to make up for the problems you caused that 1
> user?

That's one of the things I didn't knew about. If it is potentially that
critical, then by all means, make it a multiple of 45. However it was my
intention that the last line could be made shorter - so assuming that this
is the eof would be correct. You probably meant to write that this uudecode
cannot handle that correctly and adds junk (which subsequently will get
that block marked corrupt by the hash-algorithm)

> I know a block size which is not a power of two seems "wrong".  But I
> think it's more than justified for this application.

It seems so, yes. Coming from the pure programmer's side with no binary
news experience I would have taken a multiply of 1024 because it is
"natural". I didn't see the problems with uudecode.


Damn, not a bit more tired now...

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62431
Author: Dufus Systems
Date: Tue, 24 Dec 2002 04:45
5 lines
1371 bytes
Good description of your hash tree's here. 


http://open-content.net/specs/draft-jchapweske-thex-01.html
Re: Power-Post 2003 - requesting input from authorities..
#62432
Author: Curt Welch
Date: Tue, 24 Dec 2002 04:51
15 lines
2046 bytes
peon@somecompany.com.invalid (Dufus Systems) wrote:
> Expecting the Servers to change at all to support this IDing process is
> unreasonable.

I wrote my server.  So the idea of _a_ server changing to take advantage of
something new is not at all odd to me.  But the xBin system for labeling
posts has huge advantages for both posters and downloaders and needs no new
support to be added to any server to make it work.  It's just nice because
it opens the door for the possibility of advanced server features being
added later.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: Power-Post 2003 - requesting input from authorities..
#62433
Author: Curt Welch
Date: Tue, 24 Dec 2002 04:58
28 lines
2608 bytes
peon@somecompany.com.invalid (Dufus Systems) wrote:
> Currently I'm watching fakes that are exactly the same size as the
> original posts, even the same line count (though this is easy to fake).

Not on my server it's not.  My server fixes the Line: header to be correct
so both the byte value and the line value returned by XOVER and the Line:
value you find in the headers reflect the size of the file as it is on my
server.

A newsreader could use that to attempt to idenfity short fakes.  But if
they post a correct size and format article, there's no easy way to
identify it's a fake without downloading even with the xbin system. (but
with xbin, the servers could start rejecting the fakes so the newsreaders
won't even have to deal with them).

> So, size filtering's out as a solution. I'm also seeing pre-emptive posts
> where the attackers notice a part 1,2,3 and post a fake part 30 BEFORE
> the real part 30's sent out. I expect the encoding format will soon be
> matched up as well.
>
> Quade

Do you know who is doing this and why?

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: Power-Post 2003 - requesting input from authorities..
#62434
Author: J.B. Moreno
Date: Tue, 24 Dec 2002 06:15
23 lines
2354 bytes
In article <20021223235121.889$9w@newsreader.com>, 
 Curt Welch <curt@kcwc.com> wrote:

> peon@somecompany.com.invalid (Dufus Systems) wrote:
> > Expecting the Servers to change at all to support this IDing process is
> > unreasonable.
> 
> I wrote my server.  So the idea of _a_ server changing to take advantage of
> something new is not at all odd to me.  But the xBin system for labeling
> posts has huge advantages for both posters and downloaders and needs no new
> support to be added to any server to make it work.  It's just nice because
> it opens the door for the possibility of advanced server features being
> added later.

Right -- and this *is* a server group and several people (besides
yourself) who work on servers have expressed interest in some kind of
labeling system; which is quite understandable, there are definite
benefits that the server gains, not least the ability to easily expire
large files faster than smaller files.

-- 
J.B. Moreno
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62435
Author: Jeffrey M. Vinocur
Date: Tue, 24 Dec 2002 07:38
17 lines
1614 bytes
In article <20021223041127.986$6M_-_@newsreader.com>,
Curt Welch <curt@kcwc.com> wrote:
>
>I'll give an outline here. (which now that I've finished writing it, I see
>will take you a few hours to get through anyway :)).

Can you stick this up on the web somewhere?  I don't really have
the motivation to work through it now, but at some point I might,
and it would be nice not to have to poke at Google.

And it would keep you from having to repeat yourself all the
time.

-- 
Jeffrey M. Vinocur
jeff@litech.org
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62436
Author: Curt Welch
Date: Tue, 24 Dec 2002 07:41
351 lines
19671 bytes
Rene <invalid@email.addr> wrote:
> curt@kcwc.com (Curt Welch) wrote:

> This system works fine for its purpose: To uniquely identify files within
> the network, even if the same file is inserted into the p2p-network at
> two different places. As long as the file is (bit for bit) the same, so
> is the hash.

Like I said in my other posts, there's what looks like a standard called
bitprint which seems like it was defined for P2P use.  I can't tell if any
P2P system is actually using it however.  But the name no doubt comes from
"fingerprint" as a uniq ID for the file.  It's a very large hash however
because the bitprint is a combination of both a TigerTree (which is a
hash-tree build on 192 bit Tiger hash and 1K blocks), and the SHA-1 of the
file, which adds up to an 352 bit hash of the file.

They are no doubt trying to create a hash so unique that you can use it for
thousands of years for every file createad and still have the odds of a
collsion be near 0.

> The community has found a way to prevent this happening though. There is
> a site who downloads the files and once it is confirmed that the file is
> really what was claimed and probably it fullfills some other quality
> constraints, it is put in a database for everyone to see.

This BitPrint seems to be built around that concept.  The company that
created it might have even been trying to get into the business of running
these databases.

> Furthermore,
> since the system uses a URL-scheme to easily select files of interest,
> you can simply create a link like a http-link and users of this
> p2p-software can just click and get that file hash added to their "to
> download list" - which is a very clever and quite comfortable way.

For xBin on usenet, the Message-ID of any article posted under the system
acts as a unique identifier for that file.  (uniqe to 60 bits hash+file
length) which I believe is large enough for this purpose).

If you post an xBin file to any group on usenet (including
alt.binaries.everythingxbin), to announce the file to the world, all you
have to do is post a text message somewhere and say:

  I posted song.mp3 as <$XB$Hx/I8REUBPH$SEoJr$oAA$sBa$$3mK@xbin.org>

One Message-ID is all the download to tool needs to find the post and
download it for you.  If the download tool gave you the power to read text
messages, and gave you the power to click on xBin Message-IDs to add the
post to the download list, then it could be a convention that people would
post all there announcemnts in a .d group, and post the 1000 part posts to
a .x group that nobody every bothered to read or download headers from.
The download tools would simply download all the Message-Ids from the .x
group and use that to find all the posts, and reposts as required.

For that mater, the announcement of the post should have the same xBin file
signature in it's Message-ID so it could act like a part 0 post where the
part 0 post was posted to the .d group and the data was posted to the .x
group.  So then instead of having to put the Message-ID into the text, the
article would just be an announcment of the post.  The download tool would
see that the article had an xBin Message-ID, so it would activate the
"Download This File" button when you read the message.  And the newsreader
would also be able to show you the size of the file since it too is in the
Message-ID so you know how big of a file you are asking to be downloaded.

So, if you want the file, you just click the DownLoadFile button, and the
download tool adds that xBin id to the list of files it's downloading parts
for.  None of the parts even have to be on the server yet, the tool will
simple add to it's list of "things to download" and for something huge,
that might be posted as 100 articles every day for the next week, the tool
will just keep collecting the pieces as they show up.

Having a download tool that could spot Xbin Message-IDs in the text of a
post would allow people to build indexes of everything posted to Usenet
recently so you could read the one index article and click on things you
wanted to download.

Or, maybe the idea of posting a set of files and listing the xBin ids of
each file in the set in one article would be good as well.  A download tool
could then have an option to extract all the xbin IDs from the text of the
article and add them all to it's download list.

Lots of things become possible when you can automate the job of locating
file parts and download and deocode without having a human "step in an fix
things" which is so commonly needed on Usenet now.

> Yes, and this has prooven to work out well. However, if someone posts the
> same file again BUT applies any transformation beforehand (he rar's it
> with a different, never version) then the file he posts is of course
> something different (bitwise compared) and it *will* get another file
> hash.

And some posters don't want people to know that the same file is being
posted again, so they won't like the file-hash idea.  But it should be easy
for them to both use xBin and get around that by finding ways to make minor
changes to the file.  A 1 bit change anywhere gives it a new file-hash.

It was suggested that the standard should allow for a random hash to be
made up to allow people to that did not want their reposts to be tracked to
still label their files with xBin but to get around the "fixed ID" issue
they didn't no like.

I think it would be wrong to allow that.  To keep things simpler, I think
xBin should only allow a "real" hash.  There are plenty of ways to change
the file or post it a different format (like ziped or rared etc) that would
prevent it from being spoted for the people that care about that.

> Ok, basically include the unique file-hash into the message-ID.

Right.  That makes the Message-Id not only uniquely identify the article,
but it also uniquely identifies the file the article is a part of.

> Maybe there is a clever way in propagating those tree-hashes but if so,
> you didn't say that up to now and I don't see it directly :)

As you have now seen in the other posts, this is exactly the point of the
hash tree.  It is the clever way of including the hash informaion for the
file in every post in a compact form.

> However that is hashing linearly. For tree hashing, you'd need to stop
> after having reached a block and save that result, then continue until
> there are all results. Then create the pair-hashes etc. However, the most
> time gets lost seeking through the file, getting the "leave-hashes",
> since once they are computed, you can leave them in memory and work over
> them in memory only, which should be quite fast (even though you'd have
> to compute (2^log n)-1 hashes, whereas n is the number of
> blocks/leave-hashes)

Yeah, is it turns out, the code isn't as bad is it might seem at first
glance.

If you want to calcuate the tree hash but not save the entire hash tree,
then all you need to do is read hash-sized blocks from the file, calcuate
the hash of the block, and maintain a list of hash values in an array going
up to the root.  Each entry in the array is either empty, or holding a hash
value.

Once you calcuate the hash for the block, you then scan the array. If you
find an empty arry element, you store the hash there and stop.  If the
element is holding a previous hash value, you remove it from the array,
hash it with your current hash value, and then proced to the next array
element and repeat.

You continue reading blocks, calcuationg hash values, and scaning your
array combining the current hash with others already stored.  After you
finish the last block, you then make a final pass though the array and
combine hash vales up to the top until you are left with only one which
becomes the file hash.

If you need to build and save the entire hash tree, I did by allocationg
binary-tree nodes on the fly.  You could also di it in an array using
positional encoding.  Or if you were worred about how much memory might be
available to you, could could calcaute the hash values in-core using only
the small array as talked about above, but the write out every hash value
as it is calcuated to a file.  The position of each hash value could be
found in the file later by it's position.  I'd have to think a little more
about that, but I'm sure it would work.

> Once the blocksize is set, the newsposting software knows it wants to
> post nnn blocks with each block being xxxx bytes large. The article
> length of each article in such a sequence will vary of course - but
> that's no change from what it is today, is it?

The other things that is "good" for usenet that is not commonly done is to
try and equlize the size of all the articles in one multipart post.
Articles tend to get filtered by size, and they tend to move faster or
slower though Usenet based on their size.  If all the articles for one
multipart set are the same size, it imporves the odds that they will all
make it to the same servers, at about the same time which improves the odds
they they will expire at about the same time, and expire in the same order
hey were posted.

Today, the last article is very often substantically smaller.  These tend
to move faster though usenet, and tend to make it to servers that the large
articles might be filtered from.  And because they move faster, they can
sometimes show up first even though they were posted last.  And then,
because they showed up first, they expire first, leaving an incomplete set
of "large" articles on the server and leaving users wondering why the small
articles were "lost".

The larger the block size you choose for the hash, the more variation you
have from file to file in size, and the more problems you have like we
already see today.

> > To demonstarte the format it's using, I just posted a small 3 part mp3
> > file to Usenet.  Here are the important headers added to the first of
> > the three parts:
> >
> > X-Bin-Signature: x/I8REUBPHGJ+qcCiUb3TXz4Z80
> >   pRnksBkZcSiccM1/hkrWdEBd7u0 x+m6b4q/02G04s29ZNPQcRMToMg
> >   j/3IFK3di5igu5Z7KpjDoIkN33I 0MFRwrdF1rCYmcW5qCcs0+fM0B8
> >   yiZ65jmF1sZjCiHjUoKzBd75Wgw
> > Message-ID: <$XB$Hx/I8REUBPH$SEoJr$oAA$sBa$$3mK@xbin.org>
> >
> > The X-Bin-Signature: is the tree-hash data needed to verify the data in
> > the article.  The hash is encoded in base64.  The first value is the
> > full tree-hash for the file. (the one that starts with x/I8...)
>
> What exactly is the rest of the X-Bin-Signature containing? I assume its
> some of the tree-hashes but in what order (upwards towards the root from
> this node?)

They are the hash values for the rest of the file which is not included in
the post.  They are the highest level nodes from the binary hash tree which
do not overlap with data in the article.  Each hash value in the signature
is the hash value for a set of blocks from the full file and each hash will
cover a range of blocks which is a power-of-2.

If the hash blocks in the file are numbered starting with 1, and the
article we are looking includes blocks 14 though 18, the first hash in the
signature is the hash for the first 8 blocks (1 to 8), the next hash is for
the next 4 blocks (9 though 12), and the next hash is for block 13.  The
remain hash values cover the rest of the file after the segment included in
the article.

Those hashes represent the highest levels of the hash tree you could
calcuate using the data _not_ included in the current post.

To verify the data in the post, you then use those hash values, and the
data in the post, to finsh the hash tree calculation.  If you finish the
calculation, and end up with the correct file hash, you know the data in
the post is valid, and you know for sure that it came from a file who's
tree-hash matches the one listed in the Message-ID.

> > What's left to do is write a article verifiying tool - first to show it
> > can be done and second - to veryify that what my posting tool is
> > produceing is even valid.
>
> I'm currently working on a personal Java programm that fetches news for
> me more or less autonomously. (Don't worry Curt, I haven't let it run
> loose on your servers yet, I'm testing it with my local leafnode
> installation ;-) )

No problem.  You can't really do much harm if you are aren't posting.  If
there's anything I can do from my side to help with our code let me know.

> At the moment it can connect to a server, issue the
> "DATE" and "HELP" commands, get the reply and quit. It's a free time
> project though and I don't know how much I'll be working on it over the
> hollidays and silvester.
>
> IF there is a specification (you already gave about most of it I think,
> though some questions remain) I can programm something that tries to
> understand that format. However I gladly let anyone step forward who
> "really really wants to do it now" (tm).

The only spec I have right now other than these posts is the code.  But if
this to go somewhere, I'll be happy to work on a more formal definition and
put it on my "nothining here yet" xbin.org web site.

> > Par file technology could be supported by this as well, but it would
> > have to be built into the xBin standard to work correctly.  That gets
> > complex.
>
> Well every single file gets its own file-hash. So the par's could be
> marked somehow "this is for filehash : xxxxxx" so you know that this is a
> par-file which belongs to the file with the corresponding file-hash.
> However, if people will still post their files splitted in nn-parts (r00,
> r01...) then each of these rNN-parts will get its own file hash uniquely
> identifying it. That WILL get a mess then... and if people start to post
> the full file as one segment with Xbin, then this becomes incompatible
> with the par-system (since the par's must be as big as the original
> segments - if there is only one segment you have one big file and one
> just as big par-file ? Don't think so.)

Well what you have to do is logically treat the one huge file as if it were
split up into fixed sized segemets even though it is not.  Just like par
got built into winrar to work better, the reed solomon codeing would have
to get built into the download and posting tools to really work correctly
with this.

So you would post the full file with any part size you want to.

Then you have a tool that can calcuate and post PAR segments which don't
need to be based on the origianl file split at all - but they could be and
it would be usefull if they were.

You then post PAR "segements" which are used to replace missing articles.

But 8 bit Reed-Solomon coding is limited in the number of "files" it can
protect.  It think that number is 128 or 256.  Or maybe it's actually that
the number of data files + the number of par files you want post has to <=
256??

And if you are posting large files as one huge multipart posts (which is
they way it should be done), then you will end up with posts where a single
par post will not cover all the articles.  But that's not a problem, you
just post rar files which cover the parts 1 to 128, then another set of rar
files to cover parts 129 to 256, etc.

This gets confusing for the person trying to download, but the point is
that all this needs to be made automatic so the person downloading doesn't
have to understand which parts they have missing and which par files they
need to use to fix it.

The par file segments need to have special xBin Message-IDs that indicate
they are par files, and which document eactly which par file it is and what
parts of the full file the par file is "protecting".  The download tool
would then be smart about par files and be able to figure out on it's own
if the par file could help it fill missing gaps in the file.  The user
wouldn't have to think about it.

As far as posting par files, what would work best is to automate the
re-post requests so the people who were missing parts could post a re-post
request which is machine generated and machine readable to cleary document
all the segments the person was missing (and for a 1,000 part post, that
may be alot).

But the re-posting tool could look at a request and figure out what par
files, and how many par files are needed to fill the request and only post
what was needed.

But before something like that is in place, people for now will just
continue to do what they have been doing.  They can split the large files
up, and post rar and par files.  xBin won't help them get the full set, but
it will help get the peices of the rar files and it will help prevent
forgeries from causing the problems they cause now.

> > The other dream of xBin is to "fix" posting so that people would no
> > longer need to break huge files into lots of small rar files (or master
> > spliter or whatever).  It would allow you to post a huage file as 1000
> > parts if that is what it takes.
>
> Yes that would be recommended, however that comes at the cost of breaking
> par-style parity files. However, you could simply re-get/post the missing
> blocks.
>
> This definitly needs to be tested thoroughly....
>
> > All this stuff is a bit complex.  It might prove to be too complex for
> > Usenet.  But I think it could make multipart posts work a lot better
> > than
>
> Not too complex I think. In the end its "just" another way to mark posts.
> Actually to make them more system-readable. The logic and complexity
> remains completely in the end-users news-application software. It
> shouldn't bother the newsservers at all, though they might take advantage
> of it, once it is used widespread (automatic processing for webfrontends
> or something like that comes to mind).

Right.  That's the goal. You make the binary files more system-readable so
the software can deal with the files instead of making the users do so much
by hand to deal with the problems that keep showing up.

It should give both the end-users/admins/software developers a lot more
options than we currently have to deal with binary file problems, and to
add new features to help support binary files better on Usenet.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62437
Author: Curt Welch
Date: Tue, 24 Dec 2002 08:49
99 lines
5839 bytes
Rene <invalid@email.addr> wrote:
> Lucky me, can't find some sleep... *sigh*
>
> curt@kcwc.com (Curt Welch) wrote:
> > I could easilly be wrong about SHA-1.  I don't think I've ever looked
> > into it.  I just made the assumption it worked on 20 byte blocks in a
> > similar way to how MD5 works.
> >
> > MD5 however is a block hash which works on 16 byte blocks.  It is
> > structured to run though it's algorithm once for each 16 byte block.
> > If you give it 17 bytes to hash, it pads the last block and runs the
> > hash algortihm twice making it take twice as long as for 16 bytes.
>
> Nope, sorry. That's wrong too.

Ok, so I give up on that point.  :)  I'll have to go look into this some
time.

> > Here are three runs of my code calculating the tree hash of a 50MB file
> > (where the file is all in the memory cache of the server so no disk IO
> > happened):
>
> Well actually loading and processing the file would have been more
> interesting... The slowest part of all this WILL be the disk i/o. Memory
> access is always fast.

Testing it now - it took 5.4 seconds total to read the disk blocks and do
the calculatlions for the 50MB file (compared to the 2.5 seconds to just
calcuate the hash when all the disk blocks were in-core).  And the system
I'm running it on is busy being a news transit box at the same time moving
about 40 Mbits of traffic.

> > Looking at the user time (u), the 4500 block code seemed to run faster
> > than the 4096 byte code.  But more important, the difference is so
> > small
>
> Yes the difference is too small. It probably will still be small with
> actual disk i/o but you already seem to have your test-program around, so
> can you repeat this test with a non-cached file?

I did it with the same file I used before, but I would expect none of it to
be left in the cache.  It's hard to tell for sure however.

Here is a run against a 2GB file that's not likely to be cached using a
hash block size of 4096:

81.207u 32.254s 3:02.80 62.0%   21+42966k 32204+0io 0pf+0w

That works out to 4.5 seconds per each 50MB.

And another 2GB file with a block size of 4500:

80.720u 30.956s 2:34.85 72.1%   21+38537k 32075+0io 0pf+0w

CPU is almost identical, elapsed time is somewhat different, but the
machine is under a load so that's not going to mean a lot.

FileIO shows 32K read operations for both which is interesting because that
implies the reads were 64K blocks.  I don't know what that number is
tracking (OS reads to the disk, application reads to the disk cache, sys
calls???)

> However it was my
> intention that the last line could be made shorter - so assuming that
> this is the eof would be correct. You probably meant to write that this
> uudecode cannot handle that correctly and adds junk (which subsequently
> will get that block marked corrupt by the hash-algorithm)

The uuencode format includes a size value at the front of every line (M
means 45), and the file should not end until you see the "end" marker, and
all uuencode implementations must support a short last line, so you would
think that any uudecoding software would "work" if short lines were
included in the middle of the file, but with Usenet, you just never know.
Multipart uuencoded posts never noramally have a part which ends with a
shorter line. You can't help but wonder if some tool somewhere is going to
choke if you do something non-standard like that.

Maybe some decoder will see the line as a sign of a corrupted post and just
abort?

If we make xBin posting tools create non-standard uuencoded files, and one
tool somewhere starts rejectiong these posts, and then they find out that
since 4096 blocks are the standard for xBin that it's impossible to fix
this, the people that use this will start their own "xBin sucks" campaign.

It could be that every single uudecoding tool in use on Usenet today will
work correctly with multipart uuencode files with the last line of each
multipart being short.  But after 15 years of not doing that way, I really
don't want to risk it.  And though a non power-of-two block size seems odd,
I can't find any technical reason to belive it's important for anything.

> Damn, not a bit more tired now...

You must be excited about Christmas! :)

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62438
Author: Curt Welch
Date: Tue, 24 Dec 2002 09:11
22 lines
2005 bytes
jeff@litech.org (Jeffrey M. Vinocur) wrote:
> In article <20021223041127.986$6M_-_@newsreader.com>,
> Curt Welch <curt@kcwc.com> wrote:
> >
> >I'll give an outline here. (which now that I've finished writing it, I
> >see will take you a few hours to get through anyway :)).
>
> Can you stick this up on the web somewhere?  I don't really have
> the motivation to work through it now, but at some point I might,
> and it would be nice not to have to poke at Google.
>
> And it would keep you from having to repeat yourself all the
> time.

Ok, I put that article (as is in ascii) on http://xbin.org/

It's not much, but it's a start.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62439
Author: Rene
Date: Tue, 24 Dec 2002 15:10
134 lines
7355 bytes
curt@kcwc.com (Curt Welch) wrote:
> Ok, I put that article (as is in ascii) on http://xbin.org/
> It's not much, but it's a start.

To follow up on that, I've been thinking on some pseudo code for a xBin
decoder.

I've thinking it through and I think it works - with some caveats. First:
The pseudo code assumes tree structure has already been built up in memory.
Second, the tree at this point must have a power of two number of leaves.
(Ie a fully loaded, balanced binary tree) Third, when the pseudo code
fetches another hash out of the xBin header, it also pulls those that it
got before (for articles containing more than 1 block of data) which are
not saved a second time in the header.

Vocabulary used: (might as well define first about what I ramble :) )
This is all "very drafty". I use a vocabulary as I see fit. If there is a
better suited word that's been longer in use, please suggest / correct my
draft. After all, all this here screams for discussion, addenums,
corrections and suggestions.

article = one single usenet post
block = one atomic unit of (binary) data that gets hashed. Several blocks
per article are allowed, but one block may not be split over several
articles. Max length of a block not yet defined (working size as for now:
4500 bytes) block hash = hash of the block. AKA: "leave node's hash"
hash tree = memory structure in form of a binary tree that saves hashes on
each of its nodes root node = distinct node which is the root of the hash
tree. AKA: "root" file hash = hash saved within the root node. AKA: "root
hash" parent = node above a node. The root node has no parent, every other
node does. AKA: "parent node" sibling = "brother" node, node on the same
level whose hash toghether with this node in the correct order produces the
parent node's hash. AKA: "brother node", "sister node"

I think that suffices for the moment. Also note that each node within the
hash tree has one of these three states:
UNKNOWN - the hash value of this node is as of yet unvalidated
KNOWN - the hash value of this node is known AND validated.
NOTEXISTING - this node does not really exist - necessary for trees which
are not created using a power-of-two leave nodes. Still they need to be
traversed...

Here's the pseudo-code. I've used more or less a Java notation. It should
be readable for any C, C++ programmer though. It IS still pseudo code, it
won't compile. It has the limitations outlined above, so it is not
complete. You probably best copy & paste it into your favorite editor, so
the comments get color coded and the code gets more readable

=================
Pseudo code, assumes a tree structure has been built up in memory.

function process-xBin-article(Article a) {
if(a.getFileHash() != searchedFileHash) {
  throw_article_away;
  return;
}

foreach (block b in a) do {
  success = decode(block);
  if(!success) {
     complain("error decoding block" + b.num);
     next;                       // proceed to next foreach iteration
  }
  bhash = hash(block);                // get the hash from this block
  siblingHash = a.getNextHashFromHeader();  // get the sibling's hash
  actualNode = block.getNodeNr();  // set nodeptr to actual block nr.

  repeat {
    actualNode = actualNode.getParentNode(); // set nodeptr to parent
    if(siblingIsLeftOfMe)      // find out if we're "left" or "right"
      phash = hash(siblingHash + bhash);
    else                     // calculate the parent hash accordingly
      phash = hash(bhash + siblinghash);
    }
    if(actualNode.State == KNOWN) && (phash == actualNode.getHash()){
       // this parent's node has already been computed and the hashes
       // match. Good so far
      if(actualNode == rootNode) {
        say("block OK!);
        saveblock(file, block, offset);
        setallnodesknown();   // this will flag all nodes on the path
         // from this block's leave node up to the root node to known
                    // where they have formerly been in unknown state
        next;                    // proceed to next foreach iteration
      }
    if(actualNode.State == KNOWN) && (phash != actualNode.getHash()) {
      complain("error, hash does not match along the path!");
      next;                      // proceed to next foreach iteration
    }
    if(actualNode.State == UNKNOWN) {
      markthisnode();  // this saves this node's just calculated hash
                      // the value gets written if setallnodesknown()
                              // is called later. Otherwise discarded
    }
    siblingHash = a.getNextHashFromHeader();     // need next sibling
                          // to be able to calculate next parent node
    bhash = phash;          // new "block hash" is this parent's hash
  } // end repeat
} // end foreach block
} // end function
=================

For reference, here follows Kjetil T.'s ASCII so you can play that
pseudocode through in your mind:


                              l
                +----------------------------+
                j                            k
        +--------------+                +---------+
        |              |                |         |
        g              h                i         |
    +------+        +------+        +------+      |
    |      |        |      |        |      |      |
    a      b        c      d        e      f      |
  +--+    +--+    +--+    +--+    +--+    +--+    |
  |  |    |  |    |  |    |  |    |  |    |  |    |
  1  2    3  4    5  6    7  8    9 10   11  12  13

I think it works IF the tree has a power-of-two leaves and I can always
pull the sibling's hashes from the header (which is actually incorrect,
some of the values would need to be "cached" and not fetched from the
header again). You can "insert" parts out of order, so I'm assuming the
algorithm will be working in a multi-threading enviroment and out of order
insertion of blocks WILL happen. The tree operations should be synchronized
/ atomic though.

Curt, you may want to add the pseudo code to your site. If you can spare
the time, a colorization of the comments wouldn't do any bad...

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62440
Author: Rene
Date: Tue, 24 Dec 2002 15:18
23 lines
2154 bytes
Following up on my own message, sorry the vocabulary got reformated and I
didn't notice it before posting. So here follows the READABLE one :)

article = one single usenet post
block = one atomic unit of (binary) data that gets hashed. Several blocks
per article are allowed, but one block may not be split over several
articles. Max length of a block not yet defined (working size as for now:
4500 bytes)
block hash = hash of the block. AKA: "leave node's hash"
hash tree = memory structure in form of a binary tree that saves hashes
on each of its nodes
root node = distinct node which is the root of the hash tree. AKA: "root"
file hash = hash saved within the root node. AKA: "root hash"
parent = node above a node. The root node has no parent, every other node
does. AKA: "parent node"
sibling = "brother" node, node on the same level whose hash toghether with
this node in the correct order produces the parent node's hash. AKA:
"brother node", "sister node"

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62441
Author: Rene
Date: Tue, 24 Dec 2002 20:10
444 lines
22921 bytes
I hope you don't mind me concatenating the different messages for the sake
of "channeling" and focusing the discussion a bit.

curt@kcwc.com (Curt Welch) wrote:
> Testing it now - it took 5.4 seconds total to read the disk blocks and do
> the calculatlions for the 50MB file (compared to the 2.5 seconds to just
> calcuate the hash when all the disk blocks were in-core).  And the system
> I'm running it on is busy being a news transit box at the same time
> moving about 40 Mbits of traffic.

Ok, a bit hard to get good data when the box is doing lots of other things.
Then again I think we can leave the optimisations for now, especially
considering you convinced me, that line limit is more important.

> Here is a run against a 2GB file that's not likely to be cached using a
> hash block size of 4096:
> 81.207u 32.254s 3:02.80 62.0%   21+42966k 32204+0io 0pf+0w
> That works out to 4.5 seconds per each 50MB.
> And another 2GB file with a block size of 4500:
> 80.720u 30.956s 2:34.85 72.1%   21+38537k 32075+0io 0pf+0w

This statistic seems to say "bigger is better".

> FileIO shows 32K read operations for both which is interesting because
> that implies the reads were 64K blocks.  I don't know what that number is
> tracking (OS reads to the disk, application reads to the disk cache, sys
> calls???)

Interesting, might be the effect of a 64K read ahead. Most likely, the
behaviour will be different for another architecture.

> included in the middle of the file, but with Usenet, you just never know.
> Multipart uuencoded posts never noramally have a part which ends with a
> shorter line. You can't help but wonder if some tool somewhere is going
> to choke if you do something non-standard like that.

Ok, lets align to that then.

> > Damn, not a bit more tired now...
> You must be excited about Christmas! :)

Cursing at my insomnia rather... :)

----- next post -----
> If the newsreader was cross checking hash tree values between articles,
> that's true.  But because of the strength of hash, it's likely that many
> tools would not bother.  To verify an article, you can simply read it
> sequentially and decode the data and verify it in one pass.  You write
> the

Yes you can do that. Since CPU time is however much more cheaper than
bandwith it makes sense to pre-compute the header data. Its cheap to get
them and as an additional bonus, the newsreader can tell its user "I
currently see X valid parts of Y".

> Well, I take that back.  If you want to re-post parts of the file before
> you download all the parts, then you do need to save the hash tree values
> from the signature as you get them from each post.  So a more powerful
> tool that allowed you to repost segments from your "partial download"
> would need to save that - and as long as you are re-constructiong the
> hash tree and saving the data as you download each article, why not
> double check it and make the job of fake a few orders of magnatude
> further past "impossible".
> :)

Yep, if you want to re-use the tree you'd need to save it. Otherwise it can
be discarded. It can be discarded once the file is complete, since with one
intact file, you can recreate the tree fully.

> > Actually, the number of hashes needed sending (as header data) is a
> > function of the number of articles using your xbin. One article at
> > least needs the hashes up the path to the root, so thats a guaranteed
> > log2(N).

> In another article, I thought the answer was log2(N)+log2(M) where N is
> the number of blocks in the complete file and M is the number of blocks
> in each article.  But that's not right because if M == N then the number
> of hashes needed is 0.  if M is N/2 and M is a power of 2, then the
> number of hashes needed for each article is 1.

It gets quite complicated when you consider trees that are non-power of
two. All I'm sure right now is, that there will be a total of 2*N - 1
different hashes in the whole tree, no matter if the tree is power-of-two
or not.

If the tree is non-power of two, then you still create a tree the size of
the next larger power-of-two value and insert some "nonexistent" nodes
there. I've yet to formalize the rules of the creation of the tree. Target
is, to be able to create exactly one, well defined tree by use of only one
parameter: "number of blocks".

Depth of the tree will be log2(N), whereas N either is already a power of
two, or is being rounded up to be one. Depth is #levels - 1, so for N =
5..8, depth will be 3, #levels will be 4. There will be 2*N - 1 nodes with
hashes in total.

> > worst case is where the blocks overlap from the left-subtree into the
> > right-subtree (ie, crosses the "middle") because if it stays in its
> > subtree, then sooner or later up the path you reach a node you already
> > have, if you pass over to the right side however, you have a full
> > sub-tree to traverse upwards.
> For a file which has a power of two number of blocks, I think you are
> right and the worse case happens when the article has 2 blocks which
> overlaps the the center of the file.

Actually thinking about it: The worstcase is one article containing all
blocks, since that article will need to contain 2*N-1 hashes. (all of them)

Probably only of interest for small number of blocks. For large number of
blocks where there are several articles, I'll stay with my assumption that
the one article spanning blocks from the left-half to the right-half will
probably have the most hashes.

> Ah, I'm beginning to see it.  This is the same problem as counting the
> number of bits turned on in a binary number.

Well, the easy way of counting bits is simply
for(size of bit-array)
 if (bit-array &0x01 == 1) then count++
 bit-array >> 1;

There are clever ways though, AFAIK.

>Ah, but it's not even that simple because that gives you the correct value
>for the left side (which starts at the beginning of the file and is
>correctly aligned with the binary tree), but the number required for the
>right side depends on the alignment of the block with the binary tree for
>the entire file.

Its not as easy predictable as I thought. Consider the following n=8 tree:

       root
     /     \
    e       f
  /  \    /  \
 a   b   c   d
/ \ / \ / \ / \
1 2 3 4 5 6 7 8

Let's say one article has number 1 and 2. Then a is already defined, so we
only need b to get e. To reach the root, we additionally require f. So an
article having 1 and 2 needs to provide the hashes b and f.

If the article carries 2 and 3 however, we need 1, 4. Then a, b and e are
defined, we further need f. So thats 1,4,f.

If the article carries 4 and 5, we need 3,6, a and d.

So an article containing 2 blocks in this tree, can have 2, 3 or 4 hash
values (plus the root-hash) in the header. Position is important and I
don't see a pattern yet.

> I think some work is required here to get a better understanding of this
> because the worse case effects the max size of the Signature header, and
> that can limit the max possible file size which can be posted using this
> system while still keeping the header length to a size which various news
> servers can correctly deal with (which I think is around 1000 bytes).

Definitly. It must be established, what is allowed in the header. Then
based on this value we can calculate how many hashes that are. Then this
number directly defines with the max-block size, how large a file may
become.

>Let see, the hash and a few spaces takes up about 30 bytes per hash so
>that gives us around 32 hash values max in one header. If 2log2(N) is the
>worse

The hash is 160 bits large, that's 20 bytes (yielding 40 chars, not 20 like
I wrote before). So we best take those 20 bytes and encode them somewhat
(you use uuencode, as I've seen) maybe we should take another encoding to
gain more space. What alphabet is allowed in the header? Could we yEnc the
20 hash bytes in the header? Or not yEnc, because yEnc rotates the
byte-value, assuming there are less "00" that way. A hash value byte though
has an equal probability on every single of the 256 values.

> That's not as high as I'd like to see.

Yep, I think 2 GB at least should be reachable.

> One option I guess is to use a larger hash block size, but doubling the
> block size only doubles the max file size, and I'd like to see something
> that would allow a file size much much larger (100 GB) for example.

100GB is a bit much, considering widespread filesystems can't handle > 2GB
properly. But they slowly become obsoleted, so probably thinking about
really large files is not too wrong.

> The larger the parts the less hash values you need, but I'm not sure how
> to calcuate that.  Maybe the answer is if want to post a 100GB file you
> have to do it with 10MB posts. :)  That's not an unresonable requirement.
> Also, if the articles each hold an even power of 2 number of hash blocks,
> that reduces the worse case problems.  So many be the answer is that for
> really large files, the posting program has to be smart to avoid a header
> overflow problem.

Yep, having a worst case number of header-hashes would really help here.
I'm thinking a bit about it.

> And manybe I'm wrong about header length probelms.  For a header which
> the news serers don't have to deal with, and which the news reader is
> only going to get by doing a HEAD command, there may not be any news
> servers which care that there is a 2K header in the artcle?  Anyone know?

Don't know, you are the server guy :) I suspect however that headers get
indexed at servers. If I issue a XHEAD command in a newsgroup with
1'000'000 articles, I really doubt the server opens every single
file/article and gathers the headers toghether. I think headers are indexed
in a special database in advance, and if so, they probably DO have a size
constraint.

> I do.  I just iddn't know SHA-1 worked with an internal block size of 64
> bytes.
> I was also fairly sure that MD5 used an internal block size which matched
> the hash size of 16 bytes, but I could be wrong about that as well.

There is no difference between MD4, MD5 and SHA-1 what regards the internal
buffer or the padding, as far as I see. No wonder, that stuff comes largely
from the very same people.

> If you care, here's a really good description of the algorithm written
> for programmers to understand (it's in PDF):
> http://www.cs.utk.edu/~plank/plank/papers/CS-96-332.html

Thanks. That really is a very straight forward explanation.

> Once you get a basic understanding of it, it's really not as complex as
> it seems at first.

I knew it was basically a matrix / equotation system that's simply
overdefined. I didn't knew how to build up the matrices or calculate within
that specific number space.

> If you have any data files missing, then what you are left with is a set
> of simultanious equations with N unknowns where N is the number of files
> you are missing.  As long as you have N or more equations (i.e. par
> files), then you can solve using substitution for the unknown variables
> (files).

Yep, its like an equation with n lines and m variables. If m > n, then you
can't solve it. If you got m = n, then it has a solution. Now you go an
create parity files such as n > m. It is now "overdefined" and you can
delete any x lines until n = m and it is still solvable.

> And the use of hash trees for this same purpose (distribution of partial
> files over an unscure medium) has been defined for use with P2P I found.
> Search for "bitprint".

Searched and found. They are using it in the new Gnutella (P2P)-Protocol.
When I was discovering edonkey2000, that wasn't there yet. So I'd say ed2k
was faster. However I have no doubt that this has been in use before that.

----- next post -----
> Like I said in my other posts, there's what looks like a standard called
> bitprint which seems like it was defined for P2P use.  I can't tell if
> any P2P system is actually using it however.  But the name no doubt comes
> from

The new Gnutella protocol seems to use them. That's some odd-numbered
different client programs.

> They are no doubt trying to create a hash so unique that you can use it
> for thousands of years for every file createad and still have the odds of
> a collsion be near 0.

A bit "over the top" if you ask me.. but they certainly aren't going to
expand it to a bigger value soon...

> > Furthermore,
> > since the system uses a URL-scheme to easily select files of interest,
> > you can simply create a link like a http-link and users of this
> > p2p-software can just click and get that file hash added to their "to
> > download list" - which is a very clever and quite comfortable way.
> For xBin on usenet, the Message-ID of any article posted under the system
> acts as a unique identifier for that file.  (uniqe to 60 bits hash+file
> length) which I believe is large enough for this purpose).

Yep, thats right. I actually became aware of that later. Though I don't
know if it suffices. If I connect to a newsserver and request a message-id
(without delivering a groupname first) does it tell me in which group the
message was?

Ah stupid me, the header of the message in question should contain that
information. Then I can select that group and skim through the message
headers to seek the other parts of that article. Yes it works perfectly
already.

> For that mater, the announcement of the post should have the same xBin
> file signature in it's Message-ID so it could act like a part 0 post
> where the part 0 post was posted to the .d group and the data was posted
> to the .x group.  So then instead of having to put the Message-ID into
> the text, the

Hm I don't know about that... the newsreader may mix up the posts and
trying to decode parts out of the announcement. IF this should be made
possible, then it should get a well defined format, so there is no mixing
up articles with xBin signatures which are only "referrers" and articles
with xBin signatures which are truely xBin articles containing blocks.

> Or, maybe the idea of posting a set of files and listing the xBin ids of
> each file in the set in one article would be good as well.  A download
> tool could then have an option to extract all the xbin IDs from the text
> of the article and add them all to it's download list.

That's not far away from my system where you post the meta-information in a
0-post.

> > Yes, and this has prooven to work out well. However, if someone posts
> > the same file again BUT applies any transformation beforehand (he rar's
> > it with a different, never version) then the file he posts is of course
> > something different (bitwise compared) and it *will* get another file
> > hash.
> And some posters don't want people to know that the same file is being
> posted again, so they won't like the file-hash idea.  But it should be
> easy for them to both use xBin and get around that by finding ways to
> make minor changes to the file.  A 1 bit change anywhere gives it a new
> file-hash.

Yep, they can just repack it with an added .nfo or whatever. Shouldn't be
automated though. Makes reposting / filling a hell.

> It was suggested that the standard should allow for a random hash to be
> made up to allow people to that did not want their reposts to be tracked
> to still label their files with xBin but to get around the "fixed ID"
> issue they didn't no like.

No that defeats the basic idea of the hash.

> I think it would be wrong to allow that.  To keep things simpler, I think
> xBin should only allow a "real" hash.  There are plenty of ways to change
> the file or post it a different format (like ziped or rared etc) that
> would prevent it from being spoted for the people that care about that.

Yes I fully agree here. IF someone wants to make a distinct post, they
still can. They just need to do it by themselves.

> If you need to build and save the entire hash tree, I did by allocationg
> binary-tree nodes on the fly.  You could also di it in an array using
> positional encoding.  Or if you were worred about how much memory might
> be

For a reference algorithm, I think really building the tree with nodes
(which have pointers left, right, parent) will be the best solution. For a
real world implementation, one should probably use an array (heapsort is
the keyword here)

The array variant will be more efficient but less clear to someone trying
to understand how it works.

> available to you, could could calcaute the hash values in-core using only
> the small array as talked about above, but the write out every hash value
> as it is calcuated to a file.  The position of each hash value could be
> found in the file later by it's position.  I'd have to think a little
> more about that, but I'm sure it would work.

Memory is nothing nowadays... Sparing 2*N-1 times 20 bytes is bearable. You
don't want to run xBin on your wristwatch with embeddedLinux though.

> The other things that is "good" for usenet that is not commonly done is
> to try and equlize the size of all the articles in one multipart post.
> Articles tend to get filtered by size, and they tend to move faster or
> slower though Usenet based on their size.  If all the articles for one
> multipart set are the same size, it imporves the odds that they will all
> make it to the same servers, at about the same time which improves the
> odds they they will expire at about the same time, and expire in the same
> order hey were posted.

Ok, I see the problem. However if an xBin encoder stuffes, say, 5 blocks
per article, since a blocklength will be fixed, all the articles should be
more or less same sized (minus the last one, which will be shorter).

Not much different to what there is today. Of course the blocksize will
define the granularity with which a newsreader or its user will be able to
vary the article size.

> Today, the last article is very often substantically smaller.  These tend
> to move faster though usenet, and tend to make it to servers that the
> large articles might be filtered from.  And because they move faster,
> they can sometimes show up first even though they were posted last.  And
> then, because they showed up first, they expire first, leaving an
> incomplete set of "large" articles on the server and leaving users
> wondering why the small articles were "lost".

Well with xBin, even that small part will have the filehash-signature and
will therefor be picked up by an interested newsreader. The good part of
the hash tree's complexity is, that you can pick up articles in any order.

> > I'm currently working on a personal Java programm that fetches news for
> > me more or less autonomously. (Don't worry Curt, I haven't let it run
> > loose on your servers yet, I'm testing it with my local leafnode
> > installation ;-) )
> No problem.  You can't really do much harm if you are aren't posting.  If
 >there's anything I can do from my side to help with our code let me know.

At the moment I don't think I will ever make it to be able to post. Its
purpose mainly is to gain some understanding of the new Java IO subsystem
:) Second it should somewhen be able to fetch headers for me and process
them to a bit more easily readable format than what BNR2 is currently
giving me.

> > IF there is a specification (you already gave about most of it I think,
> > though some questions remain) I can programm something that tries to
> > understand that format. However I gladly let anyone step forward who
> > "really really wants to do it now" (tm).
> The only spec I have right now other than these posts is the code.  But
> if this to go somewhere, I'll be happy to work on a more formal
> definition and put it on my "nothining here yet" xbin.org web site.

I think I'll be implementing the xbin-system - the decoding part either
into that project or as a stand-alone proof of concept. I've already posted
some pseudo code for that. Its far from perfect but then again there are
some questions open still.

Before I start some real coding, some things need to be defined first:
- The exact building rule for the tree
- block size
- max allowed header data (which directly corresponds to blocksize)

> Well what you have to do is logically treat the one huge file as if it
> were split up into fixed sized segemets even though it is not.  Just like
> par got built into winrar to work better, the reed solomon codeing would
> have to get built into the download and posting tools to really work
> correctly with this.

If I understand you correctly, you're saying that will create "virtual
segements" ie segments that do not really exist, because the file will be
sent as one not segmented. But for the generation of PAR files, the
newsreader/poster looks at it as if it were. Is that right?

> But 8 bit Reed-Solomon coding is limited in the number of "files" it can
> protect.  It think that number is 128 or 256.  Or maybe it's actually
> that the number of data files + the number of par files you want post has
> to <= 256??

From your posted link, the m + n values (number of segments plus all part
files ever) may not be >= 2^wordsize. Using a wordsize of 16 bits, that's
already a safe value of 65535...

So, now off to church (it's traditional :-) )
Happy chritsmas !

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62442
Author: J.B. Moreno
Date: Tue, 24 Dec 2002 21:17
14 lines
1659 bytes
In article <20021224024147.474$RX@newsreader.com>,
 Curt Welch <curt@kcwc.com> wrote:

> It was suggested that the standard should allow for a random hash to be
> made up to allow people to that did not want their reposts to be tracked to
> still label their files with xBin but to get around the "fixed ID" issue
> they didn't no like.

You could get around that problem by including the file name as part of
the data to be hashed.

-- 
J.B. Moreno
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62443
Author: Curt Welch
Date: Wed, 25 Dec 2002 02:41
45 lines
3658 bytes
"J.B. Moreno" <planb@newsreaders.com> wrote:
> In article <20021224024147.474$RX@newsreader.com>,
>  Curt Welch <curt@kcwc.com> wrote:
>
> > It was suggested that the standard should allow for a random hash to be
> > made up to allow people to that did not want their reposts to be
> > tracked to still label their files with xBin but to get around the
> > "fixed ID" issue they didn't no like.
>
> You could get around that problem by including the file name as part of
> the data to be hashed.

Interesting.  But that in general is bad idea because we want people to be
able to find missing parts if the same file is posted again.  And file
names tend to be far too non-portable and are subject to change - many
times automatici\ally because the OS doesn't support the file name as
included in the original article.  So that will tend to break the hash for
one of the main reasons we wanted it in the first place.

But, kinda along the same idea, the hash algorithm could include some seed
data - like a 32 bit number, which got hashed along with the data in some
well defined way.  The value of that seed data could be included as the
first few base64 characters in the offical "file hash".  Most people would
agree to use a seed value of 0.  But any other seed value could be picked
at random by the poster which would in effect add "random data" to their
file, changing the hash.  But because the seed data was also included with
every post, the hash could still be used in the normal way to verify the
data and to prevent corruption.

So, people could in effect pick different hash functions just by changing
the seed data.

This I think would work, and would be much better than simply allowing
people to make up a random "hash value" to mark the post.  But I think it
would be better overall for Usenet to not include that feature.  The whole
point of posting a file to Usenet is so people can download it.  If there
are people out there looking for missing parts of a specific file, it would
be wrong to post that file to Usenet in a way that those who wanted it
couldn't use it.  The point of this xBin convention is to make Usenet work
better, not to make it hide files so people can't find them.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62444
Author: Curt Welch
Date: Wed, 25 Dec 2002 08:57
390 lines
20349 bytes
Rene <invalid@email.addr> wrote:
> > If the newsreader was cross checking hash tree values between articles,
> > that's true.  But because of the strength of hash, it's likely that
> > many tools would not bother.  To verify an article, you can simply read
> > it sequentially and decode the data and verify it in one pass.  You
> > write the
>
> Yes you can do that. Since CPU time is however much more cheaper than
> bandwith it makes sense to pre-compute the header data. Its cheap to get
> them and as an additional bonus, the newsreader can tell its user "I
> currently see X valid parts of Y".

Are you talking about downloading all the headers and collecting all the
Signature information first?  That won't tell you if the article is valid.
The data could be bogus or corrupted still.  You have to download the
entire article to know if you have a valid part.

Also, given only the signature data from one article, you don't have enough
information to calculate the hash, so you have no way of knowning if the
data from that article is valid.  If you have enough articles, you can try
to calculate the hash, but if you find an error (the hash ends up with the
wrong value, then you have no way of knowing which of the articles was
valud and which had the bogus data.  It turns into a complex problem that's
really just a waste of time to even try and write the code to solve.  Just
start downloading the aticles, thrown them away if you find they are bogus,
or else keep the data if you find they are good.

Now the one thing we could do is add a few more hash values in the
signature so it includes the hash values for the data in the article as
well, then you would be able to verify that the signature hash values are
all valid without the help of the data by combining them up to the root and
seeing that you got the correct final hash.  That would allow you with only
one header to know that all the hash values in that signature were valid.
So then you could download headers and build a partial hash tree (you can't
build it all because depending on the the size of the parts, you won't get
all the hash values - but you will have a good bit of the top of the hash
tree).

The nice thing about adding the extra hash values to the signature is that
looking at the Signature: header alone, you would be able to verify all
those values were valid without the help of any other data.  But for part
sizes around 1MB, you might have to add as many as 7 additional hash values
to a header which I fear might already be too large for very large posts.

I need to find out more about what the current news servers do with large
headers.  I know INN had limits in the 1000 byte range, but that might only
be for headers which the server was trying to use and not for "other"
headers.  And it had line length limits when you posted an article, but
it's easy enough to fold the header to stay under the line length limit if
that's the only issue.

> Yep, if you want to re-use the tree you'd need to save it. Otherwise it
> can be discarded. It can be discarded once the file is complete, since
> with one intact file, you can recreate the tree fully.

Yep.

> > > Actually, the number of hashes needed sending (as header data) is a
> > > function of the number of articles using your xbin. One article at
> > > least needs the hashes up the path to the root, so thats a guaranteed
> > > log2(N).
>
> > In another article, I thought the answer was log2(N)+log2(M) where N is
> > the number of blocks in the complete file and M is the number of blocks
> > in each article.  But that's not right because if M == N then the
> > number of hashes needed is 0.  if M is N/2 and M is a power of 2, then
> > the number of hashes needed for each article is 1.
>
> It gets quite complicated when you consider trees that are non-power of
> two. All I'm sure right now is, that there will be a total of 2*N - 1
> different hashes in the whole tree, no matter if the tree is power-of-two
> or not.

Yeah 2N-1 seems right.

> If the tree is non-power of two, then you still create a tree the size of
> the next larger power-of-two value and insert some "nonexistent" nodes
> there. I've yet to formalize the rules of the creation of the tree.
> Target is, to be able to create exactly one, well defined tree by use of
> only one parameter: "number of blocks".

It's very easy to write code to construct it.  Coming up with a formula to
calcaute things like the number of hash values in the signature is what I
have not seen a solution for yet.  Writing code to calcuate that is easy as
well.

> Depth of the tree will be log2(N), whereas N either is already a power of
> two, or is being rounded up to be one.

int(log2(N-1))) + 1 should do it where int() takes the interger value of
the number and throws away the fractional part.

Or, just by counting the number of bits using interger math in C:

   for (levels = 0; N > 0; levels++)
      N >>= 1;

> Actually thinking about it: The worstcase is one article containing all
> blocks, since that article will need to contain 2*N-1 hashes. (all of
> them)

Ah.  You are confused.  Or just not thinking like I am.  The signature does
not include the hash values for the blocks in the current article.  It only
includes the hash values for the data not in the current articles.

One post that includes all the data is the best case.  It has no hash
values in the signature.

> Probably only of interest for small number of blocks. For large number of
> blocks where there are several articles, I'll stay with my assumption
> that the one article spanning blocks from the left-half to the right-half
> will probably have the most hashes.
>
> > Ah, I'm beginning to see it.  This is the same problem as counting the
> > number of bits turned on in a binary number.
>
> Well, the easy way of counting bits is simply
> for(size of bit-array)
>  if (bit-array &0x01 == 1) then count++
>  bit-array >> 1;
>
> There are clever ways though, AFAIK.
>
> >Ah, but it's not even that simple because that gives you the correct
> >value for the left side (which starts at the beginning of the file and
> >is correctly aligned with the binary tree), but the number required for
> >the right side depends on the alignment of the block with the binary
> >tree for the entire file.
>
> Its not as easy predictable as I thought. Consider the following n=8
> tree:
>
>        root
>      /     \
>     e       f
>   /  \    /  \
>  a   b   c   d
> / \ / \ / \ / \
> 1 2 3 4 5 6 7 8
>
> Let's say one article has number 1 and 2. Then a is already defined, so
> we only need b to get e. To reach the root, we additionally require f. So
> an article having 1 and 2 needs to provide the hashes b and f.

Right. B is the hash for blocks 3 and 4, f covers 5 though 8.  So you have
hash values for those two sections of file which covers everything no in
the article.

> Position is important and I
> don't see a pattern yet.

Well if you have 8 in the article, then you need hash values which cover
blocks 1 to 7.  That's less than 8, so the first hash value will cover only
4 blocks, leaving 3 more blocks to cover, so the next hash value will cover
2 blocks, the last hash value will cover 1.

So those hash values are e, c, 7.  4+2+1 == 7 blocks covered by those 3
hash values.  Binary for 7 is 111 which has 3 bits turned on which the
number of hash values you need for the blocks to the left of the segment
included in the file.

For the blocks to the right, it's more complex because of the alignment.
The best case (I think) is the same problem as the blocks on the right,
which is the number of bits in the binary representation of the number of
blocks.  So if you have 8 blocks to the right, the best case will be 1 hash
value.  But if the alightment is not correct, then something more complex
happens.

> > I think some work is required here to get a better understanding of
> > this because the worse case effects the max size of the Signature
> > header, and that can limit the max possible file size which can be
> > posted using this system while still keeping the header length to a
> > size which various news servers can correctly deal with (which I think
> > is around 1000 bytes).
>
> Definitly. It must be established, what is allowed in the header. Then
> based on this value we can calculate how many hashes that are. Then this
> number directly defines with the max-block size, how large a file may
> become.
>
> >Let see, the hash and a few spaces takes up about 30 bytes per hash so
> >that gives us around 32 hash values max in one header. If 2log2(N) is
> >the worse
>
> The hash is 160 bits large, that's 20 bytes (yielding 40 chars, not 20
> like I wrote before). So we best take those 20 bytes and encode them
> somewhat (you use uuencode, as I've seen)

It's Mime Base64 actaully.  The hash is 27 bytes in base64.

> maybe we should take another
> encoding to gain more space. What alphabet is allowed in the header?

Well, It's the Message-ID that's the issue.  You can't do Base128 because
the charset is too limited and doing something non power-of-two seems not
worth the complexity for the little amount of space gained.

I used base64 in the Signature because that's what worked well in the
Message-ID and it allows you to use the same format in both.

> Could we yEnc the 20 hash bytes in the header? Or not yEnc, because yEnc
> rotates the byte-value, assuming there are less "00" that way. A hash
> value byte though has an equal probability on every single of the 256
> values.

You could, but it would get weird.  I think if there are news servers that
have problems with headers that long, the better option is to look at
multiple header solution than trying to compress the data into one header
and make it that much more unreadable.

> > That's not as high as I'd like to see.
>
> Yep, I think 2 GB at least should be reachable.
>
> > One option I guess is to use a larger hash block size, but doubling the
> > block size only doubles the max file size, and I'd like to see
> > something that would allow a file size much much larger (100 GB) for
> > example.
>
> 100GB is a bit much, considering widespread filesystems can't handle >
> 2GB properly. But they slowly become obsoleted, so probably thinking
> about really large files is not too wrong.

I guess the other issue is that the only thing keeping it from growing is
the header size issue, and if this became a wide spread standard and needed
2KB headers to work for the huge posts, then the servers that couldn't deal
with it would be under a lot of pressure to change.  So if the servers can
deal with the heaaders for the size files people are positing today, then
it might be ok to push the problem off onto the servers.  That would be
even more justifable if "most" servers today didn't have a problem with 2KB
header lines.  My server doesn't for example.  So that's one.

> Don't know, you are the server guy :) I suspect however that headers get
> indexed at servers. If I issue a XHEAD command in a newsgroup with
> 1'000'000 articles, I really doubt the server opens every single
> file/article and gathers the headers toghether. I think headers are
> indexed in a special database in advance, and if so, they probably DO
> have a size constraint.

Most servers special cate the XOVER headers, but none that I'm aware of
special case all the headers.  Some servers only allow you do do an XHDR on
headers in the special XOVER database.  Some allow you to do it on any
header, but if it's a non xover header, yes, it fetches the data from each
article.

But the articles are stored in special spools which are designed to be fast
to access so you don't have to do something like open a file for each
article.  You do have to seek an read at least one block for every header
however.

> > For xBin on usenet, the Message-ID of any article posted under the
> > system acts as a unique identifier for that file.  (uniqe to 60 bits
> > hash+file length) which I believe is large enough for this purpose).
>
> Yep, thats right. I actually became aware of that later. Though I don't
> know if it suffices. If I connect to a newsserver and request a
> message-id (without delivering a groupname first) does it tell me in
> which group the message was?

Yes.  You can do HEAD <message-id> to get the head of any article without
doing the group command first.  And then the Xref: line tells you the
groups and article numbers in those groups.

> Ah stupid me, the header of the message in question should contain that
> information. Then I can select that group and skim through the message
> headers to seek the other parts of that article. Yes it works perfectly
> already.

yes.  The only minor catch is that a few too many servers have "broken"
history files which are used to look up articles by Message-ID.  They have
problems of beeing to shourt for the server and Message-IDs will expire
from the history before the article expires from the server.  After that,
you can't find it by Message-ID even though you can find it by group and
article number still.

> > For that mater, the announcement of the post should have the same xBin
> > file signature in it's Message-ID so it could act like a part 0 post
> > where the part 0 post was posted to the .d group and the data was
> > posted to the .x group.  So then instead of having to put the
> > Message-ID into the text, the
>
> Hm I don't know about that... the newsreader may mix up the posts and
> trying to decode parts out of the announcement. IF this should be made
> possible, then it should get a well defined format, so there is no mixing
> up articles with xBin signatures which are only "referrers" and articles
> with xBin signatures which are truely xBin articles containing blocks.

Yeah, it should be well defined so there's no confusion.  A segment length
of 0 pretty much tells the newsreader that there's no useful data in there
however so that alone should be enough - as long as some download tool
doesn't core-dump when it sees that. :)

> > Or, maybe the idea of posting a set of files and listing the xBin ids
> > of each file in the set in one article would be good as well.  A
> > download tool could then have an option to extract all the xbin IDs
> > from the text of the article and add them all to it's download list.
>
> That's not far away from my system where you post the meta-information in
> a 0-post.

Yeah, it has a lot in common.  But the purpose is different - it's
informational only instead part of the "security system".

> Ok, I see the problem. However if an xBin encoder stuffes, say, 5 blocks
> per article, since a blocklength will be fixed, all the articles should
> be more or less same sized (minus the last one, which will be shorter).
>
> Not much different to what there is today. Of course the blocksize will
> define the granularity with which a newsreader or its user will be able
> to vary the article size.

Right, if you try to equalize the size of the articles, and do it right,
the last N will be 1 block shorter than the others (where N is a function
of the filesize and the article size you pick).  So the block size defines
how close in size the articles in a multipart post can be.

> Well with xBin, even that small part will have the filehash-signature and
> will therefor be picked up by an interested newsreader. The good part of
> the hash tree's complexity is, that you can pick up articles in any
> order.

And they don't even need to match the partsizes you had already downloaded.
So is someone posts the file in 20 parts, but you miss a few articles, and
two weeks later someone else posts the same file again, but with a
different part size, so it's 30 articles (and a different file name, and in
a different group), the download tool will sill be able to spot it
(assuming it's sanning the group it was posted to), and figure out which
parts it needs to download to fill in the gaps.

> Before I start some real coding, some things need to be defined first:
> - The exact building rule for the tree

What is in question?  Using SHA-1, you get a 20 byte hash.  To combine the
two hashes together, you put them in a 40 byte array with the first 20
bytes filled in with the hash for the lower block numbers.  You then hash
that 40 byte chunk of data.

For files which don't have a number of blocks which is a power of 2, you
will end up with hash values in the tree where it's matching pair doesn't
exist.  For those, you just take the hash value unchanged to the next
higher level.

> - block size

I'm using 4500 but it's a #define in my code so it's trivial to change to
anything else to experiment.

> - max allowed header data (which directly corresponds to blocksize)

Yeah, we need to look into that.

> If I understand you correctly, you're saying that will create "virtual
> segements" ie segments that do not really exist, because the file will be
> sent as one not segmented. But for the generation of PAR files, the
> newsreader/poster looks at it as if it were. Is that right?

Right.  The PAR file is specified as if large file had been split up
somehow.

The problem is that this might make it too hard for someone trying to find
and download PAR files by to figure out which PAR files they need.  But
mayne not.  If you generate them for the articles as they were posted, then
the subject just needs to point out that this is PAR1 for articles
0256-0512 etc.

> > But 8 bit Reed-Solomon coding is limited in the number of "files" it
> > can protect.  It think that number is 128 or 256.  Or maybe it's
> > actually that the number of data files + the number of par files you
> > want post has to <= 256??
>
> From your posted link, the m + n values (number of segments plus all part
> files ever) may not be >= 2^wordsize. Using a wordsize of 16 bits, that's
> already a safe value of 65535...

Well, to calcuate the missing data, you have to read all the other files in
the set.  If you have a 1,000 article set with 1 part missing and you
downloaded 1 par file, for the algorithm to figure out the missing data it
has to scan all 1000 articles.  And when you generate the par files, you
also have to scan the entire file and do the math.  It's probably better to
limit the range of the par files to something like 100 articles just to
prevent having to read so much data to calcuate the missing blocks.

> Happy chritsmas !

Same to you!

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62445
Author: Rene
Date: Wed, 25 Dec 2002 09:10
40 lines
2972 bytes
curt@kcwc.com (Curt Welch) wrote:
> So, people could in effect pick different hash functions just by changing
> the seed data.
> This I think would work, and would be much better than simply allowing
> people to make up a random "hash value" to mark the post.  But I think it
> would be better overall for Usenet to not include that feature.  The
> whole point of posting a file to Usenet is so people can download it.  If
> there are people out there looking for missing parts of a specific file,
> it would be wrong to post that file to Usenet in a way that those who
> wanted it couldn't use it.  The point of this xBin convention is to make
> Usenet work better, not to make it hide files so people can't find them.

It would work, yes. But adding a 32bit seed would allow for 2^32 different
hashes for the very same file.

However I really don't see why there should be such a "feature". Let xBin
just hash a file and send it reliably.

If a user wants to send a file under another hash he can:
- pack it
- unpack it and pack it with another packer
- unpack it and split it in two parts
- add / change some metadata (ID3 tag in a mp3, for example)
etc.

In short, xBin does not hinder anyone sending the same data "differently"
so that the hash will be different.

However for the very same input file, the hash should always be the same.
Otherwise that somewhat defeats the very purpose of using a hash here.

So personally I wouldn't provide any mechanism for changing the hash for
the same input data. If some user wants to have another hash, he can still
do that, but he needs to bring up the effort himself. If he doesn't want to
bring up that effort himself, it probably isn't really necessary anyhow.

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: Power-Post 2003 - requesting input from authorities..
#62447
Author: Bas Ruiter
Date: Wed, 25 Dec 2002 15:41
48 lines
2971 bytes
>> True-  I don't have MD5 algorithms handy, but if I can get a c++ class
>> or set of functions to do the job, I may be in.

If I recall correctly, there's a link to a MD5 lib on my website.

Alternatively (recommended) have a look at the cryptolib by
Tom St Denis. If you want to contact him, he's a regular in
sci.crypt.

>However, please note that crypto-experts are no longer considering MD5
>cryptographically safe.

The hash only has to remain useable for the duration the parts are
available on the sever.

To catch duplicates in NewsBin (assuming NB will then switch to use
MD5 for it's dupes file) it will have to stand up for longer. What
kind of time period is reasonable - a year? Two?

Still, MD5 is strong enough (on current hardware) to make it usuable
for this kind of time period, and probably a lot longer.

Basically, I don't think it matters much which current cryptohash we
use. The only reason you'd have to chose for one or the other is:

 1. Ease of implementation / Availability of sources
     If 'we' are going to implement something, others will have to
     follow. To prevent ppl using buggy versions, and the resulting
     havoc, some standard lib would have to be available.

 2. Compatability with other programs.
     If hashes are going to be used to identify files, you might
     consider using a hash thats used by one of those CRC Tools
     (WinVFD... or whateve its called). I know JPEGSherriff already
     has MD5 support.

     There's also the P2P programs... XoloX for example uses SHA-1.
     eDonkey (eMule) uses MD4?


Bas

Happy XMass everyone {{{group hug}}} and dont drink too much of the
bubbly :)


Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62448
Author: Rene
Date: Wed, 25 Dec 2002 16:35
431 lines
22693 bytes
curt@kcwc.com (Curt Welch) wrote:
> > Yes you can do that. Since CPU time is however much more cheaper than
> > bandwith it makes sense to pre-compute the header data. Its cheap to
> > get them and as an additional bonus, the newsreader can tell its user
> > "I currently see X valid parts of Y".
> Are you talking about downloading all the headers and collecting all the
> Signature information first?  That won't tell you if the article is
> valid. The data could be bogus or corrupted still.  You have to download
> the entire article to know if you have a valid part.

Yes that's right. But I need to download only ONE valid block. After that,
I have a partially hash tree in memory and can compare the headers with my
hash tree.

Let's take my N=8 tree example again. Suppose each article contains only
one block.

      root
     /     \
    e       f
  /  \    /  \
 a   b   c   d
/ \ / \ / \ / \
1 2 3 4 5 6 7 8

The root is known anyway. I download one article, lets say nr4. The
article's header contains the hashes 3, a, f. I decode the article,
calculate hash 4. Now I check hashes 3 and 4 result in b. a + b = e, e + f
= root. The block is accepted and validated. But as a side effect I now
have the validated hashes 3, 4, a, b, e, f.
Posts 1 and 2 will include hashes b and f in their header. I can check
these. Post 3 will include hashes 4, a, f in its header, I can check these.
Posts 5 to 8 will include hash e in its header.

The more valid parts I download, the more validated hashes I will have in
my tree.

Now this simply means that if an attacker wants to fake headers, he must
know the hashes in the tree nodes. But he can't do that unless he downloads
parts and calculates the valid tree by himself. So there can't be a
pro-active spamming a ng with bogus articles, because those can be spotted
from afar.

If there is a file being reposted later, a prospective attacker might have
a tree ready to create "good looking" headers. So this is just an added
"small" bonus.

If xBin becomes accepted and widely used, then an attacker creating
additional messages knows, that the only thing he can do is force a user to
download his parts and reject them. He can't cause file corruption any
longer. If then servers start to perform the checks themselves and discard
faulty messages, that attack becomes utterly useless.

Best way to stop xBin files is imho trying to kill the messages. And that,
to my understanding, will only be possible if you can get all server
operators to do that.

> Also, given only the signature data from one article, you don't have
> enough information to calculate the hash, so you have no way of knowning
> if the data from that article is valid.  If you have enough articles, you

If I have limited knowledge of the tree, by having at least one valid
block, I can decide if the header is fundamentally wrong or not.

> to solve.  Just start downloading the aticles, thrown them away if you
> find they are bogus, or else keep the data if you find they are good.

Its a small addition to that basic method. It is completely superfluous
until attackers start sending bogus articles for xBin files and your
newsreader doesn't want to download 5 bogus articles for every valid one.
Unless the attacker learns how to recreate the header-data, of course.

> Now the one thing we could do is add a few more hash values in the
> signature so it includes the hash values for the data in the article as
> well, then you would be able to verify that the signature hash values are

I don't think that's neccessary. In fact, that drops some of the security
of the system. If the current block's hash is included in the header, I can
malicously create a block of junk data. Hash it, and create hashes up just
to the root. (using my picture above, lets say I have made a bogus part 1
plus all hashes up to e) Now all that's left for me to do, is to find one
single hash f' so that my bogus e + f' are resulting in the root hash.

Only one hash collision to find. Since the hashes are 20bytes, thats 320
bits input giving one SHA-1 round (actually 512bits, but the padding is
known) yielding 160bits hash. Probably easy to find / create a collision.

Now *if* thats possible, then I can create articles with bogus blocks and
valid looking headers, even with hashes that add up correctly to the root,
but which are utterly corrupt.

If a newsreader picks up such a bogus-xBin part first, he won't be able to
complete the file because the bogus/real parts won't fit somewhen later due
to the newsreader having built up a fake tree.

> The nice thing about adding the extra hash values to the signature is
> that looking at the Signature: header alone, you would be able to verify
> all those values were valid without the help of any other data.  But for
> part sizes around 1MB, you might have to add as many as 7 additional hash
> values to a header which I fear might already be too large for very large
> posts.

Its no good idea either.

Oh just had a minor revelation. My pseudocode is more severly broken than I
thought first. Suppose the n=8 tree above. I one article spans blocks 1-4,
then the only hash in the header is f (and root). This means it is not
possible to process and validate the blocks within one article
sequencially. You need to decode all blocks first, then start validating
the tree hashes. In the example with 1-4, if one block has a bit error
(from decoding or whatever) then it can't be decided which is faulty and
which not, and all must be dropped. Again: Depending on position if some
blocks span the left-half of the tree and some the right-half, then not all
blocks need to be dropped. Some can still be validated.

Hm I can adapt to that, need to rework the pseudocode though...

> > If the tree is non-power of two, then you still create a tree the size
> > of the next larger power-of-two value and insert some "nonexistent"
> > nodes there. I've yet to formalize the rules of the creation of the
> > tree. Target is, to be able to create exactly one, well defined tree by
> > use of only one parameter: "number of blocks".
> It's very easy to write code to construct it.  Coming up with a formula
> to calcaute things like the number of hash values in the signature is
> what I have not seen a solution for yet.  Writing code to calcuate that
> is easy as well.

Yes writing the code for that is easy, but I'm not seeing an easy formula
either.

> > Depth of the tree will be log2(N), whereas N either is already a power
> > of two, or is being rounded up to be one.
> int(log2(N-1))) + 1 should do it where int() takes the interger value of
> the number and throws away the fractional part.

Right. Is int() used as a typecast here? Usually the function's called
trunc() or truncate()

> > Actually thinking about it: The worstcase is one article containing all
> > blocks, since that article will need to contain 2*N-1 hashes. (all of
> > them)
> Ah.  You are confused.  Or just not thinking like I am.  The signature
> does not include the hash values for the blocks in the current article.
> It only includes the hash values for the data not in the current
> articles.

You're right I was confused there or to be more exact, I forgot about that
"detail". The basic rule is: "Don't send any hash that can be computed,
only send the complement(s) needed to be able to reach the root."

> One post that includes all the data is the best case.  It has no hash
> values in the signature.

Well it has one, the root hash. Actually, is that necessary? I understand
it is there for a newsreader to search on using a "XHDR X-Bin-Signature"
however a newsreader could just as well skim through the message-id's no?

> > > Ah, I'm beginning to see it.  This is the same problem as counting
> > > the number of bits turned on in a binary number.
> > >Ah, but it's not even that simple because that gives you the correct
> > >value for the left side (which starts at the beginning of the file and
> > >is correctly aligned with the binary tree), but the number required
> > >for the right side depends on the alignment of the block with the
> > >binary tree for the entire file.
[..]
> Well if you have 8 in the article, then you need hash values which cover
> blocks 1 to 7.  That's less than 8, so the first hash value will cover
> only 4 blocks, leaving 3 more blocks to cover, so the next hash value
> will cover 2 blocks, the last hash value will cover 1.
> So those hash values are e, c, 7.  4+2+1 == 7 blocks covered by those 3
> hash values.  Binary for 7 is 111 which has 3 bits turned on which the
> number of hash values you need for the blocks to the left of the segment
> included in the file.

I think I have that solved now. Still it is no formula which gives the
worst case but it is a formula which gives you the number of hashes for any
given sequence of blocks.

To be given:
 N = number of blocks
 a,b = start and end of block sequence (inclusive)

calculate:
 P = next greater power-of-two from N (P = trunc(log2(N-1))) + 1 )
 X = 2*N-2 (number of total hashes in the tree minus the root)

First, check to see if sequence spans the middle:
IF(P/2 in (a,b) AND P/2+1 in (a,b)) THEN
// ok it does span the middle
  temp = a-1; // get value left of sequence
  r1 = bitcount(temp); // count number of 1 bits in temp
  temp = hashcover(b); // calculate hashcover of b (see below)
  temp = X - temp;     // subtract hashcover from total
  r2 = bitcount(temp); // count number of 1 bits
  RETURN r1+r2;  // result if sequence spans middle
ELSE
  IF(a < P/2) THEN   // is sequence in left half?
    left = a-1;
    right = P/2 - b);
  ELSE // sequence is in right half
    left = a - P/2+1;
    right = N - b;
  END;
  r1 = bitcount(left);
  r2 = bitcount(right);
  RETURN = r1+r2+1;
END

Hashcoverfunction (input integer N)
r = 0;
c = 0;
bitmask = 0x1;
REPEAT
 IF(N & bitmask != 0) THEN
   r = r + (2*bitmask-1);
   c = c + bitmask;
 END;
 bitmask << 1;
UNTIL(c = N);
RETURN r;

Discussion of this algorithm:

First what does Hashcover do? It calculates, how many hashes a sequence
from 1 to n are completely defined by those n leaves. What the algorithm
does: it breaks N into its power of two components and for each of those
(p) components it adds 2*p-1. Its actually just calculating the number of
hashes within each subtree according to the rule 2*num_of_nodes - 1 =
number of hashes total. However each power of two spans its own subtree.

Now how does the main algorithm work? Well we have to differ 2 situations.
(a) a sequence remains in one half of the tree or (b) the sequence spans
the middle.

For situation a, I must simply know how many hashes I need to be able to go
up to the child of the root node. Then I need to add 1 (this is the other
child of the root node) so I can calculate the root itself.

But how do I know how many hashes I will need ? Well we look first at the
left side of our sequence. As Curt has already stated, just take the number
of the block left of the sequence and count the number of 1 bits in that
value. That many hashes are needed. Now get the number of how many blocks
are to the right of our sequence up to the middle and do the very same. Add
those two values together and you have the number of hashes needed to reach
the child of the root. As already stated, add one to be able to calculate
the root itself.

Now the real beauty is, this even works for a incomplete tree (ie the right
side) Test it ! I had to do this several times until I was sure it works.

So basically : leftvalue is the number of blocks left of my sequence downto
1 or downto the middle and rightvalue is the number of blocks right of my
sequence up to N or the middle. Then just add bitcount of left- and
right-value plus one and you have it.

This leaves situation b, where the sequence crosses the middle. The left
side again is easy: Get the number of blocks from 1 to (a-1), which is just
a-1. Perform bitcount on a-1 and you know the number of hashes needed for
the left side. Now calculate the hashcover of our rightmost block (b)in the
sequence. This value now is simply the number of hashes we cover, when we
have the nodes 1 to b. And we truly have those, because the bitcount from 1
to (a-1) gives us the left hashes and the sequence (a,b) gives us the rest.
So what do we need to know from the right subtree past block b? Well
calculate how many hashes are left in total. Thats exactly X minus the
hashcount we just calculated. And now we're set, because you just take the
bitcount of that value...

> > The hash is 160 bits large, that's 20 bytes (yielding 40 chars, not 20
> > like I wrote before). So we best take those 20 bytes and encode them
> > somewhat (you use uuencode, as I've seen)
> It's Mime Base64 actaully.  The hash is 27 bytes in base64.

Ok my fault, you even wrote this in your first message. I can't distinguish
base64 from uuencode from sight.

> > Could we yEnc the 20 hash bytes in the header? Or not yEnc, because
> > yEnc rotates the byte-value, assuming there are less "00" that way. A
> > hash value byte though has an equal probability on every single of the
> > 256 values.
> You could, but it would get weird.  I think if there are news servers
> that have problems with headers that long, the better option is to look
> at multiple header solution than trying to compress the data into one
> header and make it that much more unreadable.

Yes that's a possibility. If an article contains blocks 7-12, then it
simply would have headers x-Bin-Signature[7-12] or something like this,
additionally to the Signature which defines what blocks are in this
article. Its way less slick but its a possibility, if header length is a
problem.

> I guess the other issue is that the only thing keeping it from growing is
> the header size issue, and if this became a wide spread standard and
> needed 2KB headers to work for the huge posts, then the servers that
> couldn't deal with it would be under a lot of pressure to change.  So if
> the servers can deal with the heaaders for the size files people are
> positing today, then it might be ok to push the problem off onto the
> servers.  That would be even more justifable if "most" servers today
> didn't have a problem with 2KB header lines.  My server doesn't for
> example.  So that's one.

Yes, if the majority of servers handle this, its ok to force the rest to
adapt. Though it is not very nice to those that need to change, of course.
There might even be mixed cases, ie where a server transports such articles
with long headers very easily, however if you do a XHDR X-Bin-Signature
over it, it returns the header truncated or not at all.

> > Don't know, you are the server guy :) I suspect however that headers
> > get indexed at servers. If I issue a XHEAD command in a newsgroup with
> > 1'000'000 articles, I really doubt the server opens every single
> > file/article and gathers the headers toghether. I think headers are
> > indexed in a special database in advance, and if so, they probably DO
> > have a size constraint.
> Most servers special cate the XOVER headers, but none that I'm aware of
> special case all the headers.  Some servers only allow you do do an XHDR
> on headers in the special XOVER database.  Some allow you to do it on any
> header, but if it's a non xover header, yes, it fetches the data from
> each article.
>
> But the articles are stored in special spools which are designed to be
> fast to access so you don't have to do something like open a file for
> each article.  You do have to seek an read at least one block for every
> header however.

Could put quite a stress on servers if the access pattern of half of its
users change. A server which does not allow XHDR X-Bin-Signature however
will be a nuisance to a newsreader, since then the newsreader needs to fall
back to reg-exping the message-id's to retrieve all the articles.

> yes.  The only minor catch is that a few too many servers have "broken"
> history files which are used to look up articles by Message-ID.  They
> have problems of beeing to shourt for the server and Message-IDs will
> expire from the history before the article expires from the server.
> After that, you can't find it by Message-ID even though you can find it
> by group and article number still.

Well, that's a broken server in that case. If that's quite common though,
then a newsreader does need to implement the "fallback" methode I wrote
above.

> Right, if you try to equalize the size of the articles, and do it right,
> the last N will be 1 block shorter than the others (where N is a function
> of the filesize and the article size you pick).  So the block size
> defines how close in size the articles in a multipart post can be.

So you are saying, from a server perspective, it is better to have 95 parts
of the same size and 5 parts slightly smaller than having 99 parts of the
same size and 1 part a lot smaller?

In any case, that's the job of the posting software to achieve. I'm
personally interested in writing a decoder. The encoder I leave to others.

> > Before I start some real coding, some things need to be defined first:
> > - The exact building rule for the tree
> What is in question?  Using SHA-1, you get a 20 byte hash.  To combine
> the two hashes together, you put them in a 40 byte array with the first
> 20 bytes filled in with the hash for the lower block numbers.  You then
> hash that 40 byte chunk of data.

No, the filling of the tree is clear to me. What is not clear is how skewed
trees are exactly built. That is, I know how I would do it, but that does
not necesarily comply with your idea.

> For files which don't have a number of blocks which is a power of 2, you
> will end up with hash values in the tree where it's matching pair doesn't
> exist.  For those, you just take the hash value unchanged to the next
> higher level.

Let me rephrase this: We start by "lining" up the block nodes. Any space
between the last node and the next power of two is filled by a
"nonexistant" node. Then the tree is build by creating parents of the
leaves until we have a root. Whenever a parent has only one real child (ie
a right side "nonexistant"-node) then the hash-value of the left node is
promoted up to this parent.

So having a tree with 9 nodes means that block 9's hash is actually saved
in the right child of the root node. Correct?

> > If I understand you correctly, you're saying that will create "virtual
> > segements" ie segments that do not really exist, because the file will
> > be sent as one not segmented. But for the generation of PAR files, the
> > newsreader/poster looks at it as if it were. Is that right?
> Right.  The PAR file is specified as if large file had been split up
> somehow.
>
> The problem is that this might make it too hard for someone trying to
> find and download PAR files by to figure out which PAR files they need.
> But mayne not.  If you generate them for the articles as they were
> posted, then the subject just needs to point out that this is PAR1 for
> articles 0256-0512 etc.

Well since using virtual segments, this throws out any manual intervention
anyhow. The newsreader getting blocks must implement this functionality. So
its the newsreaders job to localize the par's. Which means there must be a
machine-readable indicator.

I guess that means: Either par-technology (actually RS-coding) is part of
the xBin standard or it is taken care now that it can be implemented later.

> > > But 8 bit Reed-Solomon coding is limited in the number of "files" it
> > > can protect.  It think that number is 128 or 256.  Or maybe it's
> > > actually that the number of data files + the number of par files you
> > > want post has to <= 256??
> > From your posted link, the m + n values (number of segments plus all
> > part files ever) may not be >= 2^wordsize. Using a wordsize of 16 bits,
> > that's already a safe value of 65535...
>
> Well, to calcuate the missing data, you have to read all the other files
> in the set.  If you have a 1,000 article set with 1 part missing and you
> downloaded 1 par file, for the algorithm to figure out the missing data
> it has to scan all 1000 articles.  And when you generate the par files,
> you also have to scan the entire file and do the math.  It's probably
> better to limit the range of the par files to something like 100 articles
> just to prevent having to read so much data to calcuate the missing
> blocks.

You need to scan the entire file anyway (even if it has missing blocks)!
Well a newsreader downloading an xBin file should only create one file with
the final size (the size is in the Signature-header, so that's possible)
and fill in data as it recieves and validates them. If a newsreader wants
to create as many files as there are blocks, then that's their business. It
will have 1000 fopen's then, yes.

> > Happy chritsmas !
> Same to you!

Thanks, already over now though :)

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62450
Author: Rene
Date: Wed, 25 Dec 2002 23:34
23 lines
2024 bytes
> I think I have that solved now. Still it is no formula which gives the
> worst case but it is a formula which gives you the number of hashes for
> any given sequence of blocks.
>
> To be given:
>  N = number of blocks
>  a,b = start and end of block sequence (inclusive)
>
> calculate:
>  P = next greater power-of-two from N (P = trunc(log2(N-1))) + 1 )
>  X = 2*N-2 (number of total hashes in the tree minus the root)

[..]

Argh its wrong... It works perfectly for N=12 and has one off by one at
N=11, which I probably oversaw. N=13 getting 4 wrong...

Trying to find something better...

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62454
Author: Kjetil Torgrim Homme
Date: Fri, 27 Dec 2002 17:23
65 lines
3906 bytes
[Rene]:
>
>   Sorry, it was defaulted to on in the webinterface here... should
>   be off from now on unless I made a mistake.

it was still on.

>   > anyway, consider that a file on Usenet often is a gigabyte in size,
>   > and that each part seldom is larger than 500 kB.  that means 2000
>   > parts.  the hash of each part is 160 bytes.  if all hashes are
>   
>   Nope, an SHA-1 hash is 160bits long,

doh!

>   > included in all articles, you add 320 kB to each part, which clearly
>   
>   But there is no need to add them all over and over again. That's
>   the beauty of the hash'es one-way function. You post under the
>   file hash, this is the single most important identifier. Then for
>   example, send as the "0" part all the block-hashes, once only.

I don't want a scheme which relies on part 0.

>   More yet, since this information probably should be forced to be
>   in the first message posted, it becomes very hard to manipulate
>   and attack it.

you don't know what order articles will arrive in.

>   > the every other article attack was well spotted.  I think it suffices
>   > that part 3 includes the hash of part 4 and vice versa to solve it,
>   > though.
>   
>   Yes that would solve it. But it adds yet another hash to every
>   part.

not a problem.  that 1 GB file in 2000 500 kB chunks will have a hash
tree which is only 11 levels deep.  adding the neighbouring hash means
that each part needs to include 12 hashes, each 20 bytes large, for a
total of 240 bytes.  the overhead is negligible, but the robustness is
very much increased.

>   As I said, when you have all the leave-hashes, you can reconstruct
>   the file hash AND you can ensure that all parts are going to be
>   what they should be.

by including the tree hash, you don't need to download all the
articles to check that.

>   Just to be more precise, the "l" hash in the ASCII picture is a
>   different one than the one I would be constructing. The "l" hash
>   would really need the calculation of the tree to get. My version
>   simply takes all the leaves in order and creates the "root" or
>   file-hash out of that. No pairings, simply feed them into the hash
>   algorithm, one after another and get the resulting hash.

yes, I understand.  I just don't like it for this application, since
it relies on _all_ data being downloaded before doing any analysis on
its integrity.

-- 
Kjetil T.			|  read and make up your own mind
				|  http://www.cactus48.com/truth.html
Re: xBin (Power-Post 2003 - requesting input from authorities..)
#62455
Author: Kjetil Torgrim Homme
Date: Fri, 27 Dec 2002 17:37
48 lines
3429 bytes
[Curt Welch]:
>
>   Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
>   > the every other article attack was well spotted.  I think it suffices
>   > that part 3 includes the hash of part 4 and vice versa to solve it,
>   > though.
>   
>   You don't even need to do that with the tree hash.  If you check
>   part 3 and show it matches it's tree hash, and you do the same for
>   part 4, then you know they are both valid parts of the file with
>   tree hash "xyz", and you don't need to do anything else in the way
>   of cross checking other hash values.

well, yes, but that requires you to download the bogus part before
throwing it out.  by including the neighbour hash, there's a 50%
chance[1] the part you downloaded is the correct one, and that the
neighbour can be ignored by analysing the headers only.

[1] a properly written download tool should toss a coin to decide
    whether to download the even or odd numbered part first :-) if it
    always downloads the odd part first, the attacker will send bogus
    odd numbered parts.

>   So, once you decide to download the file with tree hash XYZ, then
>   every article the tool finds can be proven to be part of that file
>   without having to cross-check anything besides the tree-hash
>   value.

it can only prove that a subtree is self-consistent.

>   You could pick out hash values from the signatures and make sure
>   things matched, but that would just be a waste of time unless you
>   wanted a level of security about a million times higher than what
>   is needed for Usenet.

no, that's not the point -- I just want to spend a little CPU to avoid
wasting download time.

>   The only way the hash signature values could fail to match is if
>   someone was able to create a hash collision (or if you had bugs in
>   your code).

I'm not worried about hash collisions.

-- 
Kjetil T.			|  read and make up your own mind
				|  http://www.cactus48.com/truth.html
Page 1 of 9 • 404 total messages
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads