Bitcoinjs-lib: Question on vanity addresses

Created on 25 Dec 2017  路  4Comments  路  Source: bitcoinjs/bitcoinjs-lib

@dcousens I'm playing around with generating vanity addresses, e.g.

const bitcoin = require('bitcoinjs-lib')
const prefix = '1d'

while (true) {
  const kp = bitcoin.ECPair.makeRandom()
  const address = kp.getAddress()
  if (address.startsWith(prefix)) {
    console.log(address)
  }
}

I noticed something when playing around. If I use the prefix 1d (I assume it has to be valid base58) it's a lot slower than 1D. Are some base58 characters in the public address more common than others?

Most helpful comment

  1. the "largest" address possible is 1QLbz7JHiBTspS962RLKV8GndWFwi5j6Qr (the pubkey hash is all 0xff bytes) (address is 34 characters)
  2. The "smallest" that doesn't have two 1s at the beginning is 16HgC8KRBEhXYbF4riJyJFLSHt34Te5YA (one 0x01 byte and 19 0x00 bytes) (address is 33 characters)
  3. the order of base58 is 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz so as you increase your hash value one by one the second value goes from 6 to 7 to 8... all the way to z and wraps back to 2 (can't be 1 since 1 serves the purpose of 0(in base 10) in base58 and counting will never increase the farthest left digit with the 0 numeral) all the way up to Q...
  4. so for 6 - Q (6789ABCDEFGHJKLMNPQ) there is a much HIGHER CHANCE of randomly getting it since there's the 34 character versions AND the 33 character versions. all other letter should be the same as 1d... try 1R it should be the same as 1d, try 15 should be the same as 1d... try 19 should be same as 1D, try 1M should be the same as 1D.

All 4 comments

For the lulz I tried this on samr7/vanitygen:

lms@x240 ~/vanitygen (master)
$ ./vanitygen 1d
Difficulty: 1353
Pattern: 1d                                                 
Address: 1dcaCYjhx2sNLxTSgcytravc7HEgArbEY
Privkey: 5JnASFQV43gpWz54wf439s6MSLy8jXUut2DWJjNEfkDuv5NqC7S
lms@x240 ~/vanitygen (master)
$ ./vanitygen 1D
Difficulty: 22
Pattern: 1D                                                 
Address: 1DYdf7CDGkEH6f7zQhUV2ZZALdmLKoHgpa
Privkey: 5J2TCZMNZRaHcRgYbHizne6kM9BQyMHiVQAjwTFj9TMEJUavNB4

So it seems 1d is more difficult than 1D, which I guess answers my question :grinning:. Will take a look at that c code to get some more information.

  1. the "largest" address possible is 1QLbz7JHiBTspS962RLKV8GndWFwi5j6Qr (the pubkey hash is all 0xff bytes) (address is 34 characters)
  2. The "smallest" that doesn't have two 1s at the beginning is 16HgC8KRBEhXYbF4riJyJFLSHt34Te5YA (one 0x01 byte and 19 0x00 bytes) (address is 33 characters)
  3. the order of base58 is 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz so as you increase your hash value one by one the second value goes from 6 to 7 to 8... all the way to z and wraps back to 2 (can't be 1 since 1 serves the purpose of 0(in base 10) in base58 and counting will never increase the farthest left digit with the 0 numeral) all the way up to Q...
  4. so for 6 - Q (6789ABCDEFGHJKLMNPQ) there is a much HIGHER CHANCE of randomly getting it since there's the 34 character versions AND the 33 character versions. all other letter should be the same as 1d... try 1R it should be the same as 1d, try 15 should be the same as 1d... try 19 should be same as 1D, try 1M should be the same as 1D.

This has nothing to do with the C code, and more to do with understanding how base58 encoding works, and probability of number range occurrence.

Please re-open if this didn't answer your question. Merry Christmas.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mr-Mondragon picture Mr-Mondragon  路  3Comments

tuyennvtb picture tuyennvtb  路  3Comments

panpan2 picture panpan2  路  3Comments

Beardcoding picture Beardcoding  路  3Comments

ishwarchandratiwari picture ishwarchandratiwari  路  3Comments