Author

Topic: Best way to generate a lot of private keys/public key pairs on a server? (Read 1355 times)

legendary
Activity: 4228
Merit: 1313
Not trying to prove a point. Just experimenting. There are plenty of useless novelty websites out there like isbitcoindead.com  I thought this would be a little more interesting than a "no" written inside an h1 tag. Questions regarding collisions are frequent among many new comers. Thought it could be helpful to send someone to a website that shows the live stats of generating a couple hundred addresses every second for the last 2 years and still hasn't had a collision.

There are libraries that will do this, you asked about php, take a look at these:

https://github.com/Bit-Wasp/bitcoin-lib-php
https://github.com/mdanter/phpecc


This should be a good start, but I don't know about "a couple hundred" per second.

If you're not persisting them in a db, 100:second is achievable.

Yeah, running it with php and storing it in a database - 100/sec might be a bit much.

hero member
Activity: 765
Merit: 503
Not trying to prove a point. Just experimenting. There are plenty of useless novelty websites out there like isbitcoindead.com  I thought this would be a little more interesting than a "no" written inside an h1 tag. Questions regarding collisions are frequent among many new comers. Thought it could be helpful to send someone to a website that shows the live stats of generating a couple hundred addresses every second for the last 2 years and still hasn't had a collision.
Ok, you will need to store in a DB.  Its a very wasy project.  Probably about 100 lines of c# or use NBitcoin from nuget.
The entity framework to persist in a db.
hero member
Activity: 765
Merit: 503
Not trying to prove a point. Just experimenting. There are plenty of useless novelty websites out there like isbitcoindead.com  I thought this would be a little more interesting than a "no" written inside an h1 tag. Questions regarding collisions are frequent among many new comers. Thought it could be helpful to send someone to a website that shows the live stats of generating a couple hundred addresses every second for the last 2 years and still hasn't had a collision.

There are libraries that will do this, you asked about php, take a look at these:

https://github.com/Bit-Wasp/bitcoin-lib-php
https://github.com/mdanter/phpecc


This should be a good start, but I don't know about "a couple hundred" per second.

If you're not persisting them in a db, 100:second is achievable.
legendary
Activity: 4228
Merit: 1313
Not trying to prove a point. Just experimenting. There are plenty of useless novelty websites out there like isbitcoindead.com  I thought this would be a little more interesting than a "no" written inside an h1 tag. Questions regarding collisions are frequent among many new comers. Thought it could be helpful to send someone to a website that shows the live stats of generating a couple hundred addresses every second for the last 2 years and still hasn't had a collision.

There are libraries that will do this, you asked about php, take a look at these:

https://github.com/Bit-Wasp/bitcoin-lib-php
https://github.com/mdanter/phpecc


This should be a good start, but I don't know about "a couple hundred" per second.
legendary
Activity: 1442
Merit: 1186
Not trying to prove a point. Just experimenting. There are plenty of useless novelty websites out there like isbitcoindead.com  I thought this would be a little more interesting than a "no" written inside an h1 tag. Questions regarding collisions are frequent among many new comers. Thought it could be helpful to send someone to a website that shows the live stats of generating a couple hundred addresses every second for the last 2 years and still hasn't had a collision.
legendary
Activity: 1176
Merit: 1011
My project is a bit unconventional.  A freak-show novelty website if you will. There will be no sending or receiving, only generation of key pairs. Private and public keys will be visible to all. It is an experiment on both bitcoin address generation and the hidden variable theory, as Einstein and others called it. True randomness does not actually exist, but our ignorance to hidden variables only makes it appear random to us. Basically, I'm looking for a collision. Yes, I know the odds of a collision, but I'm not going against the collision odds, I'm going against the randomness.
In that case, you're better off just generating (pseudo)random 256-bit values. Essentially, a private key is just 256 'random' bits. If you use a poor PRNG, the actual entropy will be much less than 256 bits. Is that the point you're trying to prove?

Either way, I think calculating the corresponding address with every private key, or even importing the whole lot in an actual Bitcoin wallet, is completely unnecessary in your case and will only make the process a fuckton slower.
legendary
Activity: 1442
Merit: 1186
My project is a bit unconventional.  A freak-show novelty website if you will. There will be no sending or receiving, only generation of key pairs. Private and public keys will be visible to all. It is an experiment on both bitcoin address generation and the hidden variable theory, as Einstein and others called it. True randomness does not actually exist, but our ignorance to hidden variables only makes it appear random to us. Basically, I'm looking for a collision. Yes, I know the odds of a collision, but I'm not going against the collision odds, I'm going against the randomness.

legendary
Activity: 1022
Merit: 1008
Delusional crypto obsessionist
I was using blockchain.info's API for this, but I've hit their API usage limits. Is there a PHP library or something that will allow me to generate a large amount of private key/public key pairs constantly through out the day where I don't have to worry about usage limits?

You sure you need the private key as well?
If you want the addresses to use with customers, why not generate key pairs with bitaddress.org (for example) and then only upload the public key and keep the private key very secret somewhere offline?
legendary
Activity: 2226
Merit: 1052
I was using blockchain.info's API for this, but I've hit their API usage limits. Is there a PHP library or something that will allow me to generate a large amount of private key/public key pairs constantly through out the day where I don't have to worry about usage limits?

Blockchain.info allows 28800 addresses to be created per 8 hour. May I know what u r doing that u r hitting this limit ?

Moreover, what I understand, that u need the receive API of blockchain.info to be re-created. Only having private key/public key pair will not solve this problem. You need to forward the amount as well to your actual deposit address and inform your application by a callback that an amount has hit the address.
donator
Activity: 1218
Merit: 1079
Gerald Davis
I was using blockchain.info's API for this, but I've hit their API usage limits. Is there a PHP library or something that will allow me to generate a large amount of private key/public key pairs constantly through out the day where I don't have to worry about usage limits?

You didn't specify the use case, but you should be careful storing private keys on the server too.  Just something to consider.  


This.  Consider careful if you even need private keys on the server.   If you don't then creating keypairs offline (or on a hardened single purpose computer) and uploading only the public keys to the server would be more secure.   Using an HD wallet you could generate an unlimited number of deterministic pubkeys from a single extended pubkey.
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
Just so you know, importing addresses into a wallet is a very slow process, something like 2 keys per second on a standard HDD if you use importprivkey RPC.
legendary
Activity: 4228
Merit: 1313
I was using blockchain.info's API for this, but I've hit their API usage limits. Is there a PHP library or something that will allow me to generate a large amount of private key/public key pairs constantly through out the day where I don't have to worry about usage limits?

You didn't specify the use case, but you should be careful storing private keys on the server too.  Just something to consider. 
legendary
Activity: 3472
Merit: 4801
You can compile and run vanitygen on the server just as you would on your local machine.  However, this requires, of course, something like a VPS where you have the ability to install custom programs / compile the code.  If you have just a webhost that allows you to run PHP, then it won't work.

You can also run vanitygen on your own PC and generate a few million key/address pairs.  Then you can put together a small script that will import all the addresses into the database that you are running on the server.  That should result in your server having all the addresses it needs for a long time.

Then you can create an alert that lets you know when you have fewer than 200,000 addresses unused in your database.  In that case, you can re-run vanitygen on your local PC and re-import a new set of a few million addresses.
legendary
Activity: 1135
Merit: 1166
You could use vanitygen.

Or you could use the code from bitaddress.

Or you could run bitcoind.

Actually can you provide a little more guidance on vanitygen? When I looked it up it appears to be an application I run on my local machine? Maybe I'm not looking at the same thing you are talking about.  I'm looking for something I can use so I can write a script and run on my server, preferably as a cronjob every few minutes and log all the generated key pairs to my DB.

You can compile and run vanitygen on the server just as you would on your local machine.  However, this requires, of course, something like a VPS where you have the ability to install custom programs / compile the code.  If you have just a webhost that allows you to run PHP, then it won't work.
legendary
Activity: 1442
Merit: 1186
You could use vanitygen.

Or you could use the code from bitaddress.

Or you could run bitcoind.

Actually can you provide a little more guidance on vanitygen? When I looked it up it appears to be an application I run on my local machine? Maybe I'm not looking at the same thing you are talking about.  I'm looking for something I can use so I can write a script and run on my server, preferably as a cronjob every few minutes and log all the generated key pairs to my DB.
legendary
Activity: 1442
Merit: 1186
You could use vanitygen.

Or you could use the code from bitaddress.

Or you could run bitcoind.

That's a lot of options!  Things are looking good  Cool
Thank you I'll check out the vanitygen and bitaddress options. Is it possible to run bitcoind on a hosted webserver? I know how to run one locally, but no idea how I would get it on my host. Most people use a VPN like digital ocean for their bitcoind, correct?
legendary
Activity: 3472
Merit: 4801
You could use vanitygen.

Or you could use the code from bitaddress.

Or you could run bitcoind.
legendary
Activity: 1442
Merit: 1186
I was using blockchain.info's API for this, but I've hit their API usage limits. Is there a PHP library or something that will allow me to generate a large amount of private key/public key pairs constantly through out the day where I don't have to worry about usage limits?
Jump to: