pockets – Non-public key to WIF compressed: which one is appropriate?

0
4
pockets – Non-public key to WIF compressed: which one is appropriate?


That is how we are able to discover the WIF from a personal key:

private_key = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'
decoded_private_key = bitcoin.decode_privkey(private_key, 'hex')
wif = bitcoin.encode_privkey(decoded_private_key, 'wif')
# 5HpHgWkLaovGWySEFpng1XQ6pdG1TzNWR7SrETvfTRVdKHNXZh8

However the way to get the WIF compressed?

Ought to I do:

private_key = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'
compressed_private_key = private_key + '01'
wifcomp1 = bitcoin.encode_privkey(bitcoin.decode_privkey(private_key, 'hex'), 
             'wif_compressed')
# KwDidQJHSE67VJ6MWRvbBKAxhD3F48DvqRT6JRqrjd7MHLBjGF7V

or

wifcomp2 = bitcoin.encode_privkey(bitcoin.decode_privkey(compressed_private_key, 'hex'),  
            'wif_compressed')
# KwFfpDsaF7yxCELuyrH9gP5XL7TAt5b9HPWC1xCQbmrxfFzfMakg

It appears that evidently #1 is appropriate and never #2.


Additionally plainly:

  • the non-compressed WIF, imported in Electrum, produces lastly a non-compressed Base58 tackle,

  • the compressed WIF, imported in Electrum, produces lastly a compressed Base58 tackle

which appears apparent. However I might prefer to ensure that compression of WIF and compression of addresses on the finish is absolutely linked.

Can we conclude that using a compressed or non-compressed WIF (each encoding the identical personal key) will decide, when importing them in Electrum, if the public-key (and thus the tackle ultimately) will lastly be compressed or non-compressed?

LEAVE A REPLY

Please enter your comment!
Please enter your name here