Bitcoin Forum
May 13, 2024, 10:24:38 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [PHP] How to get the address from a private key?  (Read 1241 times)
alex1s (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
April 07, 2015, 11:03:50 AM
 #1

How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?
1715639078
Hero Member
*
Offline Offline

Posts: 1715639078

View Profile Personal Message (Offline)

Ignore
1715639078
Reply with quote  #2

1715639078
Report to moderator
Whoever mines the block which ends up containing your transaction will get its fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715639078
Hero Member
*
Offline Offline

Posts: 1715639078

View Profile Personal Message (Offline)

Ignore
1715639078
Reply with quote  #2

1715639078
Report to moderator
defcon23
Legendary
*
Offline Offline

Activity: 1120
Merit: 1002


View Profile
April 07, 2015, 11:13:02 AM
 #2

How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?

just  import the private key into your wallet , and you've got the public key.
cr1776
Legendary
*
Offline Offline

Activity: 4032
Merit: 1301


View Profile
April 07, 2015, 11:20:39 AM
 #3

It really depends on what you are asking, but this may be useful:
https://bitcointalk.org/index.php?topic=1008030.0


abyrnes81
Hero Member
*****
Offline Offline

Activity: 714
Merit: 500



View Profile
April 07, 2015, 11:21:32 AM
 #4

How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?


Maybe try this source on gitHub: https://github.com/RobKohr/PHP-Bitcoin-Address-Creator  or http://gobittest.appspot.com/Address
coinableS
Legendary
*
Offline Offline

Activity: 1442
Merit: 1179



View Profile WWW
April 07, 2015, 01:04:20 PM
 #5

A lot will depend on what PHP extensions you have installed on your server. If you're on shared hosting (like many are) your hosting provider controls what version of PHP is ran and which extensions. Echo out phpinfo(); to see what you have installed. Ones that I have seen you'll need bcrypt, bmath, and an ECC library as well. So I usually just end up using a 3rd party API to do key generation.

Maybe give this one a try, it doesn't have many requirements.

https://github.com/BitcoinPHP/BitcoinECDSA.php


Amph
Legendary
*
Offline Offline

Activity: 3206
Merit: 1069



View Profile
April 07, 2015, 01:55:02 PM
 #6

wiki is your friend here

https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses

also, for more in depth knowledge about ecdsa creation

http://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm
frogCorporation
Full Member
***
Offline Offline

Activity: 124
Merit: 100



View Profile
April 07, 2015, 04:05:41 PM
 #7

Hello, alex1s,

We had almost the same issue and we used the following answer on stackoverflow
http://stackoverflow.com/questions/19233053/hashing-from-a-public-key-to-a-bitcoin-address-in-php

However we do not know its behaviour in a case of multiple senders. For example if you need to retrieve the addresses of those, who sent you some coins, f.ex using walletnotify.
Bitcoin_BOy$
Hero Member
*****
Offline Offline

Activity: 854
Merit: 503


|| Web developer ||


View Profile
April 10, 2015, 03:28:44 PM
 #8

Well you can use a ready PHP library to do this , I didn't ever saw how it work and how Bitcoin address are hashed !
You can check this library and you will probably understand how it work and make your own ` easy code ` .

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


Kind Of Respect ,
Bitcoin Boy .
dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
April 10, 2015, 04:29:01 PM
 #9

How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?


5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
          vvvvvvvvvvvvv
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#L568
          vvvvvvvvvvvvv
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#L430
          vvvvvvvvvvvvv
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#L389
          vvvvvvvvvvvvv
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
NyeFe
Hero Member
*****
Offline Offline

Activity: 699
Merit: 500


View Profile
April 12, 2015, 02:28:00 PM
 #10

This is a lengthy instruction on the process:

http://bitcoin.stackexchange.com/questions/25024/how-do-you-get-a-bitcoin-public-key-from-a-private-key-this-is-a-new-question

But it works accordingly.

MicroDApp.com—Smart Contract developers. Lets build a decentralized future!
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!