# How to calculate Monero addresses for different account numbers?

And page 125 of Mastering Monero does a good job of describing how subaddresses associated with account #0 are calculated.

My question is, how are the deterministic Monero public spend and view keys calculated for accounts other than account #0?

Each account is simply another subaddress. Therefore the math is identical to the usual subaddresses calculation - it is still represented by an `i` index in:

PSi = Hs(pV0 || i) G + PS0

(using Mastering Monero's notation).

However, it's worth noting that the calculation for the subaddress secret key is actually `m = Hs(a || index_major || index_minor)`, and for its public key, `M = mG`, where `index_major` is the account index and `index_minor` is the subaddress index. Thus i is the concatenation of `index_major || index_minor`.

Therefore the Master Monero example is a little misleading. The subaddress, regardless of which account it is in, is actually calculated like:

PSij = Hs(pV0 || j || i) G + PS0

Or in the common notation used in the code and elsewhere:

``````m = Hs(a || index_major || index_minor)
M = mG
D = M + B
``````

`D` being your public view and spend keys for account # subaddress #.

• Oh thanks for the suggestion! – SerHack May 29 at 16:58