monero-docs/docs/public-address/subaddress.md

74 lines
3.6 KiB
Markdown
Raw Normal View History

2017-12-22 22:11:36 +00:00
# Subaddress
2017-12-26 00:51:22 +00:00
Subaddresses serve two purposes described below.
2017-12-22 22:11:36 +00:00
## Prevent payer from linking your payouts together
2017-12-26 00:51:22 +00:00
To prevent the payer from linking your payouts together simply generate a new subaddress for each payout.
This way services like [Shapeshift](https://shapeshift.io) wouldn't know it is you again receving Monero.
Note it won't help if you have an account with the service. Then your payouts are already linked in the service database, regardless of Monero.
2017-12-22 22:11:36 +00:00
## Group incoming payments
Think income streams.
2017-12-26 00:51:22 +00:00
Subaddresses allow to group incoming transactions within a single wallet.
2017-12-22 22:11:36 +00:00
2017-12-26 00:51:22 +00:00
User interface allows to assign convenience labels to subaddresses.
2017-12-22 22:11:36 +00:00
2017-12-26 00:51:22 +00:00
You may want to organize your incoming funds into a streams like "donations", "work", etc.
2017-12-22 22:11:36 +00:00
2017-12-26 00:51:22 +00:00
This is similar to subaccounts in your bank account. There is a very important difference though.
In Monero funds don't really sit on public addresses. Public addresses are conceptually a gateway or a routing mechanism. Funds sit on the unspent outputs. Thus, a single transaction can aggregate and spent outputs from multiple addresses.
2017-12-22 22:11:36 +00:00
## Why not multiple wallets?
2017-12-26 00:51:22 +00:00
The advantage over creating multiple wallets is that you only have a **single seed** to manage.
All subaddresses can be derived from the wallet seed.
2017-12-22 22:11:36 +00:00
2017-12-26 00:51:22 +00:00
Additionally, you conveniently manage your subaddresses within a single user interface.
2017-12-22 22:11:36 +00:00
## Wallet level feature
Subaddresses are a wallet-level feature to construct and interpret transactions. They do not affect the consensus.
2017-12-26 00:51:22 +00:00
## Data structure
2017-12-22 22:11:36 +00:00
2017-12-26 00:51:22 +00:00
Subaddress has a dedicated "network byte":
2017-12-22 22:11:36 +00:00
Index | Size in bytes | Description
------------|------------------|-------------------------------------------------------------
0 | 1 | identifies the network and address type; [42](https://github.com/monero-project/monero/blob/784f7b07f05a645d43f62ed3a9cefda4b0c57825/src/cryptonote_config.h#L153) - main chain; [63](https://github.com/monero-project/monero/blob/784f7b07f05a645d43f62ed3a9cefda4b0c57825/src/cryptonote_config.h#L167) - test chain
2017-12-28 21:23:29 +00:00
Otherwise the data structure is the same as for [standard address](/public-address/standard-address/).
2017-12-26 00:51:22 +00:00
Each subaddress conceptually has an index (with 0 being the base standard address).
The index is not directly included in subaddress structure but is used as input to create the private spend key.
## Generating
The private key `m` related to a subaddress is derived as follows:
m = Hs(a || i)
Where:
* `Hs` is a Keccak-256 hash function interpreted as integer and modulo `l` (maximum Ed25519 scalar)
* `a` is a private view key
* `i` is a subaddress index
TODO: describe rest of the procedure.
2017-12-26 00:51:22 +00:00
## Caveates
* Subaddress **cannot** be used to receive transactions having multiple destinations (e.g. pool payouts). Only the standard address (the one with index == 0) can receive such transactions.
* It is not recommended to sweep all the balances of subaddress to main address in a single transaction. That links the subaddresses together on the blockchain. However, this only concerns privacy against specific sender and the situation will never get worse than not using subaddresses in the first place. If you need to join funds while preserving maximum privacy do it with individual transactions (one per subaddress).
* Convenience labels are not preserved when recreating from seed.
2017-12-22 22:11:36 +00:00
## Reference
* [https://github.com/monero-project/monero/pull/2056](https://github.com/monero-project/monero/pull/2056)
* [https://www.reddit.com/r/Monero/comments/5vgjs2/subaddresses_and_disposable_addresses/](https://www.reddit.com/r/Monero/comments/5vgjs2/subaddresses_and_disposable_addresses/)