Bitcoin Forum
May 09, 2024, 09:03:04 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to convert Hex keys to WIF as a math problem?  (Read 1117 times)
GlassWerx (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
January 09, 2016, 11:11:10 PM
 #1

I have noticed that behind the scenes of bitcoin code there is a lot of math. Which made me wonder, Is there a way to convert a hex private key to WIF using a mathematical algorithm? If so, could someone please post the formula as i cannot find it anywhere if it exists. I am by far no math wiz or anything i just find math interesting sometimes, and this is one of them.
1715288584
Hero Member
*
Offline Offline

Posts: 1715288584

View Profile Personal Message (Offline)

Ignore
1715288584
Reply with quote  #2

1715288584
Report to moderator
1715288584
Hero Member
*
Offline Offline

Posts: 1715288584

View Profile Personal Message (Offline)

Ignore
1715288584
Reply with quote  #2

1715288584
Report to moderator
1715288584
Hero Member
*
Offline Offline

Posts: 1715288584

View Profile Personal Message (Offline)

Ignore
1715288584
Reply with quote  #2

1715288584
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715288584
Hero Member
*
Offline Offline

Posts: 1715288584

View Profile Personal Message (Offline)

Ignore
1715288584
Reply with quote  #2

1715288584
Report to moderator
1715288584
Hero Member
*
Offline Offline

Posts: 1715288584

View Profile Personal Message (Offline)

Ignore
1715288584
Reply with quote  #2

1715288584
Report to moderator
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
January 09, 2016, 11:21:43 PM
 #2

I have noticed that behind the scenes of bitcoin code there is a lot of math. Which made me wonder, Is there a way to convert a hex private key to WIF using a mathematical algorithm? If so, could someone please post the formula as i cannot find it anywhere if it exists. I am by far no math wiz or anything i just find math interesting sometimes, and this is one of them.

In math terms its pretty borring -> https://en.bitcoin.it/wiki/Wallet_import_format

Im not really here, its just your imagination.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
January 10, 2016, 12:19:37 AM
 #3

- snip -
hex private key to WIF using a mathematical
- snip -

There are two mathematical algorithms you'll need.

First you'll need to calculate SHA256. This is generally binary "math" consisting of the logic functions (and, or, xor, not) and shifting or rotating positions.  You can find a description of the algorithm here:
https://en.wikipedia.org/wiki/SHA-2#Pseudocode

Then you'll need to convert from base 16 (hex) to base 58.

fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 275


View Profile
January 10, 2016, 02:42:35 AM
 #4

I have an implementation that illustrates the maths - it's mostly a generic base conversion trick. https://github.com/Bit-Wasp/bitcoin-php/blob/master/src/Base58.php look at the encode() and decode() functions.

Bitwasp Developer.
GlassWerx (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
January 10, 2016, 03:31:15 PM
 #5

Thanks for all the links guys. Some very good reading. Bitcoin really is beautiful when you look behind the scenes.
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!