3

After decoding the amount from ecdh amount, we get the numbers which is obvious not in decimal, e.g. "0010a5d4e8000000".

Then we can transfer them into integer with the following python code and get "1000000000000" which means 1.0 xmr:

def hexToInt(h):
    s = binascii.unhexlify(h) #does hex to bytes
    bb = len(h) * 4 #I guess 8 bits / b
    return sum(2**i * ed25519.bit(s,i) for i in range(0,bb)) #does to int

Therefore, I am curious about what the standard it follows?

Mooooo
  • 459
  • 2
  • 8

1 Answers1

4

It's just the hex of a little-endian byte-order encoded number (i.e. when swapped around you get 0xE8D4A51000).

Perhaps this will help you see:

import struct
import binascii
bin = binascii.unhexlify('0010a5d4e8000000')
print(struct.unpack('<Q', bin)[0])
print(0xE8D4A51000)

unhexlify converts the hex to binary and the format specifier <Q used by unpack means unpack a 64 bit number which is stored little-endian byte-order.

MiniNero's hexToInt is just doing the same thing in a different way.

jtgrassie
  • 19,601
  • 4
  • 17
  • 54