🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #57535

Re: Using Message-ID to store binary file information

#57535
From: Coises
Date: Fri, 22 Mar 2002 09:29
65 lines
4606 bytes
[22 Mar 2002 07:33:26 GMT] Curt Welch:
>Remeber that we are talking about a partial MD5 plus the file length.  So
>we only need to figure out how likely it is for two files of the
>same length to end up with the same N bits from an MD5 (or any hash
>that works well).

Assuming the hash "works well," it should be independent of the file
length.  The likelihood that two different files would happen to hash to
the same n-bit value would be 1/2^n.

The likelihood that two different files would have the same length would be
difficult to estimate a priori.  Let's see where we get if we omit that
factor and rely only on the hash.

The relevant question then is:
     Suppose, over some period of time, "k" *different* files are posted.
     What are the chances that any of those "k" files will have the same
     "n"-bit hash key?

The probability that the second file has a different hash key than the
first is  (1-(1/2^n)).  The probability that the third file has a different
hash key than the first is (1-(1/2^n)).  Etc... so the probability that
none of the other files have the same hash key as the first file is
(1-(1/2^n))^(k-1).  (We can multiply them like that because the probability
of any hash key colliding with the first is independent of the probability
of any other hash key colliding with the first.)

What about the second file?  Well, if the first file was clear, then we
already know that one hash value is taken, and can't be the value of any of
the other files.  So, given that none of the files collided with the first,
the probability that none of the files collide with the second is
(1-(1/(2^n-1)))^(k-2).  Given that none of the files collided with the
first two files, the probability is (1-(1/(2^n-2)))^(k-3) that none
collided with the third.  And so on.

We can multiply all *these* probabilities together because we've figured
each given that the previous condition held.  So the probability that all
"k" files have different hash keys is:

(1-(1/(2^n)))^(k-1) * (1-(1/(2^n-1)))^(k-2) * ... * (1-(1/(2^n-k+2)))^(1)

Yuk.

We can simplify that by noting that this value must be greater than:
     (1-(1/(2^n-k+2)))^((k-1)+(k-2)+...+1)
which is the same as:
     (1-(1/(2^n-k+2)))^(k*(k-1)/2)
which we can plug into a calculator.  The error (which will be on the
"safe" side) shouldn't be too large, since for any reasonable choice of
hash key length, 2^n will be much greater than k.

OK... let's try for, say, a 32-bit hash key and 10,000 files (for a year's
time, that would be a little over 27 files a day):
     (1-(1/(2^32-10000+2)))^(10000*(10000-1)/2)
in my handy-dandy calculator gives:
     0.988
which means the odds would be a little more than 1 in 1oo that some pair of
hash keys would collide.  Not bad... perhaps not quite good enough.


Math geeks are welcome to jump in and improve on the above.  :-)
-- 
Peace, Randy@Coises.com
Pages at http://www.coises.com/ were updated 5 March 2002.
Technical Details
Message-ID: <b8pl9u0lphocim3v2kj5r4ehaqpe27hhrs@4ax.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!howland.erols.net!newsfeed.mindspring.net.MISMATCH!newsfeed0.news.atl.earthlink.net!news.atl.earthlink.net!news.mindspring.net!not-for-mail
References: <180320022351466617%planb@newsreaders.com> <20020320140409.897$WW_-_@newsreader.com> <200320021558402413%planb@newsreaders.com> <20020320174111.780$V8@newsreader.com> <200320022314345462%planb@newsreaders.com> <20020321022856.582$dC@newsreader.com> <210320021224366481%planb@newsreaders.com> <20020321125143.414$Wp@newsreader.com> <a7ddkd$j6s1m$1@ID-26705.news.dfncis.de> <3c9c54a2.1953960@news> <a7e4h9$kvunt$1@ID-26705.news.dfncis.de> <20020322023326.175$pl@newsreader.com>

Show Full Headers
Complete Article Headers
Message-ID: <b8pl9u0lphocim3v2kj5r4ehaqpe27hhrs@4ax.com>
Subject: Re: Using Message-ID to store binary file information
Date: Fri, 22 Mar 2002 02:29:16 -0700
From: Coises <auorfa-spamtrap@Coises.com>
References: <180320022351466617%planb@newsreaders.com> <20020320140409.897$WW_-_@newsreader.com> <200320021558402413%planb@newsreaders.com> <20020320174111.780$V8@newsreader.com> <200320022314345462%planb@newsreaders.com> <20020321022856.582$dC@newsreader.com> <210320021224366481%planb@newsreaders.com> <20020321125143.414$Wp@newsreader.com> <a7ddkd$j6s1m$1@ID-26705.news.dfncis.de> <3c9c54a2.1953960@news> <a7e4h9$kvunt$1@ID-26705.news.dfncis.de> <20020322023326.175$pl@newsreader.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!howland.erols.net!newsfeed.mindspring.net.MISMATCH!newsfeed0.news.atl.earthlink.net!news.atl.earthlink.net!news.mindspring.net!not-for-mail
Newsgroups: alt.usenet.offline-reader.forte-agent,news.software.nntp
Organization: http://www.coises.com/
Lines: 64
Distribution: inet
Reply-To: Agent-user@Coises.com
NNTP-Posting-Host: d1.56.cd.8d
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Server-Date: 22 Mar 2002 09:29:17 GMT
X-Newsreader: Forte Agent 1.91/32.564