How many keys can be generated by a deterministic wallet?
Effectively infinitely many. The same as a non-deterministic wallet which just keeps generating random private keys. There is a limit, 2^256, but you are never going to reach that. It is effectively infinite.
Is it possible to list all keys (public keys, to avoid leaking critical information) in such a wallet?
It depends. If you are using hardened derivation, then no.
Also, because there are effectively infinitely many addresses, this would be impossible to do. You could reasonably generate enough addresses that you would ever use in your lifetime though.
Infinitely many? Surely not, since the whole address space is 2^256. The whole address space? I thought the point of deterministic wallets was that they generate a subset of the address space, and that a given deterministic wallet can not collide with another deterministic wallet (they partition the address space) – dangonfast – 2017-11-29T07:07:15.253
1No, there is no such guarantee that a deterministic wallet will not generate addresses that collide with other deterministic wallets. The collision resistance is the same as with random generation. – Andrew Chow – 2017-11-29T07:11:58.430
Something does not seem right: say I have this shiny deterministic wallet, and I have used a trillion addresses already. Now I lose it but I have properly stored my passphrase, and I am able to regenerate it using another deterministic wallet (say a hardware wallet). How does the new wallet know my balance? Goes through all keys (including the trillion keys I have already used)? If what you say is true ("a deterministic wallet generates the whole address space"), then all deterministic wallets would have the same balance, namely the full bitcoin balance. – dangonfast – 2017-11-29T07:48:11.083
a theoretical approach... infinite in the sense, that you cannot spend enough computing power, to generte the addresses. There is a link where the actual implementation is discussed: https://bitcoin.stackexchange.com/questions/50538/how-does-the-client-know-the-number-of-keys-and-coins-when-recovering-from-a-see, so looks like BIP44 has a 20 address limit. On infinity: another limitation comes from the int64_t specification for the maximum addresses in a wallet - only 2^(64-1)-1 adddresses :-)
– pebwindkraft – 2017-11-29T08:17:52.683@dangonfast Because there are effectively infinite keys, your wallet cannot generate them all in a reasonable amount of time. The wallet just generates a lot of keys, and those are the keys that you use. When you restore a wallet, it just generates a lot of keys until it sees several that do not have any transactions associated with them. Because of the improbability of collisions, it is safe to assume that the coins it does find belongs to you and it is unlikely to generate private keys that belong to someone else. – Andrew Chow – 2017-11-29T15:32:08.197