# Why is there a finite amount of bitcoin addresses and how is the range of possible addresses determined

My first question is what the precise logical/theoretical reason is that there are only a fixed amount of possible bitcoin addresses. Secondly, I can generate a bitcoin address by using address(sha256("Passphrase")). If it is even possible to determine, what would be the "Passphrase" in order to calculate the first and last possible address? Is for example address(sha256(0)) the first address?

I am trying to understand how the "range" of possible addresses works or how it is bounded.

My first question is what the precise logical/theoretical reason is that there are only a fixed amount of possible bitcoin addresses.

Because physics doesn't allow us to do anything that is infinite.

But even though there are a finite number of addresses, the number of possible addresses is so large that it might as well be infinite. There's no way that we could exhaust all possible addresses; there's just too many of them.

Secondly, I can generate a bitcoin address by using address(sha256("Passphrase")). If it is even possible to determine, what would be the "Passphrase" in order to calculate the first and last possible address?

That's not how addresses work. It's not an ordered list and addresses aren't generated in any order. Addresses are not generated by hashing some password; nor would they be ordered by that password.

Addresses are generated by hashing a public key with SHA256, then that hash with RIPEMD160. The resulting hash is then encoded with Base58 Check encoding. These hash functions are irreversible so given their output, you cannot find their input. So no, it would not be possible to find out what public key an address is the hash of given just the address.

If you really wanted to order addresses, then the first address is the Base58 check encoding of `0000000000000000000000000000000000000000` and the last address is the Base58 check encoding of `ffffffffffffffffffffffffffffffffffffffff`. The range of possible addresses is just the range of all possible 160 bit (20 byte) values. That is because that is the range of all possible values that RIPEMD160 can output.

• Thanks for the explanation! Kind of interesting that ffffffffffffffffffffffffffffffffffffffff & 0000000000000000000000000000000000000000 are in use. – alpenmilch411 Feb 12 '19 at 15:45
• Not really. They are only "in use" because the range of RIPEMD160's output is all possible 160 bit values which are between those two numbers inclusive. – Andrew Chow Feb 12 '19 at 18:16

The range of addresses is greater than the range of possible key pairs in elliptic curve `secp256k1` (because there are more than 1 address type). This range is any 256 bit number from `0x1` to `0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140`. In other words, there is a finite limit, but it is about 1E77 so it's enormous.

• There are more key pairs than addresses. A private key is a 256-bit number (yes, with limited range, but not very limited), while an address is a 160-bit number. Even if you consider there to be twice as many addresses because there are 2 types (P2PKH and P2SH), that's still only `2 * 2^160 = 2^161`. – Vecna Feb 12 '19 at 20:24
• That's true, good point – JBaczuk Feb 12 '19 at 20:34