2

Monero accounts and subaddresses are conceptually well illustrated at https://medium.com/@anhdres/how-moneros-accounts-and-subaddresses-work-in-monerujo-4fa7df0a58e4.

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?

jtgrassie
  • 19,601
  • 4
  • 17
  • 54
skaht
  • 1,576
  • 11
  • 19

1 Answers1

1

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 #.

Sources: device_default.cpp#L144 and device_default.cpp#L198

jtgrassie
  • 19,601
  • 4
  • 17
  • 54