Bitcoin Forum
November 04, 2024, 04:57:18 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: hash160 -> base58. Quick Question @devs!  (Read 3010 times)
oOoOo (OP)
Full Member
***
Offline Offline

Activity: 238
Merit: 100


View Profile
August 19, 2011, 04:04:22 PM
 #1

Just a quick question:

How do I go from here:
65f2a3921afacd998e6c98a5aaa94325ed07ee14

to here:
1AJ3vE2NNYW2Jzv3fLwyjKF1LYbZ65Ez64
?

Things I have at my disposal to accomplish this task:

-pen,
-paper,
-calculator.

What do I need to do?
.
jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1280


May Bitcoin be touched by his Noodly Appendage


View Profile
August 19, 2011, 04:39:21 PM
Last edit: August 19, 2011, 05:47:55 PM by jackjack
 #2

Add "00" before, and add the first 4 bytes of sha256(sha256("00" + hash160)) after your hash160     (the + is the concatenate operation, not sum)
So you have [ "0065f2a3921afacd998e6c98a5aaa94325ed07ee14" + first4bytesof(sha256(sha256("0065f2a3921afacd998e6c98a5aaa94325ed07ee14"))) ]
The address is just the base58 representation of the hexadecimal number above

Base58 characters: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'



-pen,
-paper,
-calculator.
Quote
sha256(sha256("0465f2a3921afacd998e6c98a5aaa94325ed07ee14"))
Lol



If you really want to do it with a calculator only, there's a sha256 pseudocode here: http://en.wikipedia.org/wiki/SHA-2

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
oOoOo (OP)
Full Member
***
Offline Offline

Activity: 238
Merit: 100


View Profile
August 19, 2011, 04:47:18 PM
 #3

The address is just the base58 representation of the hexadecimal number above


Oh I think you misunderstood. Or I didn't express myself correctly.
The red part is what I'm interested in. That's why I mentioned pen+paper. I need the b58 routine.
But thanks anyways!
.
jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1280


May Bitcoin be touched by his Noodly Appendage


View Profile
August 19, 2011, 04:57:21 PM
 #4

I depends of what you want to do

If you only have the hash160 of your pubkey, I answered correctly
If you just want to convert an hex number to a base58 number, here's the process:

hex = "1d3f3a"
dec = 1*16^5 + 13*16^4 + 3*16^3 + 15*16^2 + 3*16^1 + 10*16^0
      = 1916730

The rest is just some divisions (start with the power "number of digit in the hex representation"):
dec / 58^6 = 0. ...
dec / 58^5 = 0. ...
dec / 58^4 = 0. ...
dec / 58^3 = 9.8237......
so the first character is 9, and you substract 9*58^3 to dec -> dec = 160722
dec / 58^2 = 47.777.....
so the next character is 47, and you substract 47*58^2 to dec -> dec = 2664
dec / 58^1 = 45.931.....
so the next character is 45, and you substract 45*58^1 to dec -> dec = 54
the final character is 54

Your base58 number is [9-47-45-54], ie 9mov



Your calculator may not really appreciate the value of a 64-digit hexadecimal number though

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
oOoOo (OP)
Full Member
***
Offline Offline

Activity: 238
Merit: 100


View Profile
August 19, 2011, 05:02:03 PM
 #5

That's it perfect, thanks!
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
August 19, 2011, 05:45:11 PM
 #6

For reference, see this diagram I created:

http://dl.dropbox.com/u/1139081/BitcoinImg/PubKeyToAddr.png

I have a few other diagrams posted here that you might find useful if you start looking at other calculations.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
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!