0
As we know, address reusability compromises both privacy and security.
My question is how Bitcoin wallets avoid address reusability?
Is wallet generates an address from index 1 and scan blockchain whether an address is used or not, until wallet finds an unspent address?
In case of HD wallets, whenever the user requests to generate a new address to receive address. Wallet generates an address from the very first index and checks whether the index is used or not until it reaches address that has not been used.
Is the wallet keeps state of unused address?
If the wallet is stateless, then determining unused address by generating the address from very first and looking up blockchain for the unused address is expensive?
I tried to find documentation of wallets such as Ledger, Airbitz, but i did not found it.
Edit: Note that I have knowledge of how seed, private and public keys are generated, as it is explained in detail BIP 32.
My question here is When a user requests to generate a new address how does wallet find that the address is previously unused?
If wallet generates an address from the very first index, scans blockchain whether the address is previously spent or not? until it finds the index new address to receive payment.
I think you did not understand my question or I could not explain it clearly. I have knowlege of how private key is generated from seed, as it is explained int detail BIP 32. – Infinity – 2018-03-01T14:35:52.340
Suppose i want to receive payment and i requests wallet to generate new address. I have already suppose recieve or spent amounts corresponding to first 50 addresses. Now this time when i request wallet to generate address, is wallet will generate address1 then checks via blockchain whether it is used or not. If used, then it generates address2 then checks via blockchain whether it is used or not. Until it generates address50 then it finds that address is unused. – Infinity – 2018-03-01T14:35:57.840
In other words, how does wallet generates an address and finds whether an address is previously used or not – Infinity – 2018-03-01T14:37:20.093
1As far as I know: A HD wallet stores an ID (integer) in the wallet file on your computer. In the beginning, it's 0 => it shows you address1. Then, you get funds on that address => wallet recognizes that if it's synced => It increments the ID => ID is 1 => it shows you a address2 to receive coins.... That should be possible 2^32 times. It does not check the synced blockchain everytime because it knows that you used the first 100 addresses if the stored ID is 100. But if you would remove the wallet data and restore everything from the seed, then it must check all the 100 addresses again. – ndsvw – 2018-03-01T15:08:48.487
Means it store index locally, and each time it refers that index to generate the address. In case it lost index, wallet traverse all indexes from beginning to generate the unused address. – Infinity – 2018-03-01T15:30:44.583