Bitcoin wallet address


Bitcoin wallet address

The address of the wallet is calculated according to the public key of the wallet. However, the calculation method on different chains is different, and the encoding method is also different. Ethereum uses the hexadecimal code, and eip-55 uses its case to verify the address.
The address of bitcoin is encoded by base58check, and the version number and check sum are added to the address, which can effectively prevent wrong transfer due to wrong input. Here is the address of bitcoin Wallet:

1、 Base58 encoding

Base58 encoding and Base64 encoding are not the same, not only using different character sets, but also using different encoding methods. Base64 represents 3-byte data with 4 bytes, which can effectively avoid control characters in binary system and achieve good transmission purpose.
What about base58? It’s more like binary, octal, hexadecimal. His purposes are as follows:
Compared with Base64, base58 does not use the number “0”, the letter capital “O”, the letter capital “I”, and the letter lowercase “L”, as well as the “+” and “/” symbols.

  • (1) To avoid confusion, in some fonts, the number 0 and the letter capital O, and the letter capital I and the letter small l will be very similar.
  • (2) Base64 encoding contains “+” and “/”, and it is difficult to accept strings that are not alphabetic or numeric as account numbers.
  • (3) In the mail system, the combination of characters and numbers is not easy to wrap.
  • (4) Double click to select the entire string.

Because base58 is actually 58 base, because it is not an integer multiple of 2, there will be a lot of division 2 operations, so its efficiency is much slower than Base64.
Character set used in binary system = 01
Character set used in octal = 01234567
Used character set
Character set used in hexadecimal: “0123456789abcdef”
The character set used in base 58 is “123456789abcdefghjklmpqrstuvwxyzabcdefghijkmnopqrstuvwxyz”

2、 Base58check encoding

In the process of using the wallet, if you directly use the base58 code, there will be a problem. As long as the character you enter is legal, then it is a wallet address. Even if you input it incorrectly, it will be a legal wallet address.
It’s just that the private key corresponding to this wallet address is another private key, and you can never figure it out. Therefore, with the wallet address of base58check, this address will no longer be a legal wallet address if it is mistyped.
Let’s take a look at how base58check encodes the data. Let’s make the data to be encoded into a payload, and then encode the payload in the following format:

version + payload + checksum```
From this format, we can see that we encapsulate redundant data when encoding, so we can detect errors when checking
*Version: the version number. The common version number and the prefixes that may appear after encoding are listed below
*Payload: the data loaded. The wallet address of bitcoin is obtained by hashing the public key of the wallet twice (hash256 and ripemd160)
*Checksum: This is two hashes to remove the first four bytes, (sha256 (sha256 (version + payload))). Sub (0,4);
Finally, we encode the spliced data with base58 to get the base58check encoded data
Version number of common wallet address:

|  type                         | version   |Base58 result prefix   |
|  Bitcoin Address              |  0X00     |  1                    |
|  Pay to Script Hash Address   |  0X05     |  3                    |
|  Bitcoin Testnet Address      |  0X6F     |  m, n                 |
|  Private Key WIF              |  0X80     |  5, K, L              |
|  BIP-38 Encrypted Private Key |  0X0142   |  6P                   |
|  BIP-32 Extend Public Key     |  0488B21E |  xpub                 |