Bitcoin Forum
May 27, 2024, 02:56:44 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: WIF checksum  (Read 372 times)
evanuz (OP)
Newbie
*
Offline Offline

Activity: 60
Merit: 0


View Profile
July 27, 2017, 06:55:02 PM
 #1

Hey, i am trying to make a validation of WIF (Wallet Import Format).

Following the wiki: https://en.bitcoin.it/wiki/Wallet_import_format

In step two, i have to Convert it to a byte string using Base58Check encoding

I am using python , therefore:

Code:
import base58
hexwif=str.encode("5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ")
enco=base58.b58encode_check(hexwif)
data=bytes(enco,"ascii")
l=list(data)

If i print data it gives me this output

[75, 120, 109, 118, 51, 117, 90, 90, 107, 69, 50, 100, 99, 89, 107, 65, 115, 113, 97, 99, 115, 90, 76, 70, 100, 82, 103, 52, 87, 102
, 97, 109, 66, 109, 115, 53, 84, 101, 120, 87, 111, 97, 68, 71, 114, 109, 102, 75, 105, 119, 82, 82, 98, 54, 87, 114, 89, 104, 69, 7
1, 117, 117, 90, 81, 53, 49, 103, 99, 80, 109, 101, 107, 104, 71, 107]

Which is different from what i should obtain according to the wiki.

Can somebody help me??

Thanks
DannyHamilton
Legendary
*
Offline Offline

Activity: 3402
Merit: 4656



View Profile
July 27, 2017, 07:36:07 PM
Merited by ABCbits (1)
 #2

Since the string you have is ALREADY base58check encoded, and you want to decode it back to its original bytes, try using:

enco=base58.b58decode_check(hexwif)

instead of

enco=base58.b58encode_check(hexwif)
evanuz (OP)
Newbie
*
Offline Offline

Activity: 60
Merit: 0


View Profile
July 27, 2017, 09:43:41 PM
 #3

Since the string you have is ALREADY base58check encoded, and you want to decode it back to its original bytes, try using:

enco=base58.b58decode_check(hexwif)

instead of

enco=base58.b58encode_check(hexwif)


Thanks for the reply

I have tried it like this:

Code:
import base58
hexwif=str.encode("5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ")
enco=base58.b58decode_check(hexwif)

And the output of enco is:

Code:
>>> enco
b"\x80\x0c(\xfc\xa3\x86\xc7\xa2'`\x0b/\xe5\x0b|\xae\x11\xec\x86\xd3\xbf\x1f\xbeG\x1b\xe8\x98'\xe1\x9dr\xaa\x1d"

Which looks more similar to what i should get but some parts are different is it because of some encoding i should convert it again?

evanuz (OP)
Newbie
*
Offline Offline

Activity: 60
Merit: 0


View Profile
July 27, 2017, 09:54:53 PM
 #4

Oh i find out it has to be converted to hex Cheesy Thx anyway
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!