Searching for a specific string in a P2PKH address

6 replies 109 views
Posts: 19 · Reputation: 198
#1Nov 8, 2020, 10:36 AM
Let's say I'm trying to locate a private key that generates a P2PKH address with a specific target string, like HelloWorld. Do we think all reasonably long target strings can be found with some private keys, or are there some strings that just won't show up (like aaaaaaaaaaaaaaaaa, for example)?
2 Reply Quote Share
w0lf404Hero Member
Posts: 801 · Reputation: 2381
#2Nov 8, 2020, 10:44 AM
This is exactly how people generate vanity addresses. The number of possible private keys is much larger than number of valid addresses. There are around 2256 valid private keys while the number of valid P2PKH addresses is 2160. This means that for each address, there are around 296 private keys on average. So, as long as the address is valid, in theory it's possible to find a private key assosiated with that. The more characters the target string has, the more difficult is to find a private key.
4 Reply Quote Share
Posts: 19 · Reputation: 198
#3Nov 8, 2020, 11:54 AM
Thank you, the numbers you give definitely suggest lots of very cool addresses exist, nice.
2 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#4Nov 8, 2020, 06:04 PM
Some strings like your first example "HelloWorld" cannot occur. Since P2PKH's address format is base58, you're limited to base58 characters which excludes similar characters like "0", "O", "I" and "l". "aaaaaaaaaaaaaaaaa" is possible but its difficulty will be expensive to bruteforce that the latest hardware may not be enough.
4 Reply Quote Share
Posts: 8 · Reputation: 162
#5Nov 8, 2020, 11:21 PM
Hi Man ! Any valid BASE58 string can appear in a P2PKH address because hash160 behaves like random data. However, the string "HelloWorld" requires a private key. Strings with invalid characters are impossible in BASE58 (0. O. I. l). Also, the longer the length, the larger the search space. Yes, it's theoretically possible to do "aaaaaaaaaaaaaa," but it's an unattainable goal that would take a lifetime to find.
4 Reply Quote Share
sage_moonSenior Member
Posts: 273 · Reputation: 1371
#6Nov 9, 2020, 04:15 PM
The difficulty depends on the length, as previously mentioned. If it helps, here's a Python script that transforms your text into prefixes ready to be searched with vanity address generation software such as Keyhunt. targets.txt (1 per line?) result: vanitytargets.txt
6 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#7Nov 9, 2020, 07:51 PM
Confirmed, it outputs them one prefix per line. If you mean its compatibility, then yes, vanitysearch accepts that format with -i (input file) arg. BTW, it's cleaver to replace the base58-invalid characters with its valid uppercase/lowercase counterparts. But sometimes, the result seem to emphasize a different word ;D
3 Reply Quote Share

Related topics