Article View: news.software.nntp
Article #62444Re: xBin (Power-Post 2003 - requesting input from authorities..)
From: Curt Welch
Date: Wed, 25 Dec 2002 08:57
Date: Wed, 25 Dec 2002 08:57
390 lines
20349 bytes
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/
Technical Details
Message-ID:
<20021225035755.305$XK@newsreader.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mailReferences:
<cdda0v4h6t52ov7abf1j0qkpo843itf4se@4ax.com> <cfka0vsbjdlbdmtv2gg8qnehok033qh5f1@4ax.com> <20021223041127.986$6M_-_@newsreader.com> <1rfzsoaacf.fsf@vingodur.ifi.uio.no> <20021223180543.105$Wn@newsreader.com> <20021223185652.700$BS@newsreader.com> <20021223203608.351$Qp@newsreader.com> <20021223223311.286$Mx@newsreader.com> <20021224034919.081$PY@newsreader.com> <20021224151028.847$pv@newsreader.com>Show Full Headers
Complete Article Headers
Message-ID: <20021225035755.305$XK@newsreader.com>
Subject: Re: xBin (Power-Post 2003 - requesting input from authorities..)
Date: Wed, 25 Dec 2002 08:57:55 +0000
From: curt@kcwc.com (Curt Welch)
References: <cdda0v4h6t52ov7abf1j0qkpo843itf4se@4ax.com> <cfka0vsbjdlbdmtv2gg8qnehok033qh5f1@4ax.com> <20021223041127.986$6M_-_@newsreader.com> <1rfzsoaacf.fsf@vingodur.ifi.uio.no> <20021223180543.105$Wn@newsreader.com> <20021223185652.700$BS@newsreader.com> <20021223203608.351$Qp@newsreader.com> <20021223223311.286$Mx@newsreader.com> <20021224034919.081$PY@newsreader.com> <20021224151028.847$pv@newsreader.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com
Newsgroups: news.software.nntp
X-Trace: NewsReader.Com z74xvnEu0v_6oi0fDBcm0dgih8c1/To1a2IX+Cm.TXFNlCbjm4
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5
%IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
X-Url: http://CurtWelch.Com/
User-Agent: NewsReader.Com
Lines: 389