Bitcoin Forum
September 27, 2018, 10:51:23 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: wif decodes longer than expected  (Read 656 times)
sdp
Sr. Member
****
Offline Offline

Activity: 425
Merit: 251



View Profile WWW
December 24, 2013, 03:13:54 PM
 #1

It looks as if my Satoshi client has a 33 byte secret.  Decoding the wif, which is a string I got from dumpprivkey.  Now, when decoded from base58 this much longer string should turn into something 37 bytes long.  Instead of that it is 38 bytes long.  Is there a longer magic number now?


██████████████████████████████████████████████
██████████████████████████████████████████████
█████                                    █████
█████                                    █████
█████                                    █████
█████           ▄█▄        ▄█▄           █████
█████          ████████████████          █████
█████           ▀████████████▀           █████
█████           ████▀    ▀████           █████
█████           ████▄    ▄████           █████
█████           ▄████████████▄           █████
█████          ████████████████          █████
█████           ▀█▀        ▀█▀           █████
█████                                    █████
█████                                    █████
█████                                    █████
██████████████████████████████████████████████
██████████████████████████████████████████████
▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██             ▄█▀███████████
██              ▀▀▀▀▀▀▀▀▀▀██▀
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██                        ██
████████████████████████████
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                 ▄███▀  ██
██             ▄▄██▀▀  ▄█ ██
██     ▄    ▄███▀▀  ▄███  ██
██    ██▄▄██▀▀   ▄█████   ██
██   ████▀▀  ▄▄██▀▀ ▀█    ██
██  █▀▀   ▄▄██▀           ██
██    ▄▄███▀              ██
██▄▄▄████▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██  ████▄  ▄▄▄▄▄▄▄▄▄▄▄▄   ██
██     ▀█▄ ▀▀▀▀▀▀▀▀▀██    ██
██      ██         ██     ██
██       ███████████      ██
██        ▄▄     ▄▄       ██
██       ▀██▀   ▀██▀      ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                       ▄██
██                     █████
██         ▄         ███▀ ██
██       ▄███     ▄███▀   ██
██   ▄▄███▀▀███▄████▀     ██
██▄▄███▀     ▀███▀        ██
████▀                     ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄███████████▄  ██████████████
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
██████▀██████  ██████▀███████
 ▀▀▀▀▀▀▀▀▀▀▀   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀
1538088683
Hero Member
*
Offline Offline

Posts: 1538088683

View Profile Personal Message (Offline)

Ignore
1538088683
Reply with quote  #2

1538088683
Report to moderator
1538088683
Hero Member
*
Offline Offline

Posts: 1538088683

View Profile Personal Message (Offline)

Ignore
1538088683
Reply with quote  #2

1538088683
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538088683
Hero Member
*
Offline Offline

Posts: 1538088683

View Profile Personal Message (Offline)

Ignore
1538088683
Reply with quote  #2

1538088683
Report to moderator
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1001



View Profile
December 24, 2013, 09:50:19 PM
 #2

compression flag?

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
sdp
Sr. Member
****
Offline Offline

Activity: 425
Merit: 251



View Profile WWW
December 26, 2013, 02:40:44 PM
 #3

Code:
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.


██████████████████████████████████████████████
██████████████████████████████████████████████
█████                                    █████
█████                                    █████
█████                                    █████
█████           ▄█▄        ▄█▄           █████
█████          ████████████████          █████
█████           ▀████████████▀           █████
█████           ████▀    ▀████           █████
█████           ████▄    ▄████           █████
█████           ▄████████████▄           █████
█████          ████████████████          █████
█████           ▀█▀        ▀█▀           █████
█████                                    █████
█████                                    █████
█████                                    █████
██████████████████████████████████████████████
██████████████████████████████████████████████
▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██             ▄█▀███████████
██              ▀▀▀▀▀▀▀▀▀▀██▀
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██                        ██
████████████████████████████
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                 ▄███▀  ██
██             ▄▄██▀▀  ▄█ ██
██     ▄    ▄███▀▀  ▄███  ██
██    ██▄▄██▀▀   ▄█████   ██
██   ████▀▀  ▄▄██▀▀ ▀█    ██
██  █▀▀   ▄▄██▀           ██
██    ▄▄███▀              ██
██▄▄▄████▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██  ████▄  ▄▄▄▄▄▄▄▄▄▄▄▄   ██
██     ▀█▄ ▀▀▀▀▀▀▀▀▀██    ██
██      ██         ██     ██
██       ███████████      ██
██        ▄▄     ▄▄       ██
██       ▀██▀   ▀██▀      ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                       ▄██
██                     █████
██         ▄         ███▀ ██
██       ▄███     ▄███▀   ██
██   ▄▄███▀▀███▄████▀     ██
██▄▄███▀     ▀███▀        ██
████▀                     ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄███████████▄  ██████████████
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
██████▀██████  ██████▀███████
 ▀▀▀▀▀▀▀▀▀▀▀   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀
sdp
Sr. Member
****
Offline Offline

Activity: 425
Merit: 251



View Profile WWW
December 26, 2013, 10:53:54 PM
 #4

I see now you have two possible sizes for the secret.  It might be 32 bytes or 33 bytes.  I have found a bug in libbitcoin.

██████████████████████████████████████████████
██████████████████████████████████████████████
█████                                    █████
█████                                    █████
█████                                    █████
█████           ▄█▄        ▄█▄           █████
█████          ████████████████          █████
█████           ▀████████████▀           █████
█████           ████▀    ▀████           █████
█████           ████▄    ▄████           █████
█████           ▄████████████▄           █████
█████          ████████████████          █████
█████           ▀█▀        ▀█▀           █████
█████                                    █████
█████                                    █████
█████                                    █████
██████████████████████████████████████████████
██████████████████████████████████████████████
▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██             ▄█▀███████████
██              ▀▀▀▀▀▀▀▀▀▀██▀
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██                        ██
████████████████████████████
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                 ▄███▀  ██
██             ▄▄██▀▀  ▄█ ██
██     ▄    ▄███▀▀  ▄███  ██
██    ██▄▄██▀▀   ▄█████   ██
██   ████▀▀  ▄▄██▀▀ ▀█    ██
██  █▀▀   ▄▄██▀           ██
██    ▄▄███▀              ██
██▄▄▄████▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██  ████▄  ▄▄▄▄▄▄▄▄▄▄▄▄   ██
██     ▀█▄ ▀▀▀▀▀▀▀▀▀██    ██
██      ██         ██     ██
██       ███████████      ██
██        ▄▄     ▄▄       ██
██       ▀██▀   ▀██▀      ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                       ▄██
██                     █████
██         ▄         ███▀ ██
██       ▄███     ▄███▀   ██
██   ▄▄███▀▀███▄████▀     ██
██▄▄███▀     ▀███▀        ██
████▀                     ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄███████████▄  ██████████████
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
██████▀██████  ██████▀███████
 ▀▀▀▀▀▀▀▀▀▀▀   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1001



View Profile
December 27, 2013, 02:32:37 AM
 #5

compression flag?

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
sdp
Sr. Member
****
Offline Offline

Activity: 425
Merit: 251



View Profile WWW
December 28, 2013, 04:51:21 AM
 #6


Yes, you were right.  I only used dumpprivkey and got a long string.  If the flag is true there is an extra byte before the checksum.  This library I am using handles only wifs with 37 byte secrets.

sdp

██████████████████████████████████████████████
██████████████████████████████████████████████
█████                                    █████
█████                                    █████
█████                                    █████
█████           ▄█▄        ▄█▄           █████
█████          ████████████████          █████
█████           ▀████████████▀           █████
█████           ████▀    ▀████           █████
█████           ████▄    ▄████           █████
█████           ▄████████████▄           █████
█████          ████████████████          █████
█████           ▀█▀        ▀█▀           █████
█████                                    █████
█████                                    █████
█████                                    █████
██████████████████████████████████████████████
██████████████████████████████████████████████
▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██             ▄█▀███████████
██              ▀▀▀▀▀▀▀▀▀▀██▀
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██                        ██
██                        ██
██                        ██
████████████████████████████
██                        ██
██                        ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                 ▄███▀  ██
██             ▄▄██▀▀  ▄█ ██
██     ▄    ▄███▀▀  ▄███  ██
██    ██▄▄██▀▀   ▄█████   ██
██   ████▀▀  ▄▄██▀▀ ▀█    ██
██  █▀▀   ▄▄██▀           ██
██    ▄▄███▀              ██
██▄▄▄████▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄██████████████████████████▄
██                        ██
██  ████▄  ▄▄▄▄▄▄▄▄▄▄▄▄   ██
██     ▀█▄ ▀▀▀▀▀▀▀▀▀██    ██
██      ██         ██     ██
██       ███████████      ██
██        ▄▄     ▄▄       ██
██       ▀██▀   ▀██▀      ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▄██████████████████████████▄
██                       ▄██
██                     █████
██         ▄         ███▀ ██
██       ▄███     ▄███▀   ██
██   ▄▄███▀▀███▄████▀     ██
██▄▄███▀     ▀███▀        ██
████▀                     ██
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄███████████▄  ██████████████
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
█           █  █            █
██████▀██████  ██████▀███████
 ▀▀▀▀▀▀▀▀▀▀▀   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!