Bitcoin Forum
December 03, 2016, 02:29:18 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: create btc-address + key in only PHP ?  (Read 3363 times)
hamdi
Hero Member
*****
Offline Offline

Activity: 644



View Profile
March 12, 2012, 08: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!

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480732158
Hero Member
*
Offline Offline

Posts: 1480732158

View Profile Personal Message (Offline)

Ignore
1480732158
Reply with quote  #2

1480732158
Report to moderator
1480732158
Hero Member
*
Offline Offline

Posts: 1480732158

View Profile Personal Message (Offline)

Ignore
1480732158
Reply with quote  #2

1480732158
Report to moderator
1480732158
Hero Member
*
Offline Offline

Posts: 1480732158

View Profile Personal Message (Offline)

Ignore
1480732158
Reply with quote  #2

1480732158
Report to moderator
BurtW
Legendary
*
Offline Offline

Activity: 1778

All paid signature campaigns should be banned.


View Profile WWW
March 12, 2012, 08: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.

Our family was terrorized by Homeland Security.  Read all about it here:  http://www.jmwagner.com/ and http://www.burtw.com/  Any donations to help us recover from the $300,000 in legal fees and forced donations to the Federal Asset Forfeiture slush fund are greatly appreciated!
ThomasV
Legendary
*
Offline Offline

Activity: 1722



View Profile WWW
March 12, 2012, 09: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





Electrum: the convenience of a web wallet, without the risks
hamdi
Hero Member
*****
Offline Offline

Activity: 644



View Profile
March 15, 2012, 11:50:47 PM
 #4

thanks you all!

cjp
Full Member
***
Offline Offline

Activity: 210



View Profile WWW
March 16, 2012, 05: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.

Donate to: 1KNgGhVJx4yKupWicMenyg6SLoS68nA6S8
http://cornwarecjp.github.io/amiko-pay/
hamdi
Hero Member
*****
Offline Offline

Activity: 644



View Profile
May 12, 2012, 06:26:59 PM
 #6

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.

kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
May 21, 2012, 05:45:14 AM
 #7

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.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
Realpra
Hero Member
*****
Offline Offline

Activity: 819


View Profile
June 04, 2012, 08: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.

Cheap and sexy Bitcoin card/hardware wallet, buy here:
http://BlochsTech.com
weex
Legendary
*
Offline Offline

Activity: 1097


Give me your tired, your poor, your huddled...


View Profile
June 04, 2012, 10: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.

Realpra
Hero Member
*****
Offline Offline

Activity: 819


View Profile
June 06, 2012, 01:46:35 PM
 #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.

Cheap and sexy Bitcoin card/hardware wallet, buy here:
http://BlochsTech.com
weex
Legendary
*
Offline Offline

Activity: 1097


Give me your tired, your poor, your huddled...


View Profile
June 06, 2012, 04:03:56 PM
 #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

dooglus
Legendary
*
Online Online

Activity: 1988



View Profile
June 06, 2012, 08: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.

weex
Legendary
*
Offline Offline

Activity: 1097


Give me your tired, your poor, your huddled...


View Profile
June 06, 2012, 10: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.

Stephen Gornick
Legendary
*
Offline Offline

Activity: 1988



View Profile
June 15, 2012, 09:21:23 AM
 #14

One other PHP library mentioned here:
 - http://bitcoin.stackexchange.com/a/2488/153

kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
August 31, 2012, 03:26:37 PM
 #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.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
September 08, 2012, 08: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.

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
scintill
Sr. Member
****
Offline Offline

Activity: 448


View Profile WWW
September 08, 2012, 09: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.

1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!