Bitcoin Forum
May 06, 2024, 04:58:39 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Initial byte of bitcoin address  (Read 1618 times)
AliceWonder (OP)
Full Member
***
Offline Offline

Activity: 168
Merit: 100



View Profile
July 07, 2013, 08:29:17 PM
 #1

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

The 25-byte address that compressed with base58 - I have some questions.

For the standard address, the leading byte in hex is always 00 and in base58 thus is a 1.

But from that table on that page, it looks like the leading byte for script hash would be 05 which in bitcoin's base58 would be 6, no?

So why does the table show it as a 3? Does the leading byte not use the same base58 encoding as the rest of the public address?

I guess what I'm asking is how the leading byte can have a value of 5 but be represented as a 3 in the base58 encoded address,

When they say initial byte is 5 I assume they mean 00000101 which is 05 which should be base58encoded 6, no? What am I missing?

QuarkCoin - what I believe bitcoin was intended to be. On reddit: http://www.reddit.com/r/QuarkCoin/
1715014719
Hero Member
*
Offline Offline

Posts: 1715014719

View Profile Personal Message (Offline)

Ignore
1715014719
Reply with quote  #2

1715014719
Report to moderator
1715014719
Hero Member
*
Offline Offline

Posts: 1715014719

View Profile Personal Message (Offline)

Ignore
1715014719
Reply with quote  #2

1715014719
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.
1715014719
Hero Member
*
Offline Offline

Posts: 1715014719

View Profile Personal Message (Offline)

Ignore
1715014719
Reply with quote  #2

1715014719
Report to moderator
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
July 07, 2013, 08:36:24 PM
 #2

The conversion to base58 is done by dividing the ENTIRE address ( which is a 256 bit number) by 58 taking the reaminder (mod), recording the value, and continuing that process until the number is reduced to zero.

You can't look at just one value at a time.  There is no 1=1 relationship between bytes and base58 values.  If you think about that logically it can't be.  A byte has 256 possible values to convert that into single "digit" ASCII values would require base256.  Right?

For more info on how to perform base58 encoding ...
https://en.bitcoin.it/wiki/Base58Check_encoding
AliceWonder (OP)
Full Member
***
Offline Offline

Activity: 168
Merit: 100



View Profile
July 07, 2013, 08:46:07 PM
 #3

The conversion to base58 is done by dividing the ENTIRE address ( which is a 256 bit number) by 58 taking the reaminder (mod), recording the value, and continuing that process until the number is reduced to zero.

You can't look at just one value at a time.  There is no 1=1 relationship between bytes and base58 values.  If you think about that logically it can't be.  A byte has 256 possible values to convert that into single "digit" ASCII values would require base256.  Right?

For more info on how to perform base58 encoding ...
https://en.bitcoin.it/wiki/Base58Check_encoding

But there is clearly some padding going on because when there are 00 bytes as the front they become a 1 in the address - e.g.

Private Key

AF1218ADB0D9D39EE2C47A82F5C173BB39B5FDF1360703D6FD83B1F66CE9A1F1

gives 25 byte address

00000071F5AB3BE5657C2B8742575C9D5EED6220BBC3565FA8

which gives base58 address

111XvwC1yyWph9CmBYfauoUT66GFLHqdH

The leading 00 bytes are clearly encoded separately or else the address would just be XvwC1yyWph9CmBYfauoUT66GFLHqdH, no?

So it isn't just a straight base conversion.

QuarkCoin - what I believe bitcoin was intended to be. On reddit: http://www.reddit.com/r/QuarkCoin/
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
July 07, 2013, 08:52:08 PM
Last edit: July 07, 2013, 09:18:24 PM by DeathAndTaxes
 #4

Yes the removal of excess zeroes is covered in the link I provided.

Quote
The leading character '1', which has a value of zero in base58, is reserved for representing an entire leading zero byte, as when it is in a leading position, has no value as a base-58 symbol. There can be one or more leading '1's when necessary to represent one or more leading zero bytes. Count the number of leading zero bytes that were the result of step 3 (for old Bitcoin addresses, there will always be at least one for the version/application byte; for new addresses, there will never be any). Each leading zero byte shall be represented by its own character '1' in the final result.

In your example all of the leading zeros 00000071F5AB3BE5657C2B8742575C9D5EED6220BBC3565FA8 are removed and encoded as a single "1" for each byte before encoding the rest of the value.

So 000000 = 111

the the rest 71F5AB3BE5657C2B8742575C9D5EED6220BBC3565FA8 is treated as a single large (256 bit) number.  Take the number divide by 58, calculate the mod and store the excess.  Convert the mod value (0 to 57) into a base58 digit.  Continue this process until the number has been reduced to zero.  You will be left with a string of base58 characters.  

For example the first (least significant digit):
0x71F5AB3BE5657C2B8742575C9D5EED6220BBC3565FA8 mod 0x3A = 0x10 = "H"



Honestly this is one of those things which I think Satoshi made excessively complicated for no real benefit, but he did and to change it now would be a breaking change which isn't going to happen.
AliceWonder (OP)
Full Member
***
Offline Offline

Activity: 168
Merit: 100



View Profile
July 07, 2013, 08:58:21 PM
 #5

Right, so the leading byte is treated differently than the rest of the address.

Is that only the case when the leading byte(s) are 00?

QuarkCoin - what I believe bitcoin was intended to be. On reddit: http://www.reddit.com/r/QuarkCoin/
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
July 07, 2013, 09:00:31 PM
 #6

Right, so the leading byte is treated differently than the rest of the address.

Is that only the case when the leading byte(s) are 0?

Yes.  It is possible (depends on the underlying public key) to have multiple leading zeros.  

For example the public key:
00000000000000000000000000000000000000000094A00911

Produces the Bitcoin Address:
1111111111111111111114oLvT2

Yes it is a valid address:
http://blockchain.info/address/1111111111111111111114oLvT2
Mike Hearn
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
July 08, 2013, 12:12:12 PM
 #7

It's a 160 bit number which is itself a hash of a 257 bit number (obviously, rounded up to the next byte).
nimda
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000


0xFB0D8D1534241423


View Profile
July 08, 2013, 12:24:50 PM
 #8

Right, so the leading byte is treated differently than the rest of the address.

Is that only the case when the leading byte(s) are 0?

Yes.  It is possible (depends on the underlying public key) to have multiple leading zeros.  

For example the public key:
00000000000000000000000000000000000000000094A00911

Produces the Bitcoin Address:
1111111111111111111114oLvT2

Yes it is a valid address:
http://blockchain.info/address/1111111111111111111114oLvT2
I thought that address was a public key which hashes to 0, and the 4oLvT2 was the checksum?
marjamrob
Full Member
***
Offline Offline

Activity: 140
Merit: 100



View Profile
July 11, 2013, 04:16:46 PM
 #9

Am I the only one, that tried that private key you posted, to see if there was money on it?
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!