Bitcoin Forum
May 12, 2024, 09:47:58 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoin address calculation deep dive, does not add up  (Read 477 times)
ggbtctalk000 (OP)
Full Member
***
Offline Offline

Activity: 394
Merit: 101


View Profile
September 06, 2017, 06:44:07 AM
 #1

Looking through mastering bitcoin book's chapters, I get the following formula for bitcoin address generation:
BitcoinAddress=base58encode( 2 bytes version + 20 bytes output from RIPEMD160(SHA256(pubkey)) + 4 bytes checksum)
= base58encode(26 bytes)=base58encode(104 bits) however this is generating base58 digit size of
104bits / ((log(58)/log(2)) = 104bits/5.8579...=17.75 base58 digits.


Why 104bits / (log(58)/log(2))?
Suppose 256-bits address and how many hexes are there if represented by hex? 256 / ((log 16) / log(2)) = 256/4 = 64 hex digits.

But when I check several bitcoin wallet address the base58encoded address they are showing is 34 base58 digits. Definitely not adding up or I am missing something here.
1715550478
Hero Member
*
Offline Offline

Posts: 1715550478

View Profile Personal Message (Offline)

Ignore
1715550478
Reply with quote  #2

1715550478
Report to moderator
1715550478
Hero Member
*
Offline Offline

Posts: 1715550478

View Profile Personal Message (Offline)

Ignore
1715550478
Reply with quote  #2

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

Posts: 1715550478

View Profile Personal Message (Offline)

Ignore
1715550478
Reply with quote  #2

1715550478
Report to moderator
1715550478
Hero Member
*
Offline Offline

Posts: 1715550478

View Profile Personal Message (Offline)

Ignore
1715550478
Reply with quote  #2

1715550478
Report to moderator
1715550478
Hero Member
*
Offline Offline

Posts: 1715550478

View Profile Personal Message (Offline)

Ignore
1715550478
Reply with quote  #2

1715550478
Report to moderator
Foxpup
Legendary
*
Offline Offline

Activity: 4354
Merit: 3044


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
September 06, 2017, 07:58:51 AM
Merited by ABCbits (1)
 #2

base58encode(26 bytes)=base58encode(104 bits)
I think you'll find 26 bytes is actually 208 bits. Wink

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
September 06, 2017, 08:54:34 AM
 #3

BitcoinAddress=base58encode( 2 bytes version + 20 bytes output from RIPEMD160(SHA256(pubkey)) + 4 bytes checksum)

Are you sure about that?  I thought:

BitcoinAddress=base58encode( 1 bytes version + 20 bytes output from RIPEMD160(SHA256(pubkey)) + 4 bytes checksum)

1 + 20 + 4 = 25 bytes

Since 1 byte = 8 bits...

25 * 8 = 200 bits
base58encode(25 bytes) = base58encode(200 bits)

200 bits / [ log(58) / log(2) ] = 200 bits / 5.85798... = 34.14 base58 digits
ggbtctalk000 (OP)
Full Member
***
Offline Offline

Activity: 394
Merit: 101


View Profile
September 06, 2017, 03:02:50 PM
 #4

THANKS for both of you guys Smiley !! now it adds up! why do i always mess up between nibbles and bytes!!  Grin
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!