2

I have a known amount encoded in ecdhInfo. I can decrypt ecdhInfo according to this formula:

amount = 8 byte encrypted amount XOR first 8 bytes of keccak("amount" || Hs(8aR||i))

How can I get a decimal value out of this decrypted 64bit field? Or, what type of variable is it after decrypting? I am working in C and want to avoid floats.

ivanahepjuk
  • 149
  • 5
  • "How can I get a decimal value out of this decrypted 64bit field?" <- The result is a decimal (base-10) value. Can you perhaps rephrase the question? – jtgrassie Dec 03 '19 at 04:04

1 Answers1

3

It is a 64 bit little endian unsigned integer.

If you're asking "how do I get a human amount out of an atomic unit number", divide by 1e12. cryptonote::print_money in the Monero source does this without using floating point operations (print the number, then manipulate the string).

user36303
  • 34,858
  • 2
  • 57
  • 123