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?

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.

| improve this answer | |
  • 1
    Thank you very much!! It's really clear! – Mooooo Jun 16 at 16:29

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.