-
m-relay<rucknium:monero.social> If I use docs.getmonero.org/rpc-library/mone…rod-rpc/#get_block_header_by_height with `fill_pow_hash` = true, I can get a `pow_hash` of each block. How would I convert the hex `pow_hash` value into an integer, for example to get the value of `H` in this formula: monero.stackexchange.com/a/12046 ?
-
m-relay<rucknium:monero.social> And why do the zeros of `pow_hash` appear at the end of the hex string? In bitcoin, the zeros appear at the beginning.
-
moneromoooparse_hash256
-
m-relay<rucknium:monero.social> Thank you.
-
moneromoooIf you want true 256 bit divisions, use boost bigint. Or div256_64 for short divisors.
-
sech1it's a sequence of bytes (2 hex characters per byte)
-
sech1zeroes are in the end because LSB encoded
-
sech1so the first byte is the least significant byte, the last byte is the most significant byte (bits 248-255)
-
m-relay<rucknium:monero.social> This is what I have done:
-
m-relay<rucknium:monero.social> 1) Start with the original `pow_hash`, which has 64 hexadecimal "characters".
-
m-relay<rucknium:monero.social> 2) Convert this to individual "byte" elements by concatenating the pairs of hexadecimal elements, so we have 32 byte elements.
-
m-relay<rucknium:monero.social> 3) Reverse the ordering of the 32 byte elements, i.e. the put the first element last, then the second element in the penultimate place, etc.
-
m-relay<rucknium:monero.social> 4) Concatenate these bytes together, add a `0x` at the beginning, and use a function to convert this hexadecimal form into an arbitrary-precision integer.
-
m-relay<rucknium:monero.social> Is this correct? It seems to work. A large sample of blocks pass the appropriate difficulty hurdle.
-
m-relay<sneedlewoods_xmr:matrix.org> seems correct to me (for block: 3472006 the pow_hash: aa6f70cf7b1e67e60028e19b03ac2f8f5661c61017cd41377dee7c0000000000, integer value: 51393878524106522740461043578110141991369175320009076927949205418)
-
DataHoarderit's a 256-bit hash in little endian wire format :)
-
sech1Yes, this is correct
-
m-relay<rucknium:monero.social> Thanks, all. I am learning one byte at a time :)