Smart thinking! A day or two ago, I whipped up a quickie Segwit address generator with a simple regex search. It can produce both P2WPKH-nested-in-P2SH and Bech32 addresses. It’s quite trivial; it lacks vanitygen’s features, and probably also falls short in performance.
How great is the interest in this?
interesting... I'm pretty sure there is big interest in them. did you fork samr's vanitygen or start from scratch?
though since bech32 addresses are not yet implemented by most wallet,
the interest in bech32 addresses would be somewhat lower than that for segwit 3xxx addresses
any stats on how many addresses/second your generator can do?
I am thrilled to see the interest in
Bravo Charlie Addresses! Spread the word,
“Bravo Charlie One means money.”I wrote it from “scratch”—well, not really. At first, I simply glued together
sipa’s reference bech32 code,
Core’s secp256k1,
luke-jr’s libbase58, and standard POSIX extended regular expressions. Then due to build dependency problems on my airgap machine, I had to semi-rewrite it with OpenSSL secp256k1 and my own base58check encoder using OpenSSL bignums. This was supposed to be what you might call an “little pastime project”, done on a whim.
To be absolutely clear, I do handle both Bech32 and P2SH-nested Segwit “3” addresses. Right now, pattern-matching is done on either one or the other; that’s stupid. I intend to change it to check the same trial key against different patterns for both, if the operator so desires.
The code is slow, partly because I do a real bruteforce search: Read a new private key off /dev/urandom, try its corresponding public key, and throw it away if that doesn’t match. I always somewhat distrusted vanity addresses; and this is the paranoid way to make them. Partly also because I made no attempt to make it fast. I will try to get you some useful benchmark numbers after I do some immediately planned improvements. Moreover, although I paid careful attention to basic tests, I’ll want to test more and play with testnet coins before foisting my code on other people where a bug could lose Other People’s Money.
The precursor idea popped into my head when I observed that ChipMixer is still not using Segwit; thus, I had in the back of my mind to see how hard it would be to make bulk Segwit addresses on demand. It’s trivial; and my code will churn out as many thousands of nested-P2SH or Bech32 addresses and matching private keys as you could want, lightning-fast. (Of course, ordinary users should use an HD wallet!) I was pushed to action when I hit a thread where somebody was criticizing the aesthetics of Bech32. What better way to persuade that Bech32 is pretty, than to show off a sweet vanity address? So, I whipped up my bulk address generator and tacked on a regex pattern loop function.
Note for Microsoft Windows users: My vanity generator uses POSIX regular expressions and other standard Unix APIs; and I want to keep dependencies to a minimum, for my own usage. Thus, I doubt there would ever be a version which could be compiled with MSVC. But I
think that mingw has regex support; so perhaps there may be hope. I would not be able to test the resulting binaries myself; for I have no Windows in my home or office. I may try to get this working, if I see signs of sufficient interest (
viz., potential for tips). I myself will build and test on FreeBSD and Linux, in that order.
May I ask why you wrote it from scratch? Why not just modify the code from vanitygen to change how it converts ECDSA keypair to address?
Sundry reasons:
- I was scratching an itch.
- I needed a bulk address generator anyway.
- I wanted something small and light, with as few dependencies as practicable.
- vanitygen is AGPL. As an advocate of liberal licensing and best of all, the public domain, I will avoid contributing my time and effort to a project whose code I can’t borrow without virally infecting my own codebase; GPL is a one-way street, and worst of all is AGPL.
- vanitygen appears to be abandonware, with accumulating pull requests and an otherwise-maintained fork which people don’t seem to be switching to.
- I do not have the requisite cryptanalytic expertise for evaluating the safety of the EC trick which vanitygen uses for speedup. This is not to criticize vanitygen specifically: I have significant general misgivings about vanity addresses; and anything other than fully random key selection makes me uncomfortable.
- I have no idea what it would take to make vanitygen use compressed public keys as mandatory for Segwit (one pull request is open since 2013, with a severe bug as noted in the comments), then add the other needed code for Segwit address generation. (Aside: Even if you were to desire to still use old-style addresses without the Segwit fee discount, use of uncompressed public keys is really throwing away your money on fees.) Whereas I already know exactly how to create such an implementation myself—on a whim—which this was.
- I have never used vanitygen. I first looked at its codebase a few minutes ago, to inform myself for an intelligent reply to you. I didn’t actively choose not to patch a program I’ve never used; I independently wanted something, so I wrote it, and that’s that.