Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: rage39a on July 23, 2013, 11:27:19 AM



Title: Java Base58 Keypair Generator?
Post by: rage39a on July 23, 2013, 11:27:19 AM
Hi

I'm trying to generate valid bitcoin Base58 public and private key addresses in java. I've download bitcoinj and bitcoinj-minimal, i've managed to generate base58 public keys from bitcoinj-minimal and some form of the private key but not base58 and can't see how this can be done with pre-existing functionality. Bitcoinj i believe has this functionality but haven't managed to get it to work because of the endless dependencies. Is there any java code out there which is simple/minimal and just is used for Base58 Keypair Generation or could some one point me in the right direction.

Cheers
rage39a


Title: Re: Java Base58 Keypair Generator?
Post by: Mike Hearn on July 23, 2013, 12:03:40 PM
What is "bitcoinj minimal" - I've never heard of that and I wrote bitcoinj.

It's easy to get the full library. You need to use Maven. Read this:

https://code.google.com/p/bitcoinj/wiki/UsingMaven

Then you will have all the dependencies.


Title: Re: Java Base58 Keypair Generator?
Post by: rage39a on July 23, 2013, 12:16:50 PM
bitcoinj-minimal is just a stripped down version of bitcoinj, yeh i've got the full bitcoinj library it seems to rely on loads of other random packages, and its so bloated for just the simple functions i need


Title: Re: Java Base58 Keypair Generator?
Post by: Mike Hearn on July 23, 2013, 02:02:01 PM
You can just copy/paste the Base58, ECKey and Address classes then satisfy the dependencies for those, if you want. But Maven is so convenient it shouldn't be easier to do that, than just run the tool.

bitcoinj is a full blown Bitcoin API by this point. I would describe it as "featureful" rather than bloated ;)


Title: Re: Java Base58 Keypair Generator?
Post by: rage39a on July 23, 2013, 02:39:50 PM
lol true but for the functions i need its overkill, well i downloaded it via github and its still got issues, if you take those three classes surely you'll need NetworkParamaters class to use the Address class and then this references some other class over and over plus those 3 classes reference about 50 other classes which again in turn refernce   another 50 etc etc


Title: Re: Java Base58 Keypair Generator?
Post by: Mike Hearn on July 23, 2013, 06:05:25 PM
Github? It's hosted on Google Code.

The only thing it needs from NetworkParameters is the version codes. You could just hard code them. But seriously, just use the real library. It's not worth wasting your time on trying to strip it down. ProGuard can delete unused code if you're concerned about final jar size.


Title: Re: Java Base58 Keypair Generator?
Post by: rage39a on July 26, 2013, 03:27:28 PM
github just allows you to use git on windows. Yeah managed to get it working in the end using maven to get the dependencies (i think). Turns out my pubkey is base64 instead not sure how to get it to base58 with the existing code but simple enough to write the code for it myself. But yeh the codes pretty damn slow for address generation takes around 24 seconds to generate a 1000 keypairs whereas i can read about 16000 into java through vanitygen in the same time. Might have to try and create some code which is as simple/minimal as possible for base58 key generation.


Title: Re: Java Base58 Keypair Generator?
Post by: Mike Hearn on July 26, 2013, 05:39:15 PM
You probably aren't multi-threading it or using the server VM. Also, Bouncy Castle is really slow. bitcoinj supports a native ECDSA implementation, but you would need to provide the windows DLL for it.