🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
14 messages
14 total messages Started by Curt Welch Thu, 10 Oct 2002 05:40
Re: [FNTP] verifying that part reposts belong to a file - solution
#61267
Author: Curt Welch
Date: Thu, 10 Oct 2002 05:40
207 lines
11302 bytes
Bas Ruiter <lordsnow@home.nl> wrote:

[quote moved from below]
> I think someone else mentioned binary trees in the previous discussion?

Not binary trees, but hash trees.  It is bascially the exact same concept
as what you posted below just done slightly differently.  I thought it up
as a solution to matching the hash to the data and preventing forging.  It
seems others have seen the same solution.

> To quote:

So who are you quoting and from where?  Is this your work or someone else?

> > To save space in the 0/N file, you can use hash trees.

Yes, the use of hash trees is the same idea I came to for the same reason,
you can greatly reduce the number of hash values you send.

And I propose putting the final hash (the one at the top of the tree) into
the Message-ID.  We will use that as the unique identifier for all files
posted to Usenet in the format.

Doing it like this means that you can take any single article, and veryify
that the data in the article is not forged, and that it is part of the file
which produces the hash in the Message-Id.  When you have it all bundled
like that, news servers can check these files when they are posted, or (if
you have the CPU ressources) even in transit, and reject them if they are
invalid or corrupted.  This is a wonderful thing to be able to do and I
think it justifies the amount of extra data you will have to send in every
article.

> > This means the 0/N file requires only one hash.  This is at a cost of a
> > including a signature of up to 2lg(L/C) hashes on sequence of parts you
> > post, in order to be able to verify any sequence of parts as it comes
> > in without having to verify the whole file.

Yeah, same iade, but drop the 0/N file because the hash is also in every
post in the Message-ID. (you can send a 0/N file for other reasons if you
like but it's not needed or desired for the file hash).

> > I will try to explain trees by an example: imagine a 512-byte file
> > divided into 8 parts of 64 bytes, called P1, P2, P3, P4, P5, P6, P7,
> > P8.
> >
> > Let W1 = H(P1), W2 = H(P2), ... , W8 = H(P8). H is your hash function.
> > Let X1 = H(W1|W2), X2 = H(W3|W4), X3 = H(W5|W6), X4 = H(W7|W8).
> > Let Y1 = H(X1|X2), Y2 = H(X3|X4).
> > Let Z = H(Y1|Y2).
> >
> > Put Z in the 0/N file.

What is the | function in the above notation?  It's not an OR is it like it
is in C?  You would never want to use OR.  But XOR might work ok.

If it is concatenat, then that was my plan as well.  I talked about doing
it not with only 2 hashs, but with the same size block you used at the
first level.  I had picked 1K blocks out of thin air.  With a 128 bit (16
byte) hash like MD5, that gives you 64 hashes to combine together into a 1K
block, and hash down to one hash at each node of the tree.

But, to minimize the number of hashes you need to include in the hash tree
of each post, you should use a binary tree like you used, not a 64-way tree
like I built.  I binary tree will have more levels, but less hash values
total.

I'm only a bit concernted that if you only hash two values to get one, that
it won't be as secure as if you were to hash more at each level of the
tree.

> > Suppose I wanted to send bytes 320-383 (P6). I'd post P6 and as a
> > signature W5, X4, and Y1. The receiver calculates W6 from P6, then from
> > W5 and W6 gets X3, then from X3 and X4 gets Y2, then from Y1 and Y2
> > gets Z. By comparing this Z with the Z in the 0/N file he knows he's
> > got the right P6, without needing to know any other part of the file.
> > But W5, X4, Y1 and Z do not allow an attacker to forge any part of the
> > file, assuming H is a cryptographically strong hash function.

And assuming that taking the hash of the hash values does not weaken the
security which it very well may.  I'd like to get advice on that from
people that know more about it than I do.

> > Now suppose instead I wanted to send bytes 256-447 (P5-P7). I post P5,
> > P6, P7; and as a signature on these three parts I post W8 and Y1. From
> > this the receiver can compute Z and match against the 0/N file. As you
> > see, I don't have to sign each 64-byte part separately, I can sign a
> > sequence of 64-byte parts and I just have to provide enough to complete
> > the tree down to Z. In no case will I need to post more than 4 hashes
> > to sign any sequence (for a 64MB file divided into 64 byte parts, this
> > figure goes up to only 40).

> I been kinda busy the last few days so not completely reading the posts
> - just skimming to keep up.
>
> But the above solution looks nice.
>
> It has the following implications:
>
> 1. a chunk size would have to be agreed upon (P above)

Yes.

> 2. reposts would always start at a boundary that's a multiple of P

> 3. an article can contain a repost that's a multiple of P.

I don't know why you say "repost".  I'm thinking of this for all binary
posts on usenet, not just "reposts".  And yes, all the segments would
have to begin and end on these hash chunk boundries.  So the amount
of data in each file will have to be an integer multiple of the
chunk size.

This means the chunk size should not be very large so when you split a
file up, you can still attempt to make all the parts somewhat close to
each other.  I'm still thinking something in the 1K size is about
right.

> 4. It probably means more data than needed is posted for a fill.
>    The waste would at most be 0.5 x P per article.

0.5 * P what?  I don't get what you are saying.  Oh, wait, I do get
what you are saying.  If you want to post some byte range, but are forced
to post more to make it align to the chunk size of P then you waste data,
but the waste can be up to 2P-2 bytes, not .5 P right?  But you don't need
to waste anything.  You just split it on the P boundries to start with.

This systems should be used for all posts, not just "reposts".  When
someone posts data and markes it with hash value X, you need a way to know
that they are telling the truth and that data really did come from a file
with that hash value and that it's not a fake, or an accidential
corruption.  So you make everyone label all files posted with this hash
value system, and they sign each post with the hash tree values as required
to prove to the rest of Usenet that the hash label they put on the post is
valid.

> The trick is to find a good size for P, so hash calculations
> are kept to a minimum, and so waste is also kept to a minimum.
> (read, minimum = acceptable levels)

There will be no waste to worry about if all posts are done like this.  But
you want the granularity low enough so all the posts come out to be about
the same size when the article size is chosen (which helps the articles
move at the same speed though usenet so they show up closer to the same
time and expire closer to the same time on servers).

The larger the P size, the smaller the hash tree, but doubling the size of
P only cuts the number of hash values by 1, so I suspect it's not going to
make much difference.

Ok, so to test a value, if P is 1KB, and we want to post a 128GB file in
chunks of 128KB each (trying to create a worse case example of a huge file
and small part size)... (this is a 1 million part post - that would be fun
to see).

The file is 2^37 bytes long.  1K is 2^10, so that gives us 2^27 P blocks in
the entire file so the hash tree is 27 hashes deep.  But 128KB articles
span 128 P blocks, which is 2^7 so that removes 7 levels of hash values
from what you need to include in each article, so that means you only need
to add a 20 hash values to each file to serve as the signature (well 19 I
guess because #20 is the file hash which you find in the message-id).  And
for MD5, that's only 300 bytes of extra signature data needed to for each
128K post (or 600 bytes if it's done in ascii hex).  Hell, you can get away
with putting that in the header.  That's very very workable from my point
of view.

For a more typical example, if you posted a 32MB file in 512K chunks (64
parts), the hash tree would be 15 deep for the file, but each post spans 8
levels of the tree so you only need 6 hash values included in each post
which is only 192 bytes of hex data to add to each header as the digital
signature for each post.  Cool.

Plus, if you can put the hash signature in the header, then the body can be
straight yEnc or uuencode and it becomes completely backward compatibale
with current yEnc multipart posts.  I was concerned because when I thought
the signature would be too large to fit in the header, there was no easy
way to put it in the body without breaking current decoding tools. ... But
now that I think about it, if the body was yEnc, and the signature was
something custom that just looked like text to all other decoders, then it
wouldn't cause problems adding it to the end of the post.  Yenc has an end
of data marker even for multpart posts so you can have text at the end of
each part (or article footers/signatures) without causing problems for yEnc
decoders.

But, with the hash signature system, we have something much better than the
crc used by yEnc so we can in the end just throw out yEnc, put all the file
info into the header, and make the body pure binary or something close to
it (like Content-Transfer-Encoding: X-UnidataEncoding which is a much
simpler and beter system than yEnc from my point of view).

And, since this hash system forces all file segments to be aligned on
blocks of size P (1K in my example), if we put the offset and segment size
in the message-Id like we have talked about, we can now do it in units of
size P - i.e. 1K blocks - which cuts out 10 bits from each of those numbers
to help (a little bit) make up for how large the Message-Id is going to get
for these things.

I think these ideas are just getting better and better.  I'm beginning to
feel the need to write proof of concept code....

>  Bas Ruiter

Cool stuff.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] verifying that part reposts belong to a file - solution
#61276
Author: Bas Ruiter
Date: Thu, 10 Oct 2002 15:01
108 lines
5121 bytes
> [quote moved from below]
> > I think someone else mentioned binary trees in the previous discussion?
> 
> Not binary trees, but hash trees.

Hash trees, I meant, of course.

> So who are you quoting and from where?  Is this your work or someone else?

It's not mine, but someone elses. Look in sci.crypt. I put a similar
thread there, and Daniel Mehkeri (dmehkeri_AT_victoria_DOT_swi_DOT_com)
came up with this answer.

sci.crypt seemed a good place to ask with regards to this kinda thing.

> And I propose putting the final hash (the one at the top of the tree) into
> the Message-ID.  We will use that as the unique identifier for all files
> posted to Usenet in the format.

Yes, I was thikning that as well. Just didn't mention it as it wasn't
relevant to the idea.

> > > Let W1 = H(P1), W2 = H(P2), ... , W8 = H(P8). H is your hash function.
> > > Let X1 = H(W1|W2), X2 = H(W3|W4), X3 = H(W5|W6), X4 = H(W7|W8).
> > > Let Y1 = H(X1|X2), Y2 = H(X3|X4).
> > > Let Z = H(Y1|Y2).
> > >
> > > Put Z in the 0/N file.
> 
> What is the | function in the above notation?  It's not an OR is it like it
> is in C?  You would never want to use OR.  But XOR might work ok.

No idea. I assumed it was the OR function tho. Not that I think it
matters much, OR, XOR, or concatenat. I assume you say "not an OR is it"
because you consider OR weak? I thought the subsequent hashing would
prevent any succesfull tinkering with the OR.

> I'm only a bit concernted that if you only hash two values to get one, that
> it won't be as secure as if you were to hash more at each level of the
> tree.

The overall strenght of the idea (to positively identify a (bogus) part
AND be tamper-proof) depends on the strenght of the hash, no? It's still
impossible to construct a MD5 hash collision, so nothing that's done
is going to pass.

> And assuming that taking the hash of the hash values does not weaken the
> security which it very well may.  I'd like to get advice on that from
> people that know more about it than I do.

The thread in sci.crypt is only a day or so old. Ask away :)

> > 3. an article can contain a repost that's a multiple of P.
> 
> I don't know why you say "repost".  I'm thinking of this for all binary
> posts on usenet, not just "reposts".

Ah, right. Just my frame of mind, as "we" set out to solve the repost /
completeness problem.

> each other.  I'm still thinking something in the 1K size is about
> right.

Wouldn't that mean a HUGE amount of hashes would be generated for
any file of non-trivial size?

> 0.5 * P what?  I don't get what you are saying.  Oh, wait, I do get
> what you are saying.  If you want to post some byte range, but are forced
> to post more to make it align to the chunk size of P then you waste data,
> but the waste can be up to 2P-2 bytes, not .5 P right?  But you don't need
> to waste anything.  You just split it on the P boundries to start with.

The 0.5 * P I mentioned was the average waste per artcile, not the
maximum.

It was also wrong. I was thinking HD fragmentation & waste, & forgot
that with HD's the waste is always ONLY at the end of a cluster.

So you're right - waste is max 2P-2, and averages P-1.

You also mentioned that original posting is to be done using the same
chunk size, so reposts will always align thus cutting down on possible
waste. Not that it really matters, I suppose, but can you relly assume
that the recipient is missing a piece of his file that starts at a
boundary?

> I think these ideas are just getting better and better.  I'm beginning to
> feel the need to write proof of concept code....

:)

> Cool stuff.

Yes indeed.

To quote Hannibal, "I love it when a plan comes together"


 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: [FNTP] verifying that part reposts belong to a file - solution
#61284
Author: Brian Truitt
Date: Thu, 10 Oct 2002 18:52
96 lines
5439 bytes
"Curt Welch" <curt@kcwc.com> wrote in message
news:20021010014047.034$XV@newsreader.com...
> I'm only a bit concernted that if you only hash two values to get one,
that
> it won't be as secure as if you were to hash more at each level of the
> tree.

I think you wouldn't have a problem, as long as the hash function itself was
strong. If I take 2 hashes, put them together somehow, and put it thru the
hash function to get a new hash, if you have one original hash and the final
hash you would still have to brute force thru all the possible values of the
second hash and see if it results in the final hash. If not, the hashing
function is flawed to begin with for security use and should be thrown away.

> I don't know why you say "repost".  I'm thinking of this for all binary
> posts on usenet, not just "reposts".  And yes, all the segments would
> have to begin and end on these hash chunk boundries.  So the amount
> of data in each file will have to be an integer multiple of the
> chunk size.
>
> This means the chunk size should not be very large so when you split a
> file up, you can still attempt to make all the parts somewhat close to
> each other.  I'm still thinking something in the 1K size is about
> right.
>

I disagree with this. Picking a small chunk size is going to create a huge
amount of calculation for each part you post. Simplist case, your post size
is 512K, your chunk size is 256K. You calculate hash A and B on the 2
chunks, then calculate hash C from the somehow combined hashes A and B. Hash
C would be your top hash. Hash C is NOT the same as taking a hash of the
entire 512K part. So now we reduce the chunk size to 128K. Now we do a hash
on 4 chunks, then 2 combine hashes, then a final combine hash. So now you
have 7 hashes per post to work out. If you take this down to 64 byte chunks,
you now have to calculate 16383 hashes per 512k post. At 1024 byte chunks,
you still have 1023 hashes to grind thru before you get the top hash for
that post.

I think that the chunk size should be the lowest part size you should expect
someone to post at. Make it 64K, binaries shouldn't ever be split into
pieces smaller than this, and at 512k part sizes, it only requires 8 hash
calculations per post.

[snip]
> > The trick is to find a good size for P, so hash calculations
> > are kept to a minimum, and so waste is also kept to a minimum.
> > (read, minimum = acceptable levels)
>
> There will be no waste to worry about if all posts are done like this.
But
> you want the granularity low enough so all the posts come out to be about
> the same size when the article size is chosen (which helps the articles
> move at the same speed though usenet so they show up closer to the same
> time and expire closer to the same time on servers).
>
> The larger the P size, the smaller the hash tree, but doubling the size of
> P only cuts the number of hash values by 1, so I suspect it's not going to
> make much difference.
>
> Ok, so to test a value, if P is 1KB, and we want to post a 128GB file in
> chunks of 128KB each (trying to create a worse case example of a huge file
> and small part size)... (this is a 1 million part post - that would be fun
> to see).
>
> The file is 2^37 bytes long.  1K is 2^10, so that gives us 2^27 P blocks
in

This would be 2^28-1 hashes you would have to calculate. If you can
calculate 10K hashes a second, this will take you 7 hours of math to start
posting. It'll solve the bandwidth problems nicely :D

[snip]
> And, since this hash system forces all file segments to be aligned on
> blocks of size P (1K in my example), if we put the offset and segment size
> in the message-Id like we have talked about, we can now do it in units of
> size P - i.e. 1K blocks - which cuts out 10 bits from each of those
numbers
> to help (a little bit) make up for how large the Message-Id is going to
get
> for these things.

This is a good idea, the offset and size can be in counts of P segments,
which will reduce the message-id be a bit. Making P=64K strips 2 bytes off
the offset and another 2 off the size.

>
> I think these ideas are just getting better and better.  I'm beginning to
> feel the need to write proof of concept code....

I started playing around with this too, which is how I noticed how many
actual hashes you'd have to calculate per post.



Re: [FNTP] verifying that part reposts belong to a file - solution
#61285
Author: Curt Welch
Date: Thu, 10 Oct 2002 19:00
200 lines
10124 bytes
Bas Ruiter <lordsnow@home.nl> wrote:
> > [quote moved from below]
> > > I think someone else mentioned binary trees in the previous
> > > discussion?
> >
> > Not binary trees, but hash trees.
>
> Hash trees, I meant, of course.
>
> > So who are you quoting and from where?  Is this your work or someone
> > else?
>
> It's not mine, but someone elses. Look in sci.crypt. I put a similar
> thread there, and Daniel Mehkeri (dmehkeri_AT_victoria_DOT_swi_DOT_com)
> came up with this answer.

Great.

> sci.crypt seemed a good place to ask with regards to this kinda thing.

I'll check it out.  I too was going to go there to ask.

> > And I propose putting the final hash (the one at the top of the tree)
> > into the Message-ID.  We will use that as the unique identifier for all
> > files posted to Usenet in the format.
>
> Yes, I was thikning that as well. Just didn't mention it as it wasn't
> relevant to the idea.
>
> > > > Let W1 = H(P1), W2 = H(P2), ... , W8 = H(P8). H is your hash
> > > > function. Let X1 = H(W1|W2), X2 = H(W3|W4), X3 = H(W5|W6), X4 =
> > > > H(W7|W8). Let Y1 = H(X1|X2), Y2 = H(X3|X4).
> > > > Let Z = H(Y1|Y2).
> > > >
> > > > Put Z in the 0/N file.
> >
> > What is the | function in the above notation?  It's not an OR is it
> > like it is in C?  You would never want to use OR.  But XOR might work
> > ok.
>
> No idea. I assumed it was the OR function tho. Not that I think it
> matters much, OR, XOR, or concatenat. I assume you say "not an OR is it"
> because you consider OR weak?

Well, it throws out information which is normally not a good thing for
these types of functions.

If hash A is 1011 (a four bit hash), and hash B is 0101, then the OR
of the two values is 1111.  There are a TON of possible hash values
that can OR together to get 1111.  If you then take the hash of 1111,
you will get something that looks real, but the trugh is that a huge
number of different blocks will hash to that same value, making it
very weak.

An OR will increas the bit density which means that more bits are on
than off after you OR two hash values which will have an even distribution
of 1 and 0 bits.

Yeah, he could not have meant OR. If he did, he was crazy or there's
somehting else more advanced going on here that I don't understand.

> I thought the subsequent hashing would
> prevent any succesfull tinkering with the OR.

Sure, but the OR weakens the strengh of the hash from X bits to something
a lot less for no good reason.  The result of the OR function will end
up with an uneven distribution of hash values.  If you look at millions
of different blocks and there hash values, you would expect a good hash
function to produce a fairly even distribution (i.e. random like) over
the hash values.  If you OR the two block hash values together, you
end up piling a lot of those two block hash values into the values
with more bits on.  So there will be a lot of collisions to the value
with all bits turned on and very few to the value with all bits 0.

The fact that you then map that into something valid with the hash
doesn't hide that lopsidded distribution you created.

> > I'm only a bit concernted that if you only hash two values to get one,
> > that it won't be as secure as if you were to hash more at each level of
> > the tree.
>
> The overall strenght of the idea (to positively identify a (bogus) part
> AND be tamper-proof) depends on the strenght of the hash, no? It's still
> impossible to construct a MD5 hash collision, so nothing that's done
> is going to pass.

An MD5 hash of a single byte file is trivial to reverse.

If you created a new type of MD5 hash where you first break the file into
128 bit (15 byte) chunks, and OR together all those 128 bit values, and
then take the MD5 of that, 99.999% of all files will have an OR value with
all bits set, so 99.999% of all files will have the same hash value.  Doing
that would reduce the effective number of bits in the hash from 128 down to
1.

> > And assuming that taking the hash of the hash values does not weaken
> > the security which it very well may.  I'd like to get advice on that
> > from people that know more about it than I do.
>
> The thread in sci.crypt is only a day or so old. Ask away :)

Will do.

> > > 3. an article can contain a repost that's a multiple of P.
> >
> > I don't know why you say "repost".  I'm thinking of this for all binary
> > posts on usenet, not just "reposts".
>
> Ah, right. Just my frame of mind, as "we" set out to solve the repost /
> completeness problem.
>
> > each other.  I'm still thinking something in the 1K size is about
> > right.
>
> Wouldn't that mean a HUGE amount of hashes would be generated for
> any file of non-trivial size?

Calculating a hash of a file no matter how you do it creates a new hash
value for every 16 bytes you processes.  So it's not an issue of
processing.  But it is an issue of how many hashes you might have to save
with this hash tree.

To calculate the final hash value, you only need to save one hash per level
in the tree as you make a pass over the file, so the number you need in
memory at once is only log2(P) where P is the number of blocks in your
file.  And that's very small. (10 for a 1MB file with a 1KB block size).
(20 for a 1GB file, etc).

But, to post these files along with their hash signatures, you have to make
one pass over the entire file and generate the hash tree, before you start
posting.  So the size of that hash tree is an issue.

But even with 1KB blocks, it's not out-of-control large.  A 1GB file for
example would have a hash tree with 2^21 - 1 hash values which is bascially
2 million hash values, or with MD5,  33MB of data for the total tree.

But, depending on the part size you post in, you don't have to save most of
that tree.  If you post articles of 128K each, you get to strip off the
bottom 7 levels of that tree, which gets the size that you have to save
down to, 2^(21-7)-1 hash values, or 255KB of data.  And that fits easilly
into memory and takes up a trivial amount of disk space when you are alreay
working with a 1GB file.

However, I'm alreay writing some test code and I've already decided 4KB
blocks are probably better and even larger than that might be better still.

It reduces the granularity of the sizes of your posts (all posts would have
to have a multiple of 4KB of data in each post), but it keeps these trees
smaller and it means that nothing smaller than 4KB per article could ever
be posted in this format.  You can post files smaller than that - the last
block can be smaller and it doesn't need to be padded, but for someone
posting a very large multipart post, this hash block size limits the
smallest possible post, which might help some abuse as well if it's
impossible to post 10,000 post with 10 bytes each in them.

> You also mentioned that original posting is to be done using the same
> chunk size, so reposts will always align thus cutting down on possible
> waste. Not that it really matters, I suppose, but can you relly assume
> that the recipient is missing a piece of his file that starts at a
> boundary?

If he received the file using an old-style system and was missing
something, then you are right, you can't assume that.  A new-style post
would require posting extra data to fill it out to these block sizes.  But
if it was received in the old style system, then it's hard (close to
impossible) for the download tool to know that the old file matches the
repost, so it's not very likely in my mind that anyone is going to try to
patch problems with old-style posts using this new binary format.  And it's
also very hard to correctly know how to post the refill.  You would have to
write a tool which looked at an old-stype post, like yEnc, and then
claculate what has to be posted in this new style to correctly fill the
hole.  Maybe for backward compatibility reasons, that would be done.  We
will see as we look more at this.

> > I think these ideas are just getting better and better.  I'm beginning
> > to feel the need to write proof of concept code....
>
> :)
>
> > Cool stuff.
>
> Yes indeed.
>
> To quote Hannibal, "I love it when a plan comes together"

Yes, it's neat.  I think me might actually be on to something very useful
here.

It will however, only cause usenet volume to shoot higher because it will
make posting and downloading binary files, and will make running partial
binary servers very easy.  And all that will only encourage volume to grow
faster.

BTW, I just grabbed xbin.org as a name for this usenet binary posting
convention.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] verifying that part reposts belong to a file - solution
#61289
Author: Curt Welch
Date: Thu, 10 Oct 2002 20:04
149 lines
8813 bytes
"Brian Truitt" <btruitt@rcn.com> wrote:
> "Curt Welch" <curt@kcwc.com> wrote in message
> news:20021010014047.034$XV@newsreader.com...
> > I'm only a bit concernted that if you only hash two values to get one,
> that
> > it won't be as secure as if you were to hash more at each level of the
> > tree.
>
> I think you wouldn't have a problem, as long as the hash function itself
> was strong. If I take 2 hashes, put them together somehow, and put it
> thru the hash function to get a new hash, if you have one original hash
> and the final hash you would still have to brute force thru all the
> possible values of the second hash and see if it results in the final
> hash. If not, the hashing function is flawed to begin with for security
> use and should be thrown away.

Yeah, I think you are right.  Some adcise from hash "experts" would be
good still.

> > I'm still thinking something in the 1K size is about right.

> I disagree with this. Picking a small chunk size is going to create a
> huge amount of calculation for each part you post. Simplist case, your
> post size is 512K, your chunk size is 256K. You calculate hash A and B on
> the 2 chunks, then calculate hash C from the somehow combined hashes A
> and B. Hash C would be your top hash. Hash C is NOT the same as taking a
> hash of the entire 512K part. So now we reduce the chunk size to 128K.
> Now we do a hash on 4 chunks, then 2 combine hashes, then a final combine
> hash. So now you have 7 hashes per post to work out. If you take this
> down to 64 byte chunks, you now have to calculate 16383 hashes per 512k
> post. At 1024 byte chunks, you still have 1023 hashes to grind thru
> before you get the top hash for that post.

I think you don't know much about how hash algorithms work.  The amount
of CPU time required is a linear function of the amount of data you have to
hash, not the "number of hashes" you calculate.

If you create a hash for each 1K block, you are adding 16 bytes of data
which must be hashed for each 1K block.  Extend that up though a full
binary tree and it works out to be twice that.  So for each 1K block of
data, you have to hash 32 more bytes total.  That a 3% increase in the
amount of data which must be hashed.  so if it takes 1 second to hash all
the data, you have added .03 seconds of CPU time to the problem by using 1K
blocks.

To help you understand better...

To calculate an MD5 hash of data, you divide the data up into blocks of 16
bytes each.  You then start the 16 byte "hash context" at an initial state.
You apply the MD5 algorthm to the context and the first 16 byte block.  The
algorithm produces as output, the next MD5 context.  You repeat this for
every 16 byte data block in your set.

If you have a 1K block, you have to run the hash function 64 times.

For a 512K block, you have to run the hash function 64*512 or 32,000 times.

If you take two MD5 hashes, and hash them, you run the basic hash function
2 more times.  For 512K of data, and a 1K block size, we end up with 1023
extra hash values which have to be hashed.  So the total number of hashes
that must be calculated is 32,1023 instead of just 32,000.

If you use a block size of 256K, then the total number of hashes to be
calucated drops to 32,003.  Not a significant CPU savings for a problem
which isn't CPU bound in the first place, it's disk IO bound.

> I think that the chunk size should be the lowest part size you should
> expect someone to post at. Make it 64K, binaries shouldn't ever be split
> into pieces smaller than this, and at 512k part sizes, it only requires 8
> hash calculations per post.

That's a point to consider.  Like I said in my other post, I've already
rasied it to 4KB in my test code.

64KB is a good number for a minimum post size.  But, the number also
becomes the granularity which will be used to try and adjust all posts in a
set to the same size.  To make articles move at about the same speed (and
over the same feed links), you want all the articles in the set to be as
close as possible to the same size.  If you wanted to post a 3.1MB file
say, that's works out to be 50 64KB chunks.  If you want a part size of
432KB or less (9 chunks max per file), you get 5.6 articles (i.e. 6,), and
you end up with some of the articles having 9 chunks and some with 8 like
this:

   9 9 8 8 8 8

So two files hold 576k of data and the rest hold 512K each. (the difference
being your 64K chunk size).

Are those file sizes close enough in size to help them move though usenet
cleanly?  I don't know.  They don't seem as close as I'd like them, but
maybe they are.  I wouldn't want to go higher than 64K.

There are so many hard cutoffs in the usenet feed system (like the Cidera
512K limit), that you want to get the articles as close in size as possible
to minimize problems that some of the articles (like the last 3 in the set
above) squeeze under a bar like the Cidera limit, where as the first 3 are
blocked out.

With a 1K granularity to work with, the odds are so much better that the
article set won't get split up and have only some of the articles make it
to a server instead of all or none.  With 4K it gets worse.  With 64K, it's
a big difference.

When we get farther with this we should experiment to see if this really
makes much difference or not.  If not, larger block sizes have an advantage
even if the small sizes are not a CPU issue.

> > The file is 2^37 bytes long.  1K is 2^10, so that gives us 2^27 P
> > blocks

> This would be 2^28-1 hashes you would have to calculate. If you can
> calculate 10K hashes a second, this will take you 7 hours of math to
> start posting. It'll solve the bandwidth problems nicely :D

Well, to throw in some real numbers...  The md5 Unix utility running
on a 1GHz PIII machine of mine can do about 40MB of data per second when
reading a file already cached in memory.  That's over 2^32 bytes of data.
So to calculate it for 2^37 bytes would take 2^5 seconds (that's 32
seconds to claculate a single hash for 128 GB of data).  To calculate
all the hashes for 1K blocks, that increases the work by 3%, so
we are talking 33 seconds instead of 32.  Not quite 7 hours is it?

And how long do you think a typical disk drive will take to deliver
128 GB of data to you so you can do that 32 seconds of CPU work calculating
the hash?  20MB per second is a typcial disk these days.  At that rate,
it would takes about 2 hours to read all that data.  I don't think that
33 seconds of CPU work spread over 2 hours is going to be a problem.

Someone wanting to post a 100GB file and not wanting to wait 2 hours
before the posting can even start might be an issue.  But my feelings on
that is if they are putting that much data on Usenet they better be
willing to wait because that 2 hours of delay will make it better
for everyone on usenet trying to download the file or trying to
transport the file for him.

> > I think these ideas are just getting better and better.  I'm beginning
> > to feel the need to write proof of concept code....
>
> I started playing around with this too, which is how I noticed how many
> actual hashes you'd have to calculate per post.

Yeah, but the time to calculate them shouldn't be a problem.  Let us known
if you find it is or think my logic above has some flaw in it.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] verifying that part reposts belong to a file - solution
#61297
Author: Brian Truitt
Date: Fri, 11 Oct 2002 01:44
7 lines
1334 bytes
Bah, color me stupid. I knew all that, but got so wrapped up in the program
around the hash function I failed to look at the behavior patterns of the
hash function itself. Think I'll wait until I have the code done before I
bother to post again so I don't do that again :)


Re: [FNTP] more on hash chunk sizes
#61323
Author: Curt Welch
Date: Fri, 11 Oct 2002 20:11
238 lines
14590 bytes
"Brian Truitt" <btruitt@rcn.com> wrote:
> I think that the chunk size should be the lowest part size you should
> expect someone to post at. Make it 64K, binaries shouldn't ever be split
> into pieces smaller than this, and at 512k part sizes, it only requires 8
> hash calculations per post.

I realized there's more to think about when selecting the chunk size
for the hash.  I'll summarize what I've heard/though about so far.

But first...

THE HASH

To start with, let me explain for anyone not following this, that we are
basically defining a hash algorthm that works well with multipart posts
because it allows you to verify that a single post matches it's hash id
without having access to all the other posts.  The hash algorithm is built
using a standard secure hash such as MD5 or SHA1.  We divide the entire
file up into fixed sized chunks, and calculate the hash value of each
chunk.  We then build a binary tree of hash values by taking each two hash
values, combine them, and calculate the hash of the combined.  We do this
with a large binary tree until you get to the top where you have only a
single hash value for the entire file.

The beauty of this system is that when you post a segment of data from the
file, you can include the hash values of all the other segments.  But
instead of having to include thousnads of hash values for a 1000 part file,
you include the highest hash values from the tree possible which will allow
you to recalculate the total hash using the data in the file and the hash
values supplied.  With the help of the tree, you only end up having to
include a very small number of hash values with each post (on the order of
2*log2(P) where P is the number of chunks).

So, in designing the hash which will become a possible standard for all
large binaries posted to Usenet, we have to pick a chunk size (just like
you have to pick a the number of bits you want if you were designing a new
hash). Whatevery chunk size we pick will end up being something to live
with for a long time.  Changing the hash later defeats some of it's reason
for being so it's not something you would want to do on a regular basis.

So, we have identified various issues for selecting a chunk size so far...

HASH TREE SIZE

The first chunk size issue is that smaller chunk sizes creates a larger
hash tree.  The hash calculation isn't significant unless you get down
somewhere below the 1KB size for junks, but the number of hashes which have
to be saved before a file can be posted, and then the number of hash values
that need to be included with each post as its digntial "signature",
increases.  But it's logrithmic, so every time you double the chunk size
you only remove one hash value from the post.  And for 1KB chunk sizes we
are only talking about somewhere in the range of 20 hash values for typical
files worset case and 10 or less on the average.  So the data is fairly
small either way.  But larger chunk sizes are generally better in terms of
reducing the size of the hash tree and the number of hash values to deal
with everywhere.

ARTICLE SIZE

The second issue on chunk size is the fact that all multpart posts which
use this system must be split on chunk size boundries.  The larger the
chunk size, the less options we have when selecting the size of the
multipart post, and the harder it becomes to keep all the articles in a set
close to the same size as possible.  Though it's not commonly done now,
it's better to keep all the posts in a multipart set the about the same
size.  Many feeds on Usenet are size limited, so the larger the post, the
less options it has to move though usenet, and the more likely it is to get
caught in feed which is backlogged (which slows it's movement though
usenet), and the more likely it is to be dropped and lost.

The common algorithm used today is to set a part size, and post all the
parts the same size, except the last, which will be "whaterver is left".
This means the last article in a multipart set very offen will fly though
usenet making it to sites that will end up blocking the rest of the post,
and making it to some sites hours ahead of the rest of the post.  The
problem that can cause, even if all the other posts show up later, is that
the last part will be expired first.  So this creates a window at the end
of the expiration time where all but the last part is sitting on the
server.  People think the "Usenet" lost the last part when in fact, it had
already come and gone.  This is a noticable problem on very short retnetion
servers (1 day range) where you could find 25% of all posts having this
problem even though the server is getting 100% of all the articles.

At the same time, If you don't balance the data between the articles, you
have forced your articles to be larger than they need to be.  This is most
common for smaller posts done with large part sizes.  Say you have a 910KB
post split into 300K chunks.  You end up with 3 posts of 300K and one post
of 10K.  So you already are sending out 4 articles.  If the posting tool
balanced the data between the 4 posts, you would instead have had 4 posts
of 240K each.  Those 240K posts will make it to more sites, and make it
there faster, than the 300K posts which are 25% larger than they should
have been.

So I want to encourage people to start doing this - to balance the amount
of data placed in each post of a multipart set.  But because the chunk size
limites the ability to balance, you have the issue that the larger the
chunk size you select, the less balanced the post will be.  For a 64KB
chunk size, this means that some posts will end up being 64K larger than
the rest in the set.  And, because the last file will end up with a partial
chunk it can worst case end up being 2x the chunk size smaller than the
largest files in the post.  So for a 64K chunk size, the last post in the
set may be as much as 128K (minus one byte) smaller than the largest in the
set (probably the first article posted).  So, for this dynamic, you want
smaller chunk sizes instead of larger chunk sizes.

But, the chunk size also becomes the lower limit on the article size for
mutlipart posts.  With this system, you must but at least 1 full chunk in
each article.  So a larger chunk size like 64K makes it impossible to use
this system and post small multipart articles (trying to squeze them into
systems that only want text for example).  So that would en

UUENCODE

Like I said in another post, to make this system compatible with uuencode
we have the problem that uuencode puts 45 bytes of file data on each line.
When you post in uuencode format, each article must fall on a uuencode line
break.  So that means every uuencode file contains a number of bytes which
is a multiple of 45. And the factors of 45 are 3, 3, and 5.  Not a single 2
in there.

So if we want the chunk sizes to fall on a power of 2 block boundry (to
match disk blocks and IO buffers), and also fall on uuencode 45 byte
boundries, you are forced to pick a size which is simply the produce of 45
with the power of 2 boundy (like 1K).  This make 45KB the smalest chunk
size that does both of those things.

The other option is to ignore the 45 byte uuencode limit and force uucode
to do something very non standard like including a short last-line at the
end of each article in the set.  The "M" at the beginning of each uuencode
line documents the length of the line (M is 45 in the uuencode system).
And in theory, you should be able to put less bytes on the last line and
have it work. Some uudecoding tools will work with that.  But the question
is how many would break. Normally, the very last line for the entire file
is shorter.  Some uuencoding tools I bet will see a short line and take
that to mean it's the end of the file and not just "a short line".  Or
maybe assume it's a signature added to the end of a post that needs to be
ignored, etc.

The other approach is to use a smaller chunk size, like 1K, and force any
tool that wants to deal with creating uuencode solve the problem on their
own by splitting the file into a size which is a multiple of 45*CHUNK-SIZE
(45K if we select 1K as the size).

But if we ignore the uuencod issue, and go with a chunk size like 64K
(which has no prime factors of 3 or 5), that forces a uuencode article to
contain multiples of 45*64K (2.8MB) in order to get it to split on normall
uuencode lines.  And 2.8MB of uuencode data expands to a article size of
3.9MB which of course is totally unreasonable as a "minimal" article size
for todays Usenet.

Becaus of this, if we go with any chunk size larger than 1K, it should
contain some prime factors of 3 or 5 to allow some degree of compatibility
with anyone wanting to post uuencoded articles using this system.

ERROR DETECTION

The other big advantage of this hash system is that it becomes a very
strong error detecion system to not only prevent forgeries, but also to
simply spot corrupted data in articles which can sometimes happen in
transit on Usenet, and sometimes happen when articles are posted.

But, error dection with this happens at the chunk-size level.  If a post
has a one bit corruption in transit because of broken hardware somewhere
(like an 'a' changed into an 'A'), then not only can this system detect
that the article is corrupted, it can identify the location of the
corruption down to which chunk it is in.  This could in theory, allow a
download tool to use all the other chunks from the post, and only throw out
the one chunk which was corrupted.  A repost then would only need to repost
the single corrupted chunk, and not the entire article to fix the problem.

To repost a single missing chunk, the software would have to generate the
"repost request" information automatically, but that's something we have
talked about anyhow.  We want the software to be able to create a computer
parsable description of what's missing and for a re-post tool to be able to
read that and generate the minimal amount of reposts to fix the problem (or
to simply send the re-post data though e-mail).

The larger the chunk size we select, the less resolution there will be for
being able to narrow down the location of corrupted data in a file.  That
means that more "good" data will have to be thrown out with the bad.

But the flip side to this is that maybe no one in practice will ever bother
to try do repost anything other than entire articles, or par files which
have the power to fix entire articles, so the fact that we can "save" 90%
of the data in an article might not end up doing us much good anyway.

But, the flip to the flip side, is that the download tool has the power to
fix damaged or missing segments by spotting an accidental repost of the
same file in any group it's scanning.  And if you are only missing a single
1K chunk, instead of a 64K chunk, the odds of finding an article to "fix"
the missing data I think is better for the 1K chunk size.  But if
everything is being posted in these same chunk sizes, maybe that's not
really true...

POWER OF 2 AND OTHER BOUNDRY ISSUES

This hash algorthm works fine for any chunk size (in bytes) and doesn't
realy need to be on a power of 2 block boundry. We could make the chunks
1234 bytes each if we wanted to.  The hash algorithms like MD5 and SHA1
work fine for any number of bytes and because of the amount of CPU work to
calculate the hash anyway, the block aligment issues might not be important
at all.  MD5 is a 16 byte hash, and that makes it natural to calculate a
hash for data sizes which are a multiple of 16 bytes.  But SHA1 is a 20
byte hash, (which I assume works internally on 20 byte chunks but I don't
know that for sure), so making the chunk size a multiple of 20 might be
slightly more natural if SHA1 is used (which is what my current code just
happens to use).  20 bytes has a factor of 5 so that's one of the 3 factors
needed for UUENCODE, so that's a plus anyay.

So, far, we have also talked about using Base64 to represnet chunk offset,
article size, and file size.  Using a chunk size which falls on a base64
boundry then becomes a minor advantage as well when looking at numbers
encoded in base64.  Just like using sizes which are multiples of 10 make
things easy to understand when working in base10.

But I suspect that's of close to 0 value because these Base64 numbers are
very hard to do anything with in your head (What is J3a + Ca anyway?). All
it lets you know is that for a chunk size of BAA (which is like 100 in MIME
Base64 character set), Then the offsets will be A (aka 0), BAA (aka 100),
CAA (aka 200) etc. when represtend in bytes.

CONCLUSION

That's about all the issues I have found so far which are affecting the
choice of chunk size...

Anybody see others or have move thoughs and what they think will be a good
CHUNK size?

For now, I'm writing my code so the chunk size is simple to change (a
define), so once I'm able to actually post and downlad real articles done
with this system, we will have more information to work with on what the
issues are and just how important each of the above issues really are.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] more on hash chunk sizes
#61415
Author: Claus Färber
Date: Sun, 13 Oct 2002 14:40
41 lines
2577 bytes
Curt Welch <curt@kcwc.com> schrieb/wrote:
> THE HASH

> To start with, let me explain for anyone not following this, that we are
> basically defining a hash algorthm that works well with multipart posts
> because it allows you to verify that a single post matches it's hash id
> without having access to all the other posts.

There seems to be a hash function called TigerTree that already does
that. TigerTree uses 1 kiB blocks.

A derieved method is called bitprint, which just concatenats a SHA1 and  
a TigerTree hash.

We should define a Content-Hash header field that can hold any hashes in  
the form <name>=<value> instead of defining a new header (like Content- 
MD5) for each hash method.

> UUENCODE

> Like I said in another post, to make this system compatible with uuencode
> we have the problem that uuencode puts 45 bytes of file data on each line.
> When you post in uuencode format, each article must fall on a uuencode line
> break.

With Base64, which is the better solution anyway, we have a maximum of
76 characters (= 57 encoded octets) per line.

But Base64 allows to use less than this number of characters per line,
so it's possible to just insert a line break early if you need a break.
With the resulting block size of 3 octets, we could split posts at every
3 kiB boundary.

If we define a new encoding (like an improved yEnc), we have to make
sure that we can split a post at every signle octet.

Claus
-- 
------------------------ http://www.faerber.muc.de/ ------------------------
OpenPGP: DSS 1024/639680F0 E7A8 AADB 6C8A 2450 67EA AF68 48A5 0E63 6396 80F0
Re: [FNTP] verifying that part reposts belong to a file - solution
#61414
Author: Claus Färber
Date: Sun, 13 Oct 2002 14:44
38 lines
2847 bytes
Curt Welch <curt@kcwc.com> schrieb/wrote:
> Well, to throw in some real numbers...  The md5 Unix utility running
> on a 1GHz PIII machine of mine can do about 40MB of data per second when
> reading a file already cached in memory.  That's over 2^32 bytes of data.
> So to calculate it for 2^37 bytes would take 2^5 seconds (that's 32
> seconds to claculate a single hash for 128 GB of data).

40 MB * 2^5 is 1.28 GB, not 128 GB. It would take about an hour.  
(Reading the data from disk takes two hours at 20 MB/s, as you said.)

> And how long do you think a typical disk drive will take to deliver
> 128 GB of data to you so you can do that 32 seconds of CPU work calculating
> the hash?  20MB per second is a typcial disk these days.  At that rate,
> it would takes about 2 hours to read all that data.  I don't think that
> 33 seconds of CPU work spread over 2 hours is going to be a problem.

> Someone wanting to post a 100GB file and not wanting to wait 2 hours
> before the posting can even start might be an issue.

Even with a 10 MBit/s line to the server, posting such a file already
takes at least 22 hours.

> Someone wanting to post a 100GB file and not wanting to wait 2 hours
> before the posting can even start might be an issue.  But my feelings
> on that is if they are putting that much data on Usenet they better be
> willing to wait because that 2 hours of delay will make it better
> for everyone on usenet trying to download the file or trying to
> transport the file for him.

Actually, I expect software that will handle this automatically: You
just tell it which files to post to which groups on which server and the
rest works automatically.

Claus
-- 
------------------------ http://www.faerber.muc.de/ ------------------------
OpenPGP: DSS 1024/639680F0 E7A8 AADB 6C8A 2450 67EA AF68 48A5 0E63 6396 80F0
Re: [FNTP] more on hash chunk sizes
#61426
Author: Curt Welch
Date: Sun, 13 Oct 2002 20:18
84 lines
5035 bytes
claus-usenet-20021013@faerber.muc.de (Claus_F�rber) wrote:
> Curt Welch <curt@kcwc.com> schrieb/wrote:
> > THE HASH
>
> > To start with, let me explain for anyone not following this, that we
> > are basically defining a hash algorthm that works well with multipart
> > posts because it allows you to verify that a single post matches it's
> > hash id without having access to all the other posts.
>
> There seems to be a hash function called TigerTree that already does
> that. TigerTree uses 1 kiB blocks.

I'll have to look for a reference to that.

> A derieved method is called bitprint, which just concatenats a SHA1 and
> a TigerTree hash.

Which I guess simply gives you a larger and more secure hash?

More security doesn't seem to be needed for this applicaion, and a larger
hash doesn't help the Message-ID length issue.  But having two hashes to
pick from might be worth something

> We should define a Content-Hash header field that can hold any hashes in
> the form <name>=<value> instead of defining a new header (like Content-
> MD5) for each hash method.

Yeah, extending it with a paramater name would be better than making up
a new Content-Hash-Name: header.  But the semantics of this header I
suspect is very differetnt than the Content-MD5 header so you don't want to
confuse it with that anyway.  The MIME message only constains a segment of
the entire file and the entire file.  And the hash is for the entire file
for which the included segment is a part of.  It's a subtle but very
different concept.

I don't know MIME well enough to debate where this hash value would best
fit in a MIME standard, but it seems to me that this is something that
belongs in something like a Content-Partial-Segment: header.  I think you
need a new header that would document the fact this data is only a segment
of a larger file, and to document the information about the larger file, so
something like:

Content-Partial-Segement: seg-offset=12000; seg-size=3500;
   file-size=12312312312; <hash>=JudF8D763bdtgdDerhgdf

Where <hash> could be different names for differty types of hash values.

Content-MD5: could still be used, but it would only be the MD5 of this
  segment, not the hash for the entire file.


> > UUENCODE
>
> > Like I said in another post, to make this system compatible with
> > uuencode we have the problem that uuencode puts 45 bytes of file data
> > on each line. When you post in uuencode format, each article must fall
> > on a uuencode line break.
>
> With Base64, which is the better solution anyway, we have a maximum of
> 76 characters (= 57 encoded octets) per line.
>
> But Base64 allows to use less than this number of characters per line,
> so it's possible to just insert a line break early if you need a break.
> With the resulting block size of 3 octets, we could split posts at every
> 3 kiB boundary.
>
> If we define a new encoding (like an improved yEnc), we have to make
> sure that we can split a post at every signle octet.

Yes for sure.  Only uuencode has this alignment problem.  Base64 and yEnc
don't have those problems because short lines are allowed ... I'm not
confused am I?  yEnc when used for multiparts doesn't have a problem like
that does it?  I'll have to double check that - it's got some stuff about
line lenths that never should have been in the spec in the first place.

If we create/pick a new encoding that would be "the standard" for all
Usenet binary in the future, then it too would need to have to same power
to support segements of any byte length.  But all MIME CTEs have that now
so there's no reason to expect a problem anyhow.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] more on hash chunk sizes
#61427
Author: Curt Welch
Date: Sun, 13 Oct 2002 20:57
52 lines
3634 bytes
curt@kcwc.com (Curt Welch) wrote:
> claus-usenet-20021013@faerber.muc.de (Claus_F�rber) wrote:
> > Curt Welch <curt@kcwc.com> schrieb/wrote:
> > > THE HASH
> >
> > > To start with, let me explain for anyone not following this, that we
> > > are basically defining a hash algorthm that works well with multipart
> > > posts because it allows you to verify that a single post matches it's
> > > hash id without having access to all the other posts.
> >
> > There seems to be a hash function called TigerTree that already does
> > that. TigerTree uses 1 kiB blocks.
>
> I'll have to look for a reference to that.

I've done that now.

Yes, TigerTree is the exact same type of a hash we have been talking about
based on 1KB blocks and based on the 192 bit Tiger hash function.  The hash
it seems (from a one line comment I saw) was designed for the exacty same
reasons we are looking at a hash tree algorithm - because of it's abality
to veryify file segments in a "compact fashion".

The Tiger hash function it seems is simply yet another hash that is
believed (by the authors) to be secure.  I did't search long enough to dig
up third party opinions on it's strength.  It's a 192 bit (24 byte) hash
designed for optimal speed on 64 bit processors but yet also designed to be
as fast or faster than MD5 or SHA on 16 and 32 bit processors.

TigerTree is just a Tree hash built with with Tiger and I didn't see any
connection between TigerTree and Tiger in terms of who designed it or
created it.

I see no good reason to make TigerTree the standard for this application.
Both MD4 and SHA1 are many orders of magnatude faster than disk IO, so hash
speed for either doesn't seem to be an issue, and extra length of Tiger
doesn't seem to be needed either.  The only other part of the TigerTree
algorithm is the block size, which though 1KB was the same number I picked
at first, I suspect is not the best answer for this, mainly because of the
uuencode line length issue.

The "Tree" part of the algorithm is trivial to write and works the same no
mater what underlying hash you build it on, so there's nothing special
going on there.

It is good to know that others have used this same solution for the same
problem.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] verifying that part reposts belong to a file - solution
#61428
Author: Curt Welch
Date: Sun, 13 Oct 2002 21:03
46 lines
3443 bytes
claus-usenet-20021013@faerber.muc.de (Claus_F�rber) wrote:
> Curt Welch <curt@kcwc.com> schrieb/wrote:
> > Well, to throw in some real numbers...  The md5 Unix utility running
> > on a 1GHz PIII machine of mine can do about 40MB of data per second
> > when reading a file already cached in memory.  That's over 2^32 bytes
> > of data. So to calculate it for 2^37 bytes would take 2^5 seconds
> > (that's 32 seconds to claculate a single hash for 128 GB of data).
>
> 40 MB * 2^5 is 1.28 GB, not 128 GB. It would take about an hour.
> (Reading the data from disk takes two hours at 20 MB/s, as you said.)

I should always double check my math when I post things like that. :)

Where did I get 2^32 from????

> > And how long do you think a typical disk drive will take to deliver
> > 128 GB of data to you so you can do that 32 seconds of CPU work
> > calculating the hash?  20MB per second is a typcial disk these days.
> > At that rate, it would takes about 2 hours to read all that data.  I
> > don't think that 33 seconds of CPU work spread over 2 hours is going to
> > be a problem.
>
> > Someone wanting to post a 100GB file and not wanting to wait 2 hours
> > before the posting can even start might be an issue.
>
> Even with a 10 MBit/s line to the server, posting such a file already
> takes at least 22 hours.
>
> > Someone wanting to post a 100GB file and not wanting to wait 2 hours
> > before the posting can even start might be an issue.  But my feelings
> > on that is if they are putting that much data on Usenet they better be
> > willing to wait because that 2 hours of delay will make it better
> > for everyone on usenet trying to download the file or trying to
> > transport the file for him.
>
> Actually, I expect software that will handle this automatically: You
> just tell it which files to post to which groups on which server and the
> rest works automatically.

Right, it just cues the job of calculating the hash and if you are posting
multiple files, it could even be doing that stuff in parallel.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] more on hash chunk sizes
#61429
Author: Curt Welch
Date: Sun, 13 Oct 2002 23:17
69 lines
4662 bytes
claus-usenet-20021013@faerber.muc.de (Claus_F�rber) wrote:
> There seems to be a hash function called TigerTree that already does
> that. TigerTree uses 1 kiB blocks.
>
> A derieved method is called bitprint, which just concatenats a SHA1 and
> a TigerTree hash.

After a bit more searching, I still haven't come across a good description
of who is using either of these and for what, but it does seem to be talked
about in the context of p2p file sharing.

I suspect that the bitprint is simply an attempt to create a large hash
(it's 44 bytes or 352 bits) which is (/will be) used as a universial file
identifier in P2P networks.  This of course is bascially what we are after
here as well, but our requirements are a bit different.  Collissions on
Usenet are much less dangerous because unless it happens in the same group
within a period of a few months, the damage is likely to be mostly
harmless.  And the odds of that happening with a hash as small as 64 bits
is low enough to work fine for Usenet.

On a large distributed p2p file-system where stuff could hang around for 50
years, any collision might prevent the new file from being distributed
correctly (or could break both the old and new files).

Putting a 352 bit hash into a Message-Id would be way past resonable for
Usenet.   However, if this bitprint system became (or is already) some type
of standard for P2P systems, then building on it for our application may
have merit.

One way to do that is to simply include the bitprint for the file in the
headers and use that as the ultimate "File-ID".  And for the hash that goes
into the Message-Id, we can simply pick N bits from the TigerTree hash
(where we pick an N that we feel is a resonable balance between uniquess
for Message-IDs and Message-ID length).

The question however is does this buy us anything?  Even if a P2P system
identifies files by their bitprint, what would the advantage of using the
same system on Usenet be?

To post a file segment to Usenet with a TigerTable hash "signature" would
still require a pass over the entire file to build the hash tree.  Just
knowing the bitprint for the file alone would not help.

And the 1K blocksize means uuencode posts using this system would be forced
to break segements at 45KB boundries. (i.e. multiples of 1024 uuencoded
lines per article).  Wait, I take that back. There is another fix for the
uuencod problem.

You can break the the uuencode data at any line, and then simply include
extra data in the headers for the rest of the 1KB hash block.  It would
have to be in the haaders to prevent braking uudecoding software, but it
would always be 1K or less of data if the Hash block size was 1Kb.

So, for example, a 5000 line uuencode post would have 225,000 bytes of
data.  That's 219 blocks of 1KB each with 774 bytes in the last block.  The
280 bytes of missing data from the last block can be encoded into the
headers somehow to allow the hash to be verified.

But, for posts from the middle of the file, you could end up with up to
2KB-2 bytes of data max you might have to put into the headers (because you
have to complete the hash block at both ends of the post).

I don't know if this is a resonable thing to define into the standard, but
it's yet another option to look at.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: [FNTP] more on hash chunk sizes
#61430
Author: Curt Welch
Date: Mon, 14 Oct 2002 00:05
23 lines
2075 bytes
For reference...  The idea of using these types of hash trees seems to have
been first published by Ralph Merkle in:

  R. Merkle. Protocols for public key cryptosystems. In Proceedings of the
  IEEE Symposium on Research in Security and Privacy, Oakland, CA, Apr.
  1980.

These hash trees are generaly referred to as "Merkle Hash Trees" in the
literature and are used in many areas of cryptography.

And, in the Index of the O'Reilly book "Algorithms with Perl", just happens
to be these two entries side by side:

  Merkle, Ralph, 548
  Message-ID, hiding messages in, 557

There's no end to the fun things you run accross searching the web these
days. How did we ever get along before? :)

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
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