Bitcoin Forum
May 22, 2024, 12:08:58 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Correct / incorrect WIF  (Read 211 times)
math09183 (OP)
Member
**
Offline Offline

Activity: 170
Merit: 58


View Profile
June 29, 2020, 07:54:50 AM
Last edit: June 29, 2020, 08:15:06 AM by math09183
Merited by suchmoon (4), OmegaStarScream (2), joniboini (2)
 #1

Hello

We know that WIF has checksum. I use bitcoin-core library for reading WIF and then retrieving address etc. Usually, when I provide wrong (synthetically incorrect) WIF, parser complains. But recently I have found a few WIFs which are accepted, pubKey is retrieved etc, even if checksum is wrong. What I am missing?

KztWMvdFrpEScTmRBVwfmtzqYzb1rcu5PKGGKf6FUij16N2NYS88
retrieved:
priv: 6d786c3b9976d286362f4969d3fdf7ccd6abe2314e7435bd7c270837ab19a28e
pub: (d4b8c48cd5633ea6bdd2f282f70901b1d9b120631c155263737fdb1f4ef06ace,ffca79e0ca3d894d1f6e26690c0feac80dc9039b084de3b646e15b39d3c02be5,c737176f36ac61ce342338898eba8f65539ee6727b74445b31f9597407c0caf6)
address:
18NYbvmXvQ2nducAyGJ8wrsUnyJ5rZc5RD

but checking for example on: https://learnmeabitcoin.com/guide/wif
checksum is incorrect, it should be:
KztWMvdFrpEScTmRBVwfmtzqYzb1rcu5PKGGKf6FUij164yixbkN


nc50lc
Legendary
*
Offline Offline

Activity: 2422
Merit: 5614


Self-proclaimed Genius


View Profile
June 29, 2020, 09:37:09 AM
 #2

The private key KztWMvdFrpEScTmRBVwfmtzqYzb1rcu5PKGGKf6FUij16N2NYS88 has the correct checksum but the "Compressed flag" is '0x99' instead of '0x01'.
In HEX: 806d786c3b9976d286362f4969d3fdf7ccd6abe2314e7435bd7c270837ab19a28e99029474a9
Green = Private key | Purple = Checksum | The Byte after the private key should be the 'compressed public key' flag.

The correct WIF should be: KztWMvdFrpEScTmRBVwfmtzqYzb1rcu5PKGGKf6FUij164yixbkN if you set "01" as the flag instead of "99".

Surprisingly, '99' flag resulted in 'K' or 'L' in every random private key that I've tried  Undecided
But it wont work with well-written clients.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
June 29, 2020, 12:53:01 PM
 #3

Surprisingly, '99' flag resulted in 'K' or 'L' in every random private key that I've tried 

There are a bunch of different variations that could give similar looking key strings. Here are 3 examples from Bitcoin.Net test vectors:
Code:
5GPHYxaeAAqL2egjmyU8Kaaqh831aw12XJ92y2rgRWi1zc
L5HydKmZoMcqfoY9Rgi8BRnWGmDw9YhoUS9ArnToVxvyFbM9GyfJ
KwFAa6AumokBD2dVqQLPou42jHiVsvThY1n25HJ8Ji8REf1wxAQb
Same with BIP-32 extended keys.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
math09183 (OP)
Member
**
Offline Offline

Activity: 170
Merit: 58


View Profile
June 30, 2020, 07:57:41 AM
 #4

Surprisingly, '99' flag resulted in 'K' or 'L' in every random private key that I've tried  Undecided
But it wont work with well-written clients.

Apparently there is no check for this in bitcoinj library, it accepts WIFs not only with 99 (as long as checksum is OK):
L4V2zpTnbnoTqzfXiyBXsZiaJkPj926jYtxNK65wmGePWWHtzM3W (bf)

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!