# How do Ethereum clients generate unique addresses?

How do Ethereum clients, like Ethereum Wallet or Eth-Lightwallet, generate unique addresses that haven't been used before, and what is the likelihood that these addresses have been used?

• – eth
Nov 26 '16 at 9:08

The address is derived from a random private key. The client does not check if it has been previously used because the chance of that happening is nearly zero.

• Well lets not forget the golden rule of Murphy law - what can happen - will happen or as he said "whatever can go wrong, will go wrong." Apr 16 '18 at 1:47

I think the most important phrase in your question is 'what is the likelihood'.

The other answers are correct in determining that there is a 1 in 2^160 likelihood of finding a collision with 100% probability.

Due to the birthday paradox, cryptographers give a hash function with output bitlength 160 a bitwise security rating of 80. This is because with 2^80 addresses, it is more likely than not (i.e the probability is over 50%) that you will have an address collision.

For visual comparison with the above answers, the birthday problem implies a collision will occur with probability 1 in 1,208,925,819,614,629,174,706,176, yikes.

• What the birthday problem says is that if you generate addresses using 2^80 random seeds, the chance of some pair of generated addresses being the same is ~50%. That's different than saying that if you generate a new address the chance that it will have been used before is 1 in 2^80. The correct probability is 1 in 2^160 times the number of addresses that have already been generated. Nov 26 '16 at 18:04
• Ah yeah I get the distinction, I guess interpreted the question as more 'when are we likely to get an address collision' and less 'what is the likelihood that each new address generation (starting from 0 addresses) will result in a collision'. Nov 26 '16 at 18:16

Ethereum Wallet (the official wallet that will use Mist) uses `web3.personal.newAccount` to create an account. This is a web3.js call that does the equivalent of `geth account new`.

The address space in Ethereum is a 20-byte value (160-bit address space, same as Bitcoin).

what is the likelihood that these addresses have been used?

2^160 or about 1 in 1,461,501,637,330,902,918,203,684,832,716,283,019,655,932,542,976

• When the account is created, is there a check to see if any other transactions have used this address previously? Feb 8 '16 at 13:17
• @paulmorriss I couldn't find one, but it's possible I just missed something. Feb 8 '16 at 18:05
• Nope, if you create an account that points to an existing wallet then you can spend all the ETH that's in there Jan 9 '18 at 9:07

Ethereum uses addresses that are 160 bits long. The chance that any one address is the same as any other given address is therefore 1 in 2^160. However, due to the birthday paradox the chance that a new Ethereum address is the same as any already existing Ethereum address rises exponentially with every new Ethereum address and is calculated as following:

Number of possible pairs: (number of unique Ethereum addresses + 1 / number of unique Ethereum addresses) = ((4,807,984 + 1) * 4,807,984) / 2 = 11,558,357,476,120

Chance of a unique pair: ((2^160)-1) / 2^160) = 0.999999999999999999999999999999999999999999999999315772234

Chance of 11,558,357,476,120 unique pairs = 0.999999999999999999999999999999999999999999999999315772234 ^ 11,558,357,476,120 = 0.999999999999999999999999999999999992091451

Chance of some match = 1 - 0.999999999999999999999999999999999992091451 = 7.908549 × 10^-36

As of today (26 Jul 2017) the chance of a new Ethereum address being the same as an already existing Ethereum address is ~8 × 10^-36