function chomp( sequence o )
if length(o) and o[length(o)]='\n' then
return o[1..length(o)-1]
end if
return o
end function
constant pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
function decode_base_58(sequence s)
atom answer = 0
atom power_multicand = 1
for i = length(s) to 1 by -1 do
answer += power_multicand * (find(s[i],pszBase58)-1)
power_multicand *= 58
end for
return answer
end function
sequence line = chomp(gets(0))
? log(decode_base_58(line))/log(256)
You'll need EUPHORIA for this. (see openeuphoria.org) Here this decodes a wif sent to standard input and prints the log base 256 of the value. Now, if the smallest integer greater than or equal to this value is 38, then you need 38 bytes to represent it.
The fact that the numbers are not arbitrary length numbers means nothing for we only care about the magnitude. I ran this on a wif I got from my bitcoin client and got:
37.87505791
You need 38 bytes for this value. Arguably we should be able to import the wif I got from one client to another. I will try this. The most significant byte is 128 which is the magic number.