Author

Topic: create btc-address + key in only PHP ? (Read 4144 times)

sr. member
Activity: 448
Merit: 254
September 08, 2012, 04:40:57 PM
#17
Bitcoin SCI (PHP): process transactions yourself!

That project contains all the tools necessary for generating bitcoin addresses with only PHP. It started as a simple effort to generate new bitcoin addresses in PHP but I decided to go that extra step and create a sort of private bitcoin payment gateway. It allows for generation of new addresses and confirmation of bitcoin transactions without having bitcoind installed on the server.

Or to provide a potentially simpler alternative solution, there's also the PHP Bitcoin Address Creator which is PHP script designed to execute a variant of the bitcoin-off-the-grid bash script. However the bash script has multiple dependencies so it's not exactly plug-and-play in all cases, and that's why I opted to design a pure PHP solution.

Man, where were all these implementations when I looked last week to see if it had been done? (mostly for curiousity, not a personal need at this point.)  It's hard to search for, because "xyz php" always seems to match any page about "xyz" written in PHP.  Anyways, Bitcoin SCI looks nice, and thanks for the RobKohr link too!

Edit: Oh, missed the fact that RobKohr's code is not actually native PHP, if that matters to people.
legendary
Activity: 1536
Merit: 1000
electronic [r]evolution
September 08, 2012, 03:08:12 PM
#16
Bitcoin SCI (PHP): process transactions yourself!

That project contains all the tools necessary for generating bitcoin addresses with only PHP. It started as a simple effort to generate new bitcoin addresses in PHP but I decided to go that extra step and create a sort of private bitcoin payment gateway. It allows for generation of new addresses and confirmation of bitcoin transactions without having bitcoind installed on the server.

Or to provide a potentially simpler alternative solution, there's also the PHP Bitcoin Address Creator which is PHP script designed to execute a variant of the bitcoin-off-the-grid bash script. However the bash script has multiple dependencies so it's not exactly plug-and-play in all cases, and that's why I opted to design a pure PHP solution.
kjj
legendary
Activity: 1302
Merit: 1026
August 31, 2012, 10:26:37 AM
#15
http://matejdanter.com/2010/12/elliptic-curve-php-oop-dsa-and-diffie-hellman/

Library download link at the bottom.  You need to add a generator for secp256k1.
legendary
Activity: 2506
Merit: 1010
June 15, 2012, 04:21:23 AM
#14
One other PHP library mentioned here:
 - http://bitcoin.stackexchange.com/a/2488/153
legendary
Activity: 1102
Merit: 1014
June 06, 2012, 05:37:10 PM
#13
If you're aiming for minimal, none of set_privkey(), set_pubkey(), get_privkey() seem to be used at all.

Thanks, removed.
legendary
Activity: 2940
Merit: 1333
June 06, 2012, 03:15:31 PM
#12
Ok, in case it is of use to anyone, I have gotten some help from Joric to create a script that generates keys in only python. This could be called from your PHP. Inside it supports generating keys from a passphrase or from a known private key and more.

https://github.com/weex/addrgen

Very nice, thanks.

If you're aiming for minimal, none of set_privkey(), set_pubkey(), get_privkey() seem to be used at all.
legendary
Activity: 1102
Merit: 1014
June 06, 2012, 11:03:56 AM
#11
Ok, in case it is of use to anyone, I have gotten some help from Joric to create a script that generates keys in only python. This could be called from your PHP. Inside it supports generating keys from a passphrase or from a known private key and more.

https://github.com/weex/addrgen
hero member
Activity: 815
Merit: 1000
June 06, 2012, 08:46:35 AM
#10
Thanks.

Yes I meant dependent.

I suppose I can look through the code for how its seeded.

I'll report back if I find anything suspicious.
legendary
Activity: 1102
Merit: 1014
June 04, 2012, 05:01:18 AM
#9
* So if I download that HTML/javascript code here www.bitaddress.org, it will work yes?
   (Did a quick test myself, just wondering if it is also working correctly)
I have used this method to generate addresses so I think it's reasonable. I actually used vanitygen to generate addresses and modified the code to accept my private key. The current version of bitaddress.org actually accepts private keys but I can't say it did when I worked on it. What's nice is the private key vanitygen gives you yields the same address on bitaddress.org as shown by vanitygen. You could use this as a way to double check.
Quote
* Has someone extensively tested that these addresses work and are not sent to the operator of that site or some hardware disc location?
You can go offline after downloading the web page but for the super-paranoid you want to be mindful of a couple of possibilities.
Someone could hack bitaddress.org and place their own malicious code there that:
   a) generates bad addresses
   b) sends them to a server
   c) instead generates them all from a seed that is stored by a server.
Quote
* Say someone makes a bad script is it possible to create non-valid addresses/key pairs (ie if I transfer money there they get locked
  forever).
   Can I test addresses somehow?
You can test this process by generating an address however you want to and sending 0.01 BTC to it. Then creating a new wallet at blockchain.info and importing the private key into that My Wallet. Finally, send the coins back to a known-good address of yours. If the transactions is confirmed, your process works (barring security concerns).
Quote
* Is the script dependable on your OS and java updates, could it fail if run on a clean Ubuntu install?

I ask all of this as I am about to transfer a decent pile of cash to addresses I want to generate offline on a live cd running Ubuntu.
I guess you mean dependent. Every script needs some sort of environment in which to run. PHP can be made pretty well machine independent. Python too. I'm actually looking at trimming down pywallet.py to create a utility that has the minimum amount of code required to generate a new address and private key and print them to the screen.
hero member
Activity: 815
Merit: 1000
June 04, 2012, 03:43:48 AM
#8
* So if I download that HTML/javascript code here www.bitaddress.org, it will work yes?
   (Did a quick test myself, just wondering if it is also working correctly)

* Has someone extensively tested that these addresses work and are not sent to the operator of that site or some hardware disc location?

* Say someone makes a bad script is it possible to create non-valid addresses/key pairs (ie if I transfer money there they get locked
  forever).
   Can I test addresses somehow?

* Is the script dependent on your OS and java updates, could it fail if run on a clean Ubuntu install?

I ask all of this as I am about to transfer a decent pile of cash to addresses I want to generate offline on a live cd running Ubuntu.
kjj
legendary
Activity: 1302
Merit: 1026
I got it working.  You need a library for EC math and the curve definition for SEC p256k1.

You generate the private key yourself, and converting it to a WIF is pretty simple.  To get the public key, you multiply G (the generator from the p256k1 curve) by the private key.  From there, creating an address is simple too.

I'm using the LGPL ECC library from Matyas Danter, but it took some effort.
hero member
Activity: 826
Merit: 500
i still want to create the addresses via PHP

i would create the address and send the private key to another server.


is there an example how to create a valid btc address + private key in php?

basically i just want what www.bitaddress.org ´s javascript does in php.
cjp
full member
Activity: 210
Merit: 124
March 16, 2012, 12:48:26 PM
#5
I'd also advice against keeping private keys on your server. Your server is online 24h/day, and it is probably visible that it's doing something with Bitcoin, so it's an obviously attractive target for hackers.

So: just generate your key pairs on a different computer (in advance), and save only the public part (the Bitcoin address) on the server.

I did it this way, on the donation page of my website:
http://www.ultimatestunts.nl/index.php?page=12

Please note that my website appears to have functionality that creates new addresses. This is fake: in reality, these "new" addresses are already present on the server (only the public part, as I adviced). I just have a pre-calculated pool of addresses, and whenever the server needs a new address, it takes a new one from the pool.

Maybe that's also an interesting option for you.
hero member
Activity: 826
Merit: 500
March 15, 2012, 06:50:47 PM
#4
thanks you all!
legendary
Activity: 1896
Merit: 1353
March 12, 2012, 04:12:40 AM
#3
hi.

how can i generate a valid address + key in PHP without any extra tools?

so that i can save the adress+key on the server and later import these into "Armory"

i want a website to receive BTC without actually steadily connecting to a bitcoind.

thanks for any directions!

you should not generate private keys on your server, that's not safe.
with Electrum, you can generate new Bitcoin addresses without storing private keys on your server.
This is possible because it uses a "type 2" deterministic wallet, where all your addresses are generated from a public master key.
if an attacker get access to the public master key, they can know the addresses that you use, but they cannot steal your coins.
see this demo: http://ecdsa.org/remote.php




legendary
Activity: 2646
Merit: 1137
All paid signature campaigns should be banned.
March 12, 2012, 03:22:43 AM
#2
You can generate as many key pairs as your heart desires at https://www.bitaddress.org

You can download the script and run it on a computer totally disconnected from the internet.

It will also print out the key pairs to create paper wallets.
hero member
Activity: 826
Merit: 500
March 12, 2012, 03:05:40 AM
#1
hi.

how can i generate a valid address + key in PHP without any extra tools?

so that i can save the adress+key on the server and later import these into "Armory"

i want a website to receive BTC without actually steadily connecting to a bitcoind.

thanks for any directions!
Jump to: