2

Referring to the question 11272, I have an experiment with MiniNero:

tx_pub_key = "f6d51a0cabd6a68f2c4960bc06b4132d6b937622b8954ea95851aa5f3b32c1de"
pri_view_key = "89a705a1a6427e7a19fd17a78d4a5c35bcb9ce4af74d6c180d5e39909694ab0a"
aR = MiniNero.mul8(MiniNero.scalarmultKey(tx_pub_key, pri_view_key))
tmp = MiniNero.cn_fast_hash(aR+"00")
res = MiniNero.cn_fast_hash("616d6f756e74"+tmp) #616d6f756e74 is ASCII of "amount"

Then I get the result:

0e37ec1966076a6c5c6f15b1ad32f415b5f3e2426c1dc8c95c73b72cabe02168

The last step is to XOR each first 8-byte data:

amount = MiniNero.xor("54f95f7d7f4d1e2a", "0e37ec1966076a6c")

However, the result is not right. Am I doing something wrong? Please help to solve this, Thanks!

BTW, I get 54f95f7d7f4d1e2a from ecdhInfo (explorer)

2

You haven't reduced tmp. I.e.

tmp = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(aR+"00"))

Hs in the referenced question's answer refers to Hash to scalar, not simply hash. Otherwise keccak would have been written in place of Hs.

Thus, following your experiment through with the correction, I calculate 1 XMR:

tx_pub_key = "f6d51a0cabd6a68f2c4960bc06b4132d6b937622b8954ea95851aa5f3b32c1de"
pri_view_key = "89a705a1a6427e7a19fd17a78d4a5c35bcb9ce4af74d6c180d5e39909694ab0a"
aR = MiniNero.mul8(MiniNero.scalarmultKey(tx_pub_key, pri_view_key))
tmp = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(aR+"00"))
res = MiniNero.cn_fast_hash("616d6f756e74"+tmp) #616d6f756e74 is ASCII of "amount"
amount = MiniNero.xor("54f95f7d7f4d1e2a",res[:16])[:16]
print(MiniNero.hexToInt(amount)*1e-12)

Which yields:

1.0
| improve this answer | |
  • Thanks you very much!! BTW, does it indicate that it should multiple *1e-12 after the resource? Where can I find it? – Mooooo Apr 30 at 3:06
  • 1
    web.getmonero.org/resources/moneropedia/atomic-units.html - 1 XMR is 1,000,000,000,000 atomic units. As amounts are stored in atomic units, to view in XMR one must multiply by 1e-12. – jtgrassie Apr 30 at 3:08
  • Thank you! It's clear! – Mooooo Apr 30 at 3:25
  • May I know why it needs to hexToInt() in the last step? Is there a monero-project version of hexToInt()? Thanks! – Mooooo May 15 at 8:55
  • 1
    Because most of the MiniNero python methods return hex strings. The last step above needs it as an integer to multiply by 1e-12 to convert atomic units to XMR. – jtgrassie May 15 at 13:13

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.