Bitcoin Forum
May 09, 2024, 05:37:57 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2] 3 4 »  All
  Print  
Author Topic: Private Key lost one character  (Read 6355 times)
j55rrt (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
April 18, 2016, 11:03:09 AM
 #21

@deepceleron: thanks for the info, i never tought about the problem like that.

Since it seems to be an interesting problem, i'll try to write a perl script to take a private key in WIF format with x missing letters as input, and permutate all allowed characters in this string, test if the permutated pk is valid and write all the valid keys to a logfile (or import them in bitcoin core directly).

Since this is a bit more difficult, and i can only work on the problem during my luchbreak, it might take a couple of days tough.

I cann't appreciate enough for your help Cheesy . Take your time, this is not a problem.
1715276277
Hero Member
*
Offline Offline

Posts: 1715276277

View Profile Personal Message (Offline)

Ignore
1715276277
Reply with quote  #2

1715276277
Report to moderator
1715276277
Hero Member
*
Offline Offline

Posts: 1715276277

View Profile Personal Message (Offline)

Ignore
1715276277
Reply with quote  #2

1715276277
Report to moderator
"You Asked For Change, We Gave You Coins" -- casascius
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715276277
Hero Member
*
Offline Offline

Posts: 1715276277

View Profile Personal Message (Offline)

Ignore
1715276277
Reply with quote  #2

1715276277
Report to moderator
1715276277
Hero Member
*
Offline Offline

Posts: 1715276277

View Profile Personal Message (Offline)

Ignore
1715276277
Reply with quote  #2

1715276277
Report to moderator
1715276277
Hero Member
*
Offline Offline

Posts: 1715276277

View Profile Personal Message (Offline)

Ignore
1715276277
Reply with quote  #2

1715276277
Report to moderator
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
April 20, 2016, 12:33:33 PM
 #22

It isn't finished (yet), i just had 10 minutes over my lunchbreak, so i made a first "draft".. No checking for correct keys ATM.
Just enter the characters that can be used to insert into your key in the $db string, and the key (missing 1 character) in the $privatekey_wif string, and the script will generate all possible combinations...

It should run on windows  Undecided with activestate perl, without any extra modules... It's untested, and i don't take any blame if things go wrong  Grin

You can take this script, and invoke any windows command (like bitcoin-cli  importprivkey $key) and make this work, or you can wait untill i've included a checking-function (if and when i find the time to do this).


Code:
#!c:\perl64\bin\perl.exe
$db = "allvalidcharacters";
$privatekey_wif="mykeymissingonecharacter";
@delen = split('',$privatekey_wif);
@letters = split('',$db);
$length = length($privatekey_wif);
for ($position = 0; $position < $length+1; $position++)
{
foreach(@letters)
{
@new = @delen;
splice(@new, $position, 0, $_);
print join('',@new)."\n";
}
}

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
kn_b_y
Newbie
*
Offline Offline

Activity: 26
Merit: 3


View Profile
April 28, 2016, 01:09:54 AM
Last edit: April 28, 2016, 11:48:44 AM by kn_b_y
Merited by ABCbits (3)
 #23

Here's a script in python which uses deepceleron's idea of using the checksum to filter out bad candidates.

It does depend on python-bitcoinlib.
https://github.com/petertodd/python-bitcoinlib

Code:
import bitcoin.base58
from bitcoin.core import b2x, x
from bitcoin.wallet import CBitcoinSecret, P2PKHBitcoinAddress
from bitcoin.core import Hash

def insert_char(string, char, i):
    return string[:i+1]+char+string[i+1:]

def verify_wif_checksum(wif):
    byte_string = b2x(bitcoin.base58.decode(wif))
    private = byte_string[:-8]
    checksum = byte_string[-8:]
    return checksum == b2x(Hash(x(private)))[:8]

def candidate_wifs(corrupted_wif):
    candidates = []
    for i in range(len(corrupted_wif)):
        for char in bitcoin.base58.B58_DIGITS:
            candidate_wif = insert_char(corrupted_wif, char, i)
            if verify_wif_checksum(candidate_wif):   
                candidates.append(candidate_wif)
    return candidates


# Provide a WIF private key with a single missing character.
corrupted_wif = '5HueCGU8rMjxEXxiPuD5BDku4kFqeZyd4dZ1jvhTVqvbTLvyTJ'
#   Should be:  '5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ'

for candidate_wif in candidate_wifs(corrupted_wif):
    print(candidate_wif)

It should hopefully output any candidate private keys.

For example:
5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ
xhomerx10
Legendary
*
Offline Offline

Activity: 3836
Merit: 8024



View Profile
April 28, 2016, 02:48:39 AM
 #24

Hi,

I wrote my private key on the paper, and i tried to retrieve the btc from the address recently, but found my private key only contain 50 characters! It is my mistake when record down the private key!!

The private key format is WIF without any compressed, base58, start with "5".
I've 50 characters on hand, is there any brute force tools to calculate the key in quick way?

Thank you.

  How many coins are stored in the address?
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
April 28, 2016, 06:07:21 AM
 #25

Seems like kn_b_y solved your problem  Grin
@kn_b_y: nice work man, just a little tip: try to avoid posting real private keys... The address you generated was empty (luckily), but still used, so if it's part of a wallet of yours, it might be a good idear to "freeze" it, so you don't accidently receive any coins in it...

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
kn_b_y
Newbie
*
Offline Offline

Activity: 26
Merit: 3


View Profile
April 28, 2016, 10:02:13 AM
 #26

Seems like kn_b_y solved your problem  Grin
@kn_b_y: nice work man, just a little tip: try to avoid posting real private keys... The address you generated was empty (luckily), but still used, so if it's part of a wallet of yours, it might be a good idear to "freeze" it, so you don't accidently receive any coins in it...

Thanks. I'm available for work.  Wink Anybody??

Yeah, I too was curious to see if the address had been used before and noticed some activity.

It's not a key I generated. It's the one from deepceleron's post which is also used in the WIF docs at:
https://en.bitcoin.it/wiki/Wallet_import_format
kn_b_y
Newbie
*
Offline Offline

Activity: 26
Merit: 3


View Profile
April 28, 2016, 11:51:07 AM
Last edit: April 28, 2016, 02:17:31 PM by kn_b_y
 #27

Seems like kn_b_y solved your problem  Grin
@kn_b_y: nice work man, just a little tip: try to avoid posting real private keys... The address you generated was empty (luckily), but still used, so if it's part of a wallet of yours, it might be a good idear to "freeze" it, so you don't accidently receive any coins in it...

Though I noticed the generated address was incorrect - a potential hazzard!

So I've edited the post.
immangrace
Full Member
***
Offline Offline

Activity: 196
Merit: 100


View Profile
April 30, 2016, 04:49:27 PM
 #28

The possibilities to find the missing character seems simple. It is very hard to find it correct. If you're not sure the place of the character in your private key, it may be impossible to generate the correct address.

mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
May 02, 2016, 09:45:42 AM
 #29

The possibilities to find the missing character seems simple. It is very hard to find it correct. If you're not sure the place of the character in your private key, it may be impossible to generate the correct address.

If you read the code kn_b_y has produced, you'll see that it's not only possible, but even not that hard to do... If you're not familiar with python, i already gave a basic start on how to solve the problem with perl (altough kn_b_y's version is a lot better, it only produces valid private keys)

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
j55rrt (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
June 10, 2016, 05:57:00 AM
 #30

Here's a script in python which uses deepceleron's idea of using the checksum to filter out bad candidates.

It does depend on python-bitcoinlib.
https://github.com/petertodd/python-bitcoinlib

Code:
import bitcoin.base58
from bitcoin.core import b2x, x
from bitcoin.wallet import CBitcoinSecret, P2PKHBitcoinAddress
from bitcoin.core import Hash

def insert_char(string, char, i):
    return string[:i+1]+char+string[i+1:]

def verify_wif_checksum(wif):
    byte_string = b2x(bitcoin.base58.decode(wif))
    private = byte_string[:-8]
    checksum = byte_string[-8:]
    return checksum == b2x(Hash(x(private)))[:8]

def candidate_wifs(corrupted_wif):
    candidates = []
    for i in range(len(corrupted_wif)):
        for char in bitcoin.base58.B58_DIGITS:
            candidate_wif = insert_char(corrupted_wif, char, i)
            if verify_wif_checksum(candidate_wif):   
                candidates.append(candidate_wif)
    return candidates


# Provide a WIF private key with a single missing character.
corrupted_wif = '5HueCGU8rMjxEXxiPuD5BDku4kFqeZyd4dZ1jvhTVqvbTLvyTJ'
#   Should be:  '5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ'

for candidate_wif in candidate_wifs(corrupted_wif):
    print(candidate_wif)

It should hopefully output any candidate private keys.

For example:
5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ


Hi, the script run perfectly as i did some test. Many thanks!  Wink
However, it show no result when i insert my 50 characters private key. I'm completely out of clue now.... Huh
Rune
Legendary
*
Offline Offline

Activity: 1229
Merit: 1001


View Profile
June 12, 2016, 05:06:28 PM
 #31

This is a pretty common problem when recording such a long key.
Always best to test the recorded key before sending bitcoins to it.

I am curious as to how much bitcoins are stuck there for now?
j55rrt (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
June 16, 2016, 06:12:42 AM
 #32

This is a pretty common problem when recording such a long key.
Always best to test the recorded key before sending bitcoins to it.

I am curious as to how much bitcoins are stuck there for now?

>10 btc Sad
j55rrt (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
June 16, 2016, 06:25:15 AM
 #33

i stored the altcoin in bitcoin address and it was generated from bitaddress, subsequently import the address in omniwallet to view/transfer the coins.

1. 50 characters private key on hand under WIF format, start with "5".
2. I cann't import my private key into omniwallet, now i recall i used to be imported before...but not sure i copy it from clipboard or on my paper written paper.
3. subsequently i found bitaddress private key was generated with 51 characters, and i suspect my 50 characters written on paper was incorrect, and it should be 51 char instead...

Thank you for all dudes in assist to provide the script to find the missing char, but no smiling from lucky lady  Huh Angry
PantminerS7
Full Member
***
Offline Offline

Activity: 165
Merit: 100


View Profile
June 16, 2016, 06:36:07 AM
 #34

I know it's gonna be a trust issue, but if I were you, I'd ask someone for help with running the scripts. Maybe one of the coders that were helping you. You are running a windows computer, right?
j55rrt (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
June 16, 2016, 06:45:46 AM
 #35

I know it's gonna be a trust issue, but if I were you, I'd ask someone for help with running the scripts. Maybe one of the coders that were helping you. You are running a windows computer, right?

i've ran the script on linux, and it work perfectly to find missing one character with others bitcoin private key.
The issue is my key written on paper just simply doesn't work out as expected , no ideas where gone wrong...hehe
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1032



View Profile WWW
June 16, 2016, 06:50:54 AM
 #36

.... all we need to do is feed different text possibilities into the validator logically. It may be possible to programmatically find the private key with several characters mistranscribed or missing:

- Starts with "5"? No? Add "5" if missing characters; substitute "5" if right length; add "5" and drop other characters if right length;
- Correct Length: substitute alternate upper/lower case for one character, check all positions for one character wrong, then iterate for increasing numbers of multiple incorrect cases, incorrect letters, etc;
- Missing one character? Try adding all Base58 characters at all positions.

Missing two characters? It becomes a slightly harder problem. Adding two characters in all possible positions = 3,956,064 possibilities (if the 5 at the start is correct). Single-threaded python does about 300,000 SHA256 hashes a second on my PC, so probably less than a minute to try all.

This might be an interesting programming project, but I wouldn't bother until it's actually going to recover some Bitcoins.

It sounds like the private key may need more massaging to recover, whether programmatically, or by analysis of what was written down. I would start by analyzing how you transcribed the private key to paper, and think for yourself where you were and how it might have been written in error. Did you lose your place when writing it down, are there any letters close to each other that repeat? Did you make a mistake in lower/upper case when transcribing. Picture yourself with pen and paper in one hand and screen, you will be your own best resource for figuring out how it might have gone wrong.

Programming a solution to "brute force" what was written down now needs to be informed about further possible ways that mistakes were made.
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
June 16, 2016, 06:58:37 AM
 #37

I know it's gonna be a trust issue, but if I were you, I'd ask someone for help with running the scripts. Maybe one of the coders that were helping you. You are running a windows computer, right?

i've ran the script on linux, and it work perfectly to find missing one character with others bitcoin private key.
The issue is my key written on paper just simply doesn't work out as expected , no ideas where gone wrong...hehe

Well, if you did this:
  • generated a new private key
  • removed 1 character
  • ran it trough kn_b_y's script
  • got some valid private keys back, imported them, worked ok
You can be pretty sure you're doing it right Wink

But you cannot run the private key you have on paper trough the same script (0 outputs), chances are pretty high the string you have on paper isn't correct to begin with Sad
A private key in WIF is indeed 51 characters (if i'm not mistaking), so i'm finding it a bit odd...

you say you:
  • generated a private key with bitaddress (i can only assume that's the online bitaddress.org, or maybe the downloaded sourcecode)
  • if i'm not mistaking, bitaddress gives you a Private Key WIF Compressed (52 characters base58, starts with a 'K' or 'L')
  • since your private key starts with a 5, you might have clicked on 'wallet details', so you can see the private key wif compressed, private key wif (51 characters, starts with 5), Private Key Hexadecimal Format and Private Key Base64
  • To begin with, i find it odd that you would have saved the private key wif, instead of the private key wif compressed (since that's the default one)
  • are you sure you already imported in in a wallet like that?

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
j55rrt (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
June 16, 2016, 07:00:04 AM
 #38

.... all we need to do is feed different text possibilities into the validator logically. It may be possible to programmatically find the private key with several characters mistranscribed or missing:

- Starts with "5"? No? Add "5" if missing characters; substitute "5" if right length; add "5" and drop other characters if right length;
- Correct Length: substitute alternate upper/lower case for one character, check all positions for one character wrong, then iterate for increasing numbers of multiple incorrect cases, incorrect letters, etc;
- Missing one character? Try adding all Base58 characters at all positions.

Missing two characters? It becomes a slightly harder problem. Adding two characters in all possible positions = 3,956,064 possibilities (if the 5 at the start is correct). Single-threaded python does about 300,000 SHA256 hashes a second on my PC, so probably less than a minute to try all.

This might be an interesting programming project, but I wouldn't bother until it's actually going to recover some Bitcoins.

It sounds like the private key may need more massaging to recover, whether programmatically, or by analysis of what was written down. I would start by analyzing how you transcribed the private key to paper, and think for yourself where you were and how it might have been written in error. Did you lose your place when writing it down, are there any letters close to each other that repeat? Did you make a mistake in lower/upper case when transcribing. Picture yourself with pen and paper in one hand and screen, you will be your own best resource for figuring out how it might have gone wrong.

Programming a solution to "brute force" what was written down now needs to be informed about further possible ways that mistakes were made.

hehe, i hope i knew where it went wrong  Huh, and it is impossible to recall.... Cry
j55rrt (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
June 16, 2016, 07:06:21 AM
 #39

I know it's gonna be a trust issue, but if I were you, I'd ask someone for help with running the scripts. Maybe one of the coders that were helping you. You are running a windows computer, right?

i've ran the script on linux, and it work perfectly to find missing one character with others bitcoin private key.
The issue is my key written on paper just simply doesn't work out as expected , no ideas where gone wrong...hehe

Well, if you did this:
  • generated a new private key
  • removed 1 character
  • ran it trough kn_b_y's script
  • got some valid private keys back, imported them, worked ok

But you cannot run the private key you have on paper trough the same script (0 outputs), chances are pretty high the string you have on paper isn't correct to begin with Sad
A private key in WIF is indeed 51 characters (if i'm not mistaking), so i'm finding it a bit odd...

you say you:
  • generated a private key with bitaddress (i can only assume that's the online bitaddress.org, or maybe the downloaded sourcecode)
  • if i'm not mistaking, bitaddress gives you a Private Key WIF Compressed (52 characters base58, starts with a 'K' or 'L')
  • since your private key starts with a 5, you might have clicked on 'wallet details', so you can see the private key wif compressed, private key wif (51 characters, starts with 5), Private Key Hexadecimal Format and Private Key Base64
  • To begin with, i find it odd that you would have saved the private key wif, instead of the private key wif compressed (since that's the default one)
  • are you sure you already imported in in a wallet like that?

yes, it is from bitaddress.org.
My private key start with 5KALGPT****.

Based on bitaddress, private key with 52 characters base58, starts with a 'K' or 'L
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
June 16, 2016, 07:22:37 AM
 #40


yes, it is from bitaddress.org.
My private key start with 5KALGPT****.

Based on bitaddress, private key with 52 characters base58, starts with a 'K' or 'L

Indeed, default they'll give you a WIF Compressed private key, starting with K or L, so i wonder what happened since you ended up with 50 letters starting with a 5.
The two things popping to mind:

1) you used the wallet details to get a private key in WIF format, written it down and forgot 1 letter... Maybe even switched some other letters or couldn't read your handwriting
2) you've written down the WIF compressed PK, but forgot the initial K or L AND one extra letter... The odds of the second letter in the WIF compressed pk being 5 is pretty small tough...

I have to ask: is there any chance you might have printed out the page from bitaddress... Chances of mixing up letters and bad handwriting are pretty small on a printed piece of paper.... I know, it's a longshot, but it's certainly worth your effort to try and remember this

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: « 1 [2] 3 4 »  All
  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!