13 responses to “Computer-powered lottery tickets : The Engineyard programming contest”

  1. Jon

    I agree with your search strategy and implemented the same thing myself. But I don’t think you’re right about who will win. I don’t think someone with a ton of computing power has much of a better chance than someone searching on a single core.

    The problem is that the keyspace is so large, even a botnet with a million zombie machines won’t let you search more than a miniscule fraction of the keyspace. And the winning (low Hamming distance) keys are so sparsely distributed, that no one has a good chance of hitting one.

    Let’s do the math. The number of possible combinations depends on how long the words are, but assuming an average word length of 6, there are this many possible combinations in the keyspace:

    (((2^6) * 1000) ^ 12) * (94 ^ 5) = 3.5 * 10^67

    Say you can generate and check 3 million (3 * 10^6) hashes per second per core, and you have a botnet with 1 million dual-core machines (2 * 10^6). So, you can check 6 * 10^12 combinations per second. At that rate, you can check 7 * 10^17 hashes in 30 hours. You would need to increase your rate of checking by 48 orders of magnitude to cover even 1% of the keyspace.

    So, no matter how many computers you are running on, you’re essentially taking a blind stab with no chance of hitting the optimal. The difference in probability of finding the optimum key between the botnet and the single machine are so small, and they’re both so unlikely, I think the winner will just be someone that happens to hit a good key, regardless of the computing power used.

  2. Jon

    I think a better analogy is if there was a raffle with 10 billion tickets, and I had one ticket and you had two. Are the odds of one person much higher than the other? It’s the same reason that buying 10 lottery tickets isn’t any smarter than buying 1.

  3. Charlie

    That’s not the reason you don’t buy 10 lottery tickets though. The reason buying of them is bad is because you have to pay for each ticket, and the expected return is too low. Your odds are indeed still ten times better than before, but monetarily it’s just not worth it.

    I think it’s foolish to say that anyone with one machine will have the same change as someone with a botnet. It’s possible for then to win, but their odds will literally be 100′s of times lower even if they have an extremely fast program.

    Also, unlike the lottery there is a garanteed winner, which changes things significantly. The goal isn’t to find the ONE collision, but the closest.

  4. Jared

    I don’t understand how __builtin_popcount can be used to compute the hamming distance. From what I can tell, that function just counts the number of 1 bits in an integer. However doesn’t the position of the 1 bits also matter for the hamming distance? If one byte is 10000000 and another is 00000001 then both bytes have a single “1″ bit yet shouldn’t the hamming distance be 2 since 2 bits are different (the bits in the first and last positions)?

  5. Ivan

    1. You don’t need 2^160 SHA1′s to find collision. 2^80 is enough (see “birthday paradox”).
    2. Your timings for SHA1_Transform really far from perfect. Optimized version requires only about 165 machine cycles to perform one transform on Intel Core (more correctly, ~660 cycles to process 4 hashes simultaneously with SSE2). So 2.2 dualcore cpu able to do about 26.7M hashes/sec.
    3. Previous thing also doesn’t really matter as hashing is ideal thing to do with modern GPUs. ATI RV740+ and nVidia G80+ easily beats CPUs in hashing speed. For example, 4870×2 able to compute ~720M hashes/s, GTX295 ~415M/s.
    4. But all above things again doesn’t matters as it’s still impossible to find collision in real time. However having several modern GPUs can increase your chances to win.

  6. Ivan

    Well, I don’t know much about Nettle implementation of SHA1 but simple usage of SSE2 won’t give you 10x speed-up. You’ll need to remove all unnecessary code (at least strip off little endian big endian conversions) and then try to use iCore pipelines to maximum (which is 3 SSE2 instructions per cycle). 2nd thing isn’t that easy to archive ;).

  7. Dave

    That CUDA program is impressive.. 180 M tests per second. That makes even a fast CPU at only 4M per second rather trivial. And you can use multiple video cards at once!

Leave a Reply