1

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.

1 Answer 1

1

Is wallet generates an address from index 1 and scan blockchain whether an address is used or not, until wallet finds an unspent address?

No. The wallet software generates a seed (pseudo-random). With that seed, it generates private keys. With those private keys, it generates public keys and with those public keys, it generates addresses. And this address is (almost) always unused.

and checks whether the index is used or not until it reaches address that has not been used. ---- and ---- 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?

That's not how it works. The probability to hit an address that is already used (by the method seed->SK->PK->address) is almost 0 because you don't know the seed of other people. You don't need to check that because it's almost impossible (unless you have a lot of computer power and want to waste electricity).

Is the wallet keeps state of unused address?

The wallet simply check the funds of all your addresses, recognizes that your first address is used (has funds on it) and provides you a new one (also created by the same seed (seed->SK->PK->address).

5
  • 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
    Commented Mar 1, 2018 at 14:35
  • 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
    Commented Mar 1, 2018 at 14:35
  • In other words, how does wallet generates an address and finds whether an address is previously used or not
    – Infinity
    Commented Mar 1, 2018 at 14:37
  • 1
    As 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.
    – hardfork
    Commented Mar 1, 2018 at 15:08
  • 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
    Commented Mar 1, 2018 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.