🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #61285

Re: [FNTP] verifying that part reposts belong to a file - solution

#61285
From: 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/
Technical Details
Message-ID: <20021010150018.554$OQ@newsreader.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!news.stealth.net!news.stealth.net!66.250.146.10.MISMATCH!newshosting.com!news-xfer1.atl.newshosting.com!feed2.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
References: <hpk9quk1cq0ti2reeu03epd0tgf4b8a8p0@4ax.com> <20021010014047.034$XV@newsreader.com> <t02bquo9kn92td3042tc7p83a1viivobo5@4ax.com>

Show Full Headers
Complete Article Headers
Message-ID: <20021010150018.554$OQ@newsreader.com>
Subject: Re: [FNTP] verifying that part reposts belong to a file - solution
Date: Thu, 10 Oct 2002 19:00:18 +0000
From: curt@kcwc.com (Curt Welch)
References: <hpk9quk1cq0ti2reeu03epd0tgf4b8a8p0@4ax.com> <20021010014047.034$XV@newsreader.com> <t02bquo9kn92td3042tc7p83a1viivobo5@4ax.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!news.stealth.net!news.stealth.net!66.250.146.10.MISMATCH!newshosting.com!news-xfer1.atl.newshosting.com!feed2.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com
Newsgroups: news.software.nntp
X-Trace: NewsReader.Com er0b4tO79HwIw0_XG-5doES0Pnf,=PfpuEzfw8_8-1=3AiZ
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: 199