Overview#
Bitcoin address is an identifier of 26-35 alphanumeric characters, beginning with the number 1 or 3, that represents a possible destination for a bitcoin payment.Bitcoin address can be generated at no cost by any user of Bitcoin.
For example, using Bitcoin Core, 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 cryptocurrency wallet service.
There are currently two address formats in common use:
- Common P2PKH which begin with the number 1, eg: 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2.
- Newer P2SH type starting with the number 3, eg: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy.
Encoding a Bitcoin address#
There are currently two address formats in common use and both are implemented using the Base58Check encoding of the hash of either:Pay-to-script-hash (P2SH) (Newer Bitcoin address) payload is:
[RIPEMD160] ( [SHA256|https://en.bitcoin.it/wiki/SHA256] (redeemScript))where redeemScript is a script the wallet knows how to spend; version 0x05 (these addresses begin with the digit '3') (eg: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy)
Pay-to-pubkey-hash (P2PKH): payload is
[RIPEMD160] ( [SHA256] (ECDSA_publicKey))where ECDSA_publicKey is a Public Key the wallet knows the Private Key for; version 0x00 (these addresses begin with the digit '1')
(eg: 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2)
RIPEMD-160 and SHA256 used for Bitcoin address#
RIPEMD-160 was used because it produces a shorter hash output. This permits bitcoin addresses to be as short as possible without compromising security. The exact reason why SHA256 was used in combination with RIPEMD-160 is not known. The two leading theories are:- There was concern that RIPEMD might have some defect. SHA256 was believed to be more secure. The hope was that the two combined would be stronger than RIPEMD alone.
- There was a concern about possible weaknesses in the MD5 structure itself, such as a length extension attack. Two hashes combined result in a composite hash that does not have a Merkle-Damgard construction and so is not vulnerable to these attacks.