# How is the probability of winning a block calculated from the difficulty?

I have problem finding this. The Bitcoin wiki mentions the probability here, but only with a link to the current value on BlockExplorer.

The wiki page on difficulty doesn't mention the formula for the probability either.

• What probability are you after? The probability of a hash solving a block (as per Peter's explanation), or a share solving a block? Or the number of blocks you might solve or shares you might submit in a given time period? – organofcorti Apr 30 '13 at 1:50
• The probability of a hash solving a block. I don't know how the share system works, isn't that implemented differently for each different pool specification? – Steven Roose Apr 30 '13 at 13:47
• Yes, variable difficulty shares means that strictly speaking "shares per block" is meaningless. In this context though most would take "shares per block" to mean "Difficulty 1 shares per block", which have a probability of exactly 1/Difficulty. – organofcorti May 1 '13 at 5:59

If the current difficulty is D, then the target hash (the value below which block hashes must go) is:

0x00000000FFFF0000000000000000000000000000000000000000000000000000 / D

(by definition of difficulty, which is a fraction of the maximum target), or otherwise put, the number of valid hashes is:

65535 * 2208 / D

Which means that the ratio of all hashes over valid hashes would be:

2256 / (65535 * 2208 / D) = D * 248 / 65535 = D * 4295032833

Which, at the current (January 2017) difficulty of D = 392963262344.3704 means that one hash in

392963262344.3704 * 4295032833 = 1687790113931869416948

results in a valid block, or each attempt has a chance of

1 / 1687790113931869416948 = 0.000000000000000000059 %

• I think the third equation is the formula for all possible hashes, not "the fraction of valid hashes to all possible hashes", isn't it? Shouldn't there be a "1/" in front? – Steven Roose Apr 30 '13 at 8:23