Bitcoin Forum
November 01, 2024, 11:33:58 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: create btc-address + key in only PHP ?  (Read 4142 times)
hamdi (OP)
Hero Member
*****
Offline Offline

Activity: 826
Merit: 500



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!
BurtW
Legendary
*
Offline Offline

Activity: 2646
Merit: 1137

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: 1896
Merit: 1353



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 (OP)
Hero Member
*****
Offline Offline

Activity: 826
Merit: 500



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

thanks you all!
cjp
Full Member
***
Offline Offline

Activity: 210
Merit: 124



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 (OP)
Hero Member
*****
Offline Offline

Activity: 826
Merit: 500



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
Merit: 1026



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.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
Realpra
Hero Member
*****
Offline Offline

Activity: 815
Merit: 1000


View Profile
June 04, 2012, 08:43:48 AM
Last edit: June 06, 2012, 01:44:59 PM by Realpra
 #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: 1102
Merit: 1014



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: 815
Merit: 1000


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: 1102
Merit: 1014



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
*
Offline Offline

Activity: 2940
Merit: 1333



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.

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
weex
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



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: 2506
Merit: 1010


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

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

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1026



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.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
bitfreak!
Legendary
*
Offline Offline

Activity: 1536
Merit: 1000


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
Merit: 254


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!