Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: F.Developers on July 29, 2019, 04:41:46 PM



Title: Multiple addresses on multiple coins
Post by: F.Developers on July 29, 2019, 04:41:46 PM
How do exchange sites generate multiple different addresses for different users, i only know for Bitcoin. I want to know everything about this process, at least the technical part



Thanks.


Title: Re: Multiple addresses on multiple coins
Post by: TryNinja on July 29, 2019, 10:51:57 PM
Well, most coins have a full node software. The exchange runs their own node and use the software API to generate new addresses and link them to each user on their database. There is no way to describe the exact process for every coin because each has a different software, API and technical technical specifics, but the theory is pretty much the same.


Title: Re: Multiple addresses on multiple coins
Post by: Ryutaro on July 30, 2019, 05:20:00 AM
Quote
My guess is that they're using hierarchical deterministic wallets (HD wallets), and assigning each user successive keys from the derived chain of keys. HD wallets have a neat cryptographic property where you can have a seed that allows you to derive a sequence of public keys, but deriving the corresponding private keys requires a separate seed. That means that the server that assigns user deposit addresses can be incapable of accessing the corresponding private keys.
source (https://www.reddit.com/r/ethereum/comments/9m0dxo/how_do_exchanges_assign_deposit_addresses_to_users/)


Title: Re: Multiple addresses on multiple coins
Post by: HeRetiK on July 30, 2019, 09:15:09 AM
To extend on Ryutaro's quote regarding HD wallets: Imagine these wallets like a tree -- which is where the "hierarchical" part comes from. Each leaf is an address. Each small branch is a user account. Each big branch is a cryptocurrency. Each big branch grows from a trunk that grows out of a seed.

In more technical terms, the seed is random binary data from where in the end every private key is derived from. As a user you will commonly see this in form of a BIP-39 mnemonic seed phrase:
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Using this seed, the tree is "grown" according to BIP-32 and BIP-44:
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki

With each cryptocurrency branch having their own derivation path according to a coin type as registered and documented in SLIP-44:
https://github.com/satoshilabs/slips/blob/master/slip-0044.md

Note that it is possible to generate the public keys and the corresponding addresses independently of each address' private key. This is usually referred to as a watch-only wallet and is necessary for security to allow for cold storage while still being able to automatically generate addresses.

Also note that the actual implementation may widely differ from exchange to exchange.


Title: Re: Multiple addresses on multiple coins
Post by: seoincorporation on July 30, 2019, 03:54:31 PM
... I want to know everything about this process, at least the technical part

The technical part of this could be done with different code languages. In my experience, I have worked with JS on a process similar, you need a bitcoin core wrapper and a database. This way you can make a call from JS to bitcoin core and this way create the new address, after that save that address on a variable, the last step is to write the new address on the database where you have the users data.

If you search in google 'bitcoin wrapper' you will find the codes to do it.


Title: Re: Multiple addresses on multiple coins
Post by: bitmover on July 31, 2019, 12:02:56 AM
To complement Heretik answer.

I think you can play by yourself in this website, and you will see how  HD wallets works. It is a very illustrative exercise.
https://www.iancoleman.io/bip39

Insert a seed there. Then you choose the coin you want. You will see that many public address and privatekeys were generated from that seed.

Now go and choose another coin.
You can also play with derivation path (segwit/legacy for example)s and account numbers (for different users )

You will soon realize that the same sed can generate almost unlimited addresses for each coin  (unlimited to our limited perspective as humans, but there are only a few billions per seed).