Bitcoin Forum
May 10, 2024, 09:40:27 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How can I get a public bitcoin address from a WIF (Wallet Import Format)  (Read 835 times)
btcto (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
April 03, 2013, 11:06:37 PM
 #1

As the subject says: How can I get a public bitcoin address from a WIF (Wallet Import Format)

I'm using PHP, if anyone could point me the right way, that would be great!
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715334027
Hero Member
*
Offline Offline

Posts: 1715334027

View Profile Personal Message (Offline)

Ignore
1715334027
Reply with quote  #2

1715334027
Report to moderator
1715334027
Hero Member
*
Offline Offline

Posts: 1715334027

View Profile Personal Message (Offline)

Ignore
1715334027
Reply with quote  #2

1715334027
Report to moderator
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
April 04, 2013, 02:45:06 AM
 #2

You need an ECDSA library for PHP.  There is one available, but it doesn't have the curve we use.  The constants are in the NIST guide.

Once you decode and verify the base58check encoding, you'll be left with 256 bits and an optional 8 bit flag.

The public key is made my multiplying he base point of the curve, g by the 256 bit private key.  The public key is a point, two 256 bit numbers.

If the optional flag was not found while decoding, the public key encoding is chr(4) . $x . $y.  If the flag was found, it is chr(2+($y%2)).$x.

From there, you hash the public key encoding, first with SHA256, and then with RIPEMD-160.  Run that through a base58check encoder, and you have the address.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
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!