3

During blockchain scanning I need to do:

P − Hs(aR)G

with every output in order to determie whether it is mine, or not.

Where in tx_json are P and R stored?

3

The full math you have to do is:

D = P - Hs(8aR || i)G, where i is a varint representing the index of the output. You then check whether D matches your main public spend key or any of your subaddress public spend keys. if it does, the output is destined for you.

The output public key P is in the json as vout.target.key. The transaction public key R is not separately listed, so you'll need to parse the extra field in the json and locate the txpubkey subfield.

The txextra field format is documented here: https://cryptonote.org/cns/cns005.txt

It's the "Tx public key" field mentioned in that document that you are interested in.

Also note that to support transactions with multiple subaddress recipients, there is also a new TX_EXTRA_TAG_ADDITIONAL_PUBKEYS field. If this field is present, then you'll need to check each output against the corresponding additional txpubkey listed in that field.

  • @jtgrassie Ah oops thanks, missed that P is in there. Why though would the txpubkey R be listed as "tx_hash"? – knaccc Mar 21 at 12:05
  • I would like to write python script, which is going through blockchain and for each output it sends P and R to hardware wallet, where I am determining if output is mine or not. So, I can get P from tx_json, but what is the best method for getting R ? How the tx_blob is structured? – ivanahepjuk Mar 21 at 12:07
  • @jtgrassie I'm not sure why you think that. I've messaged you on IRC so you can sanity check me. – knaccc Mar 21 at 12:20
  • 3
    Here's an example getting the tx pub key R out of the extra field. This is using the extra from this tx. – jtgrassie Mar 21 at 16:16
  • 1
    Size is a varint - the example is just a quick demo (I didn't bother adding varint decoding). – jtgrassie Apr 8 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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