# How does vanitygen calculate difficulty?

It seems really random. 1d is 1353, 1L is 22, 11 is 256, 11L is 78508, 11x is 78508, 111 is 65536, 112 is is 1335, 113 is 1330, 114 is 1330, 1L1 is 1330. I thought it was 58 to the power of the number of digits. Why isn't it?

There are two parts to this.

First is leading 1s. A leading 1 represents a 0 byte i.e. 8 bits. This means that for every additional 1 you prefix your search string with the difficulty increases by 256 (2^8). You can see this easily by checking the difficulty of prefixes 1, 11, 111 etc.

Second is other characters. Here the difficulty changes depending on how many bits you are specifying, because as your value is converted from base58 to an integer value and from there to a power of 2. Depending on your second number in your 2-digit prefix the difficulty will move around a bit (plus there will be rounding errors). Again, easy to see with prefixes of 12 and 1z (which are 1 and 57 in base58 encoding, respectively).

Once you get past all of that you should find that your 58 to the power of the number of digits comes in to play. For example the difficulty of 1234 should be 58 times the difficulty of 123.

• "For example the difficulty of 1234 should be 58 times the difficulty of 123." It's not. 1353 * 58 != 78508. Even if you compare 12345678 and 123456789, you'll find it's not exactly a factor of 58 – Nick ODell Apr 9 '13 at 23:37
• As mentioned, there are rounding errors because difficulties are calculated using integer values (and the calculation multiplies integers so the error compounds as you increase the size of the prefix). – jgm Apr 9 '13 at 23:54
• Ah. So the difficulty reported by vanitygen is inaccurate? – Nick ODell Apr 9 '13 at 23:56
• I wouldn't label it as inaccurate; it's a minor rounding error that's less than 0.05% in the most egregious case, and that's only when it really doesn't matter because the absolute numbers are so small. – jgm Apr 10 '13 at 0:01
• Non case sensitive. It says that the probability of finding 1L is the same as finding 1m OR 1M. That seems a little odd to me. – lurf jurv Apr 23 '13 at 14:39