DeathAndTaxes (OP)
Donator
Legendary
Offline
Activity: 1218
Merit: 1079
Gerald Davis
|
|
August 13, 2014, 06:22:45 PM |
|
A Bitcoin address, or simply address, is an identifier of 27-34 alphanumeric characters, beginning with the number 1 or 3, that represents a possible destination for a Bitcoin payment. Addresses can be generated at no cost by any user of Bitcoin. For example, using Bitcoin-Qt, one can click "New Address" and be assigned an address. It is also possible to get a Bitcoin address using an account at an exchange or online wallet service.
An example of a Bitcoin address is 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy.
https://en.bitcoin.it/wiki/AddressDecoded an address consists of 20 byte payload/hash 4 byte checksum 1 byte version -------------------- total: 25 bytes 34 symbols * Log2(58)/8 bytes per symbol = 24.896 bytesSo 35 digits?
|
|
|
|
dree12
Legendary
Offline
Activity: 1246
Merit: 1078
|
|
August 13, 2014, 06:34:21 PM |
|
A Bitcoin address, or simply address, is an identifier of 27-34 alphanumeric characters, beginning with the number 1 or 3, that represents a possible destination for a Bitcoin payment. Addresses can be generated at no cost by any user of Bitcoin. For example, using Bitcoin-Qt, one can click "New Address" and be assigned an address. It is also possible to get a Bitcoin address using an account at an exchange or online wallet service.
An example of a Bitcoin address is 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy.
https://en.bitcoin.it/wiki/AddressDecoded an address consists of 20 byte payload/hash 4 byte checksum 1 byte version -------------------- total: 25 bytes 34 symbols * Log2(58)/8 bytes per symbol = 24.896 bytesSo 35 digits? I think all currently-used versions have a maximum of 34 characters, because of leading zeroes, but some alt-coin versions can go up to 35.
|
|
|
|
azeteki
Member
Offline
Activity: 96
Merit: 10
esotericnonsense
|
|
August 13, 2014, 09:09:48 PM |
|
The version byte is in the low end of the range. Mainnet addresses are prefixed 0x00, for example. See https://en.bitcoin.it/wiki/List_of_address_prefixes. The longest addresses are indeed 35 characters. But they are not 'Bitcoin' addresses, because we don't use those prefixes.
|
|
|
|
DannyHamilton
Legendary
Offline
Activity: 3486
Merit: 4851
|
|
August 13, 2014, 09:19:35 PM |
|
- snip - 1 byte version - snip -
I think this is where you've made the mistake if I'm correct. With bitcoin addresses the version is currently represented with either a single "1" or "3". This makes it more of a 2 bit version than a 1 byte version. Unless significantly larger version numbers are used in the future, there really isn't much chance that the full byte will be used any time soon. Therefore, you'll never see the extra 35th digit that would be needed to represent for example a version byte of 0x3C.
|
|
|
|
DeathAndTaxes (OP)
Donator
Legendary
Offline
Activity: 1218
Merit: 1079
Gerald Davis
|
|
August 13, 2014, 09:20:20 PM Last edit: August 13, 2014, 09:37:14 PM by DeathAndTaxes |
|
On edit: deleted prior post. I realized I misunderstood azeteki's post when I saw Danny's. Yeah that makes sense now. Well I made my db fields 35 bytes so I guess I am "version 60+" compliant. With bitcoin addresses the version is currently represented with either a single "1" or "3". Just to be clear those are the resulting leading Base58 digits. P2PkH is 0x00 and P2SH is 0x05 on main-net and 0x6f and 0xc4 on testnet.
|
|
|
|
dree12
Legendary
Offline
Activity: 1246
Merit: 1078
|
|
August 13, 2014, 09:29:26 PM |
|
In byte form it is simply a sequence of bytes. For addresses it is 25 bytes long. It may begin with a 0x00 byte but it may not. Because Satoshi likes to make things difficulty a preprocessing step is done where ALL leading 0x00 bytes are replaced with a "1". Note this doesn't make the addresses shorter unless there are at least 2 or more leading zero bytes. For addresses this would require the version to be zero (P2KhH) AND the leading byte(s) of the hash are also zero.
A version byte of zero doesn't result in a smaller address than any other version UNLESS the hash also starts with a zero. The version byte refers to Bitcoin address versions (although altcoins lazily co-opted them). There are versions other than zero in use right now, P2SH addresses use 0x05.
Note that replacing an entire byte with one character "1" effectively encodes 8 bits worth of information in a single base-58 character. It then remains to encode the remaining 24 bytes in 33 base-58 characters, which by your formula is possible. Hence version-0 addresses fit in 34 characters. Version-5 addresses (P2SH) also fit in 34 characters because the version byte is small enough to ensure that the base-58 conversion does not overflow to the 35th character. This can be demonstrated by noting that log 58(6×2 8×24) is merely 33.2, and the value being logged is strictly higher than all version-5 addresses.
|
|
|
|
DannyHamilton
Legendary
Offline
Activity: 3486
Merit: 4851
|
|
August 13, 2014, 09:32:50 PM |
|
If you're still uncertain, prove it to yourself.
Assume a 20 byte hash value of 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Then calculate the bitcoin address.
That should give you the largest possible bitcoin address (and therefore the maximum possible characters), right?
|
|
|
|
HardForkComing
|
|
August 13, 2014, 09:33:44 PM |
|
- snip - 1 byte version - snip -
I think this is where you've made the mistake if I'm correct. With bitcoin addresses the version is currently represented with either a single "1" or "3". This makes it more of a 2 bit version than a 1 byte version. Unless significantly larger version numbers are used in the future, there really isn't much chance that the full byte will be used any time soon. Therefore, you'll never see the extra 35th digit that would be needed to represent for example a version byte of 0x3C. You are correct. Had an issue with a chain 5 months ago, had to go through a lot of documentation to figure out what's going on.Where were you?! :-)
|
|
|
|
DeathAndTaxes (OP)
Donator
Legendary
Offline
Activity: 1218
Merit: 1079
Gerald Davis
|
|
August 13, 2014, 09:38:50 PM Last edit: August 13, 2014, 10:05:38 PM by DeathAndTaxes |
|
Assume a 20 byte hash value of 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
For a P2PkH address it would be 1QLbz7JHiBTspS962RLKV8GndWFwi5j6Qr and yes it is 34 digits. You are right any version below a certain value will be 34 or less digits. I was thinking full bytes but as you point out it is the bits that matter. Even P2SH (0x05) only needs 4 bits. So 34 *log2(58) = 199 bits. As long as the value to be encoded is less than or equal to the max 199 bit number it won't require 35 bytes. So with a 160 bit hash and 32 bit checksum that leaves 7 bits for version. The largest 7 bit uint is 127 (0x7f). Just a heads up (which I didn't realize until now) testnet uses version 196 (0xc4) for P2SH addresses.
|
|
|
|
DannyHamilton
Legendary
Offline
Activity: 3486
Merit: 4851
|
|
August 13, 2014, 09:48:40 PM |
|
Where were you?! :-)
Right here. Take a look at my posting history. I've been around this forum quite a bit for the past 2 years.
|
|
|
|
deepceleron
Legendary
Offline
Activity: 1512
Merit: 1036
|
|
August 17, 2014, 07:06:49 PM |
|
Here is the exact address hash (with fake checksum) where addresses would change into 35 bytes of base58. Remember in Base58 that 2=1 and 1=0, so we want to find the network byte + 20 + 4 where addresses of that network byte start to have 35 character long addresses: >>> dice2key.changebase('21111111111111111111111111111111111', 58, 16) '90248722fa0bf5a28a9dfee80227dc40a4d518272400000000'
>>> dice2key.changebase('90248722fa0bf5a28a9dfee80227dc40a4d518272400000000', 16, 58) '21111111111111111111111111111111111'
>>> len('21111111111111111111111111111111111') 35 >>> That is a network byte of 90 (144 decimal). From the start of 35 byte addresses being 0x90 + 0x2487.... 9351/65536 = 85.7% of addresses using network byte 90 will be 35 digit. All network bytes above 0x90 will be 35 digit addresses starting with 2. This agrees with: https://en.bitcoin.it/wiki/List_of_address_prefixes
|
|
|
|
azeteki
Member
Offline
Activity: 96
Merit: 10
esotericnonsense
|
|
August 17, 2014, 09:13:05 PM |
|
Here is the exact address hash (with fake checksum) where addresses would change into 35 bytes of base58. Remember in Base58 that 2=1 and 1=0, so we want to find the network byte + 20 + 4 where addresses of that network byte start to have 35 character long addresses: >>> dice2key.changebase('21111111111111111111111111111111111', 58, 16) '90248722fa0bf5a28a9dfee80227dc40a4d518272400000000'
>>> dice2key.changebase('90248722fa0bf5a28a9dfee80227dc40a4d518272400000000', 16, 58) '21111111111111111111111111111111111'
>>> len('21111111111111111111111111111111111') 35 >>> That is a network byte of 90 (144 decimal). From the start of 35 byte addresses being 0x90 + 0x2487.... 9351/65536 = 85.7% of addresses using network byte 90 will be 35 digit. All network bytes above 0x90 will be 35 digit addresses starting with 2. This agrees with: https://en.bitcoin.it/wiki/List_of_address_prefixesYes. A 35 character address has a number representation >= 58**34. >>> hex(58**34) '0x90248722fa0bf5a28a9dfee80227dc40a4d518272400000000' For fun: Base58(58**34 - 1) = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' (But yes, neither of these are valid due to checksum).
|
|
|
|
Taras
Legendary
Offline
Activity: 1386
Merit: 1053
Please do not PM me loan requests!
|
|
August 20, 2014, 11:49:40 PM |
|
0000000000000000000000000000000000000000 1111111111111111111114oLvT2 27 characters
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 1QLbz7JHiBTspS962RLKV8GndWFwi5j6Qr 34 characters
|
|
|
|
theymos
Administrator
Legendary
Offline
Activity: 5376
Merit: 13420
|
|
August 21, 2014, 04:22:45 AM |
|
0000000000000000000000000000000000000000 1111111111111111111114oLvT2 27 characters
0000000000000000000000000000000000000001 11111111111111111111BZbvjr 26 characters This fact always surprises people.
|
1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
|
|
|
Taras
Legendary
Offline
Activity: 1386
Merit: 1053
Please do not PM me loan requests!
|
|
August 21, 2014, 05:52:00 AM |
|
0000000000000000000000000000000000000000 1111111111111111111114oLvT2 27 characters
0000000000000000000000000000000000000001 11111111111111111111BZbvjr 26 characters This fact always surprises people. I thought I remember a 26 character address! I assumed I just miscounted the first one. Color me surprised I guess I'll update the wiki accordingly. Welp you already did.
|
|
|
|
dree12
Legendary
Offline
Activity: 1246
Merit: 1078
|
|
August 21, 2014, 01:56:16 PM |
|
0000000000000000000000000000000000000000 1111111111111111111114oLvT2 27 characters
0000000000000000000000000000000000000001 11111111111111111111BZbvjr 26 characters This fact always surprises people. Another related surprise is that version-zero addresses are on average longer than version-one addresses, due to Satoshi's inefficient encoding of the zero byte. The only exceptions are those addresses with multiple leading zeroes.
|
|
|
|
|