Pages:
Author

Topic: segvan: Segwit vanity address & bulk address generator - page 2. (Read 2596 times)

copper member
Activity: 630
Merit: 2614
If you don’t do PGP, you don’t do crypto!
You want this code:  https://github.com/bitcoin-core/secp256k1/pull/507  it will be astronomically faster than your current code.

I believe when I previously implemented the techniques in this code my result was faster than vanitygen on a GPU.

Thank you.  Yes, I want that code!  I will promptly set this as a priority feature; I can’t wait to measure the speedup.  secp256k1 already beat OpenSSL about 7x when I tried them head-to-head in my same code; looking at the description in the code, I am guessing that “astronomically” will mean “orders of magnitude”.

FWIW, the code checked into the tree is copied from Bitcoin Core v0.15.1.  I intended to mention that in my commit log, but forgot.  Of course, I follow the secp256k1 repository; but I know it does not yet have any releases, and I wanted to be just a tiny bit conservative when using software I know is marked experimental.

It could also be made faster still with some improvements.  E.g. it doesn't actually need to compute the y coordinate of the points, so several field multiplications could be avoided in the gej_to_ge batch conversion.   It could also avoid computing the scalar for any given point unless you found a match. (E.g. by splitting the scalar construction part into another function which you don't bother calling unless there is a match).


Another advantage of this code is that it is setup to allow an arbitrary base point.  This means you could use untrusted computers to search for you.

Excellent.  I see it.  That may call for going back to the drawing board, and performing some daemonology.  I’ll see what ideas I can cook up for a client/server generator.  It may be be a higher priority than full Windows port, if I can work out an easy way for Windows-only users to submit their requests to a “cloud” machine and then do the tweak multiplication on their own machines.

Sipa also has AVX2 8-way sha2 and ripemd160 that he might post somewhere if you asked.  An 8-way bech32 checksum generator should be really easy to do,

Will ask.  Actually, I think I may have this mentioned somewhere in GH discussions; I didn’t pay attention, because I don’t yet own any machines with AVX2.  Not quite as rich as people think I am.

I myself will not try implementing such things, even the “really easy” ones.  I don’t have the CS background.  After tinkering for years, I learned programming by reading FreeBSD kernel code until I thoroughly understood almost everything except the CS-heavy subsystems (vm, scheduler, etc.).  I think you see that my code reflects the style you’d expect from that experience.  Otherwise, as in all else, I take pride in knowing enough to know the limits of my own knowledge.

though if your expression doesn't match on the final 6 characters you should avoid even running the checksum.

Of course.  Avoiding unnecessary checksums is an easy optimization all around, though it will require some refactoring to open up a code path for that.  Also, I want to at least optionally support expressions such as 'qqqqqq$'.  I’ve had fun generating a few neat addresses that way.

Time to go code...
hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
You want this code:  https://github.com/bitcoin-core/secp256k1/pull/507  it will be astronomically faster than your current code.

I believe when I previously implemented the techniques in this code my result was faster than vanitygen on a GPU.

It could also be made faster still with some improvements.  E.g. it doesn't actually need to compute the y coordinate of the points, so several field multiplications could be avoided in the gej_to_ge batch conversion.   It could also avoid computing the scalar for any given point unless you found a match. (E.g. by splitting the scalar construction part into another function which you don't bother calling unless there is a match).


Another advantage of this code is that it is setup to allow an arbitrary base point.  This means you could use untrusted computers to search for you.

Sipa also has AVX2 8-way sha2 and ripemd160 that he might post somewhere if you asked.  An 8-way bech32 checksum generator should be really easy to do, though if your expression doesn't match on the final 6 characters you should avoid even running the checksum.
Thanks for this Greg. There's a lot I don't know about ECC but I'm hoping I can contribute in other ways.
I just tried to use the makefile and deal with the errors in order, I didn't get there

The "Makefile" is for FreeBSD (and probably other BSD); the "GNUmakefile" is for Linux, and should automatically take precedence with gmake.  I assume you are using a GNU toolchain on Windows?  I could try to produce a makefile which makes isolating errors easier; let me add a no-libcrypto build option first.

Edit:  I thought tossing in the hash implementation C files would be a quick fix.  Oops.  This may take a few minutes.

I'm using mingw, so I've been running
Code:
mingw32-make.exe CC=mingw32-gcc
inside the project directory. I'll start using the GNUmakefile since I'm using the mingw version of gcc.
staff
Activity: 4242
Merit: 8672
You want this code:  https://github.com/bitcoin-core/secp256k1/pull/507  it will be astronomically faster than your current code.

I believe when I previously implemented the techniques in this code my result was faster than vanitygen on a GPU.

It could also be made faster still with some improvements.  E.g. it doesn't actually need to compute the y coordinate of the points, so several field multiplications could be avoided in the gej_to_ge batch conversion.   It could also avoid computing the scalar for any given point unless you found a match. (E.g. by splitting the scalar construction part into another function which you don't bother calling unless there is a match).


Another advantage of this code is that it is setup to allow an arbitrary base point.  This means you could use untrusted computers to search for you.

Sipa also has AVX2 8-way sha2 and ripemd160 that he might post somewhere if you asked.  An 8-way bech32 checksum generator should be really easy to do, though if your expression doesn't match on the final 6 characters you should avoid even running the checksum.
copper member
Activity: 630
Merit: 2614
If you don’t do PGP, you don’t do crypto!
I just tried to use the makefile and deal with the errors in order, I didn't get there

The "Makefile" is for FreeBSD (and probably other BSD); the "GNUmakefile" is for Linux, and should automatically take precedence with gmake.  I assume you are using a GNU toolchain on Windows?  I could try to produce a makefile which makes isolating errors easier; let me add a no-libcrypto build option first.

Edit:  I thought tossing in the hash implementation C files would be a quick fix.  Oops.  This may take a few minutes.
hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
Head meets wall repeatedly with mingw cross-compiling.

I found a regex library for Windows at PCRE, but now I need to go find a way to get openssl in there too because that's not on Windows either.

Thanks for your response.

I am under the impression that PCRE has wrappers for POSIX regex functionality (#include ); so that should work.  I’ve also found a bunch of different links and discussions (mostly on Stackoverflow) leading me to believe there’s also a mingw regex package without PCRE.  I did not yet sort it all out.

I had forgotten about the OpenSSL libcrypto dependency.  Thanks for reminding me.  It is only used for hash functions, SHA-256 and RIPEMD-160.  If it would help, I could easily copy portable C code from FreeBSD’s libmd, and eliminate the -lcrypto entirely.

The biggest question to me is getting secp256k1’s build system to work with a mingw cross-compile.  The code is portable; it’s part of Bitcoin, which I will take as proof that it runs on Windows.  But the trick is to get it to cross-build the right way.  Have you tried this part on your Windows machine?

I just tried to use the makefile and deal with the errors in order, I didn't get there
copper member
Activity: 630
Merit: 2614
If you don’t do PGP, you don’t do crypto!
Head meets wall repeatedly with mingw cross-compiling.

I found a regex library for Windows at PCRE, but now I need to go find a way to get openssl in there too because that's not on Windows either.

Thanks for your response.

I am under the impression that PCRE has wrappers for POSIX regex functionality (#include ); so that should work.  I’ve also found a bunch of different links and discussions (mostly on Stackoverflow) leading me to believe there’s also a mingw regex package without PCRE.  I did not yet sort it all out.

I had forgotten about the OpenSSL libcrypto dependency.  Thanks for reminding me.  It is only used for hash functions, SHA-256 and RIPEMD-160.  If it would help, I could easily copy portable C code from FreeBSD’s libmd, and eliminate the -lcrypto entirely.

The biggest question to me is getting secp256k1’s build system to work with a mingw cross-compile.  The code is portable; it’s part of Bitcoin, which I will take as proof that it runs on Windows.  But the trick is to get it to cross-build the right way.  Have you tried this part on your Windows machine?
hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
Head meets wall repeatedly with mingw cross-compiling.  This is actually my first time ever attempting such a thing; the last time I needed a Windows binary, a significant number of years ago, I used MSVC on a Windows machine.

I want to help Windows users get spiffy new Segwit addresses; but I think I’ve spent enough time on that for now, whereas I should be writing documentation and improving the code.  If anybody who has a working mingw setup (including a POSIX regex package) on any platform could at least confirm that it compiles that way, I’d appreciate knowing that such a thing is possible without significant code changes before I spend more time trying.

If I can successfully produce a Windows binary myself, I will distribute it on Github PGP-signed using the ECC key identified in my signature.

I found a regex library for Windows at PCRE, but now I need to go find a way to get openssl in there too because that's not on Windows either.
copper member
Activity: 630
Merit: 2614
If you don’t do PGP, you don’t do crypto!
Head meets wall repeatedly with mingw cross-compiling.  This is actually my first time ever attempting such a thing; the last time I needed a Windows binary, a significant number of years ago, I used MSVC on a Windows machine.

I want to help Windows users get spiffy new Segwit addresses; but I think I’ve spent enough time on that for now, whereas I should be writing documentation and improving the code.  If anybody who has a working mingw setup (including a POSIX regex package) on any platform could at least confirm that it compiles that way, I’d appreciate knowing that such a thing is possible without significant code changes before I spend more time trying.

If I can successfully produce a Windows binary myself, I will distribute it on Github PGP-signed using the ECC key identified in my signature.
copper member
Activity: 630
Merit: 2614
If you don’t do PGP, you don’t do crypto!
(Reserved.)
copper member
Activity: 630
Merit: 2614
If you don’t do PGP, you don’t do crypto!
Note:  This is under active development, currently on an experimental branch offering 5x speedup.  I will post further updates when appropriate.



By popular demand:

Github: https://github.com/nym-zone/segvan

The code for this is reasonably solid, notwithstanding some inelegance in main() which will be refactored.  On FreeBSD, it’s been my dogfood for over six weeks; I have also built it and tried basic functionality on Linux.  But it needs error, warning, and usage messages—plus the manpage!

When there is significant news (such as major features or a Windows version), I will severely edit this post and bump the thread.

Two recent products (tips would be encouraging):


Those were done together, on one run with each key being searched for a Bech32 pattern and a nested “3” address pattern.  They took 500–600 CPU hours on an ultra-slow airgap laptop; for comparison, the same machine requires about 8 hours for a FreeBSD buildworld (!).  But I got lucky:  I hit a ^bc1qnullnym match after covering only about 25% of a 35-bit bruteforce search.  The other took a bit longer; but wasn’t so hard, because I permitted a potential extra digit: ^3[0-9]?segwit (case-insensitive matching).

Roadmap/TODO, in no particular order:

  • Add threading.  I always simply run one instance per core.  That doesn’t waste anything, because it is a probabilistic search:  There is no concept of “progress”, no need to keep instances synchronized in any way.  Threads would make it more convenient.  However, before I add a simple pthreads implementation, I want to investigate the impact on the next item.
  • Microsoft Windows version, likely via mingw.  This is in popular demand.  I can’t promise a binary on a platform I myself don’t even have in my house; but I will try to get a Windows binary made for folks who need it.
  • Change/adjust the output format.  The current output format is intended for piping to shell scripts, especially for bulk generation mode.  If you need to generate ten thousand address/key pairs and pipe those into a `while read` loop, then the current format is ideal.
  • Add warning/error/usage messages.  This started as an afternoon project for my own use.  The code is solid, despite some inelegance in main() which will also be refactored.  It’s solid, because I need it that way; however, unlike some of my other published software, this was not originally written with other people in mind.
  • Finish the manpage!
Pages:
Jump to: