<h1>TL;DR:</h1>
<p>You don't need to bruteforce anything here (at least almost), and can recover the missing last 7 characters on an average PC at home within <strong>less than 1 second</strong> using a simple Python script!</p>
<h1>In detail:</h1>
<p>In your picture there are <strong>7 characters missing</strong> at the end of the private key (<em>figured out by comparing with a test-printout using the same HTML file</em>).</p>
<p>Yes, it is correct that this key format is using <code>Base58</code> alphabet and therefore there are 58 possibilities per character, so for 7 characters you would need to try <code>58^7</code> possibilities (<em>which would be about 2 trillions</em>) in theory, but all these considerations are missing an important fact:</p>
<p>When such a private key (the format is called <code>WIF</code> short for <code>Wallet Import Format</code>, see also the <a href="https://developer.bitcoin.org/devguide/wallets.html" rel="nofollow noreferrer">reference documentation</a> here) is encoded, at the end (after the actual private key) 4 bytes are added as a checksum. So if these 4 bytes are missing (at the end) you can calculate it from the rest.</p>
<p><strong>Second</strong>: in your picture it looks like your private key starts with an <code>L</code>. This indicates that the Bitcoin address is based on a compressed public key. Don't worry, this is a technical detail, but this helps you further:
Private keys for compressed pubkeys have another special byte added after the key (and before the checksum), namely a fixed <code>0x01</code> (see also in the <a href="https://developer.bitcoin.org/devguide/wallets.html" rel="nofollow noreferrer">reference documenation for WIF</a>).</p>
<p><strong>This means that the last 5 bytes of a WIF encoded private key (starting with <code>L</code> or <code>K</code>) are either static or can be computed from the rest.</strong></p>
<p>So you are very lucky that the <em>last</em> 7 characters are missing (and not the <em>first</em> 7, because then you really would need to bruteforce 2 trillion possibilities).</p>
<h2>What to do with this information:</h2>
<p>If we apply this knowledge now to base58 we see that <strong>only a single character is missing</strong> and then we can calculate the rest.</p>
<p><strong>Reasoning</strong>: first: a single base58 character carries ~5.85799 = log2(58) bits of information and second: we don't need the last 40 bits (<em>4 bytes checksum + 1 static byte for compressed key are 5 bytes = 40 bits</em>).</p>
<p>So, if only 6 characters would be missing at the end (<code>6 * 5.85799.. = 35.14794</code>) we not need to bruteforce anything, because this would be still less than the 40 bits we don't need.</p>
<h2>Conclusion:</h2>
<p>As you are missing 7 characters we just need to bruteforce one single character (<em>and this means just 58 attempts, not 2 trillions</em>).
So we just attempt to add one of the 58 characters from the bas58 alphabet. For each attempt we calculate the full base58 string by adding the static compressed key flag byte (<code>0x01</code>) and after that the checksum and simply compare it with the rest of the key you have. If it matches it is a valid candidate.</p>
<p>At the end of these 58 attempts you will end up with 2 or 3 (at most) valid private key candidates, and just need to check these 3 keys, to see which one belongs to your address.</p>
<p>The Reddit user <a href="https://www.reddit.com/user/dooglus/" rel="nofollow noreferrer">/u/dooglus/</a> (not me) pointed out exactly this in the first place in his <a href="https://www.reddit.com/r/Bitcoin/comments/ipcanh/damaged_secret_key/g4pjnhi?utm_source=share&amp;utm_medium=web2x&amp;context=3" rel="nofollow noreferrer">comment on your post</a> and he also added a snippet of Python code which does exactly I've described above.</p>
<h2>Don't trust anybody, don't hand out your key to any stranger!</h2>
<p>Now take your time, learn what the Python script below does (don't trust me or any strangers) and when you feel safe, copy the Python snippet from <a href="https://www.reddit.com/user/dooglus/" rel="nofollow noreferrer">/u/dooglus/</a>'s comment, save it in a text-file named <code>complete-wif.py</code> on a safe computer. After that take the computer offline and run the Python script by typing this into a commandline:</p>
<p><code>python3 complete-wif.py L...-your-private-key-goes-here...yhub</code></p>
<p>and <strong>it will print 2 or 3 completed WIF private keys in less than 1 second</strong>.</p>
<h2>Appendix:</h2>
<p>For reference, I appended the Python script but it's not my work, all credits go to <a href="https://www.reddit.com/user/dooglus/" rel="nofollow noreferrer">/u/dooglus/</a>. I just can confirm that it does what I described above (but ask others to confirm this and try it with other private keys before you trust it with your real private key):</p>
<pre><code>#!/usr/bin/env python3

import base58, sys

partial = sys.argv[1]

if len(partial) != 45:
    print(&quot;partial key should be 45 characters&quot;)
    sys.exit(1)

results = {}
for c in '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz':
    wif = base58.b58encode_check(base58.b58decode(partial + c*7)[:33] + b'\x01').decode('ascii')
    if wif[:45] == partial: results[wif] = True

for k in results.keys(): print(k)
</code></pre>

CC BY-SA 4.0
2020-09-11T16:35:50.553Z
Thank you very much, I will try this method
gabalex
CC BY-SA 4.0
2020-12-25T04:38:23.150Z
Thanks for crediting me as you did. This whole question was only recently brought to my attention.
Chris Moore
CC BY-SA 4.0
2021-02-04T18:42:53.333Z
@chris-moore: of course, credit where credit is due. It was your work. You are welcome! :-)
Johannes Zweng
CC BY-SA 4.0
2020-09-11T09:21:37.943Z
2020-09-18T02:05:49.753Z
2020-09-18T02:05:49.753Z
Johannes Zweng
<p>It has to be brute forced. There are a couple of ways but basically it is replacing each character by base-58 chars and checking the key.<br />
The amount of time that process takes depends on the number of characters missing and slightly on whether the key is compressed or uncompressed and a little on your luck.</p>
<p>However if your key is compressed and is missing up to 11 characters or is uncompressed and is missing up to 9 characters <em>from its end</em> (which seems to be the case from your screenshot) it can be recovered within seconds.</p>
<p>Check out <a href="https://github.com/Coding-Enthusiast/FinderOuter" rel="nofollow noreferrer">FinderOuter</a> on GitHub. The Missing Base58 option handles your case. You'll have to enter the characters you already have and replace the missing ones with a special char like <code>*</code> then enter your address in second box and click <code>Find</code>.<br />
Full disclosure: I'm the developer of The FinderOuter.<br />
P.S. The released version (0.4.1) is old and doesn't have the optimization mentioned above, you'll have to compile the code yourself or wait for 0.5.0.<br />
Edit: Version 0.5.0 released on 2020-09-17 and can recovery this special case with up to 11 missing chars from end.</p>

CC BY-SA 4.0
2020-09-10T08:45:29.740Z
Unfortunately, I don't understand programming. My laptop has windows 10.
gabalex
CC BY-SA 4.0
2020-09-10T14:14:47.237Z
@gabalex: If I offered you a quarter of a million dollars to spend a week or two learning programming, would you consider it?
RedGrittyBrick
CC BY-SA 4.0
2020-09-10T22:00:45.020Z
@RedGrittyBrick even if it took a year to learn enough to complete this task, thats still a great wage for the time spent.
chytrik
CC BY-SA 4.0
2020-09-11T04:23:57.240Z
Unfortunately, I don’t have the money and a quick fix would be good.
gabalex
CC BY-SA 4.0
2020-09-11T15:36:48.867Z
@gabalex You don't need to spend money to recover this wallet, you can learn all of those things on Youtube for free. Keep in mind that even if it takes a long time this is a lot of money, so it is worth it.
Luca Blight
CC BY-SA 4.0
2020-09-10T07:48:25.257Z
2020-09-17T05:34:21.440Z
2020-09-17T05:34:21.440Z
Coding Enthusiast
<p>I found this paper among my old stuff.
What can you do with it?
Is there any way to fill in the missing part?</p>
<p><a href="https://i.sstatic.net/e87Ju.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/e87Ju.jpg" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2020-09-10T08:58:47.317Z
Be very, very careful - The address has over 25 BTC in it - do not accept offers of help from anyone, do not give the part of the key that you have to anyone or any software without fully understanding what you are doing. While I don't normally do this, given the amount of BTC at stake here, there's an email in my profile, reach out if you have any questions
Raghav Sood
CC BY-SA 4.0
2020-09-10T14:10:04.457Z
I'm pretty certain Raghav is completely trustworthy. However I expect dozens of scammers may be  busy working out how they can pretend to be him and contact you. Remember that email addresses are easily faked and it isn't hard to set up other social media accounts in someone else's name (or with minor variations of their name). Just be very very careful.
RedGrittyBrick
CC BY-SA 4.0
2022-07-03T15:22:36.230Z
As a general case you can brute-force it. 
https://github.com/salian/btc-incomplete-key
Pranab
<private-key><wallet-recovery><recover-private-key><lost-wallet>
How can I recover the missing end of my private key?
gabalex
# How can I recover the missing end of my private key?

(Asked by: username_0 on 2020-09-10)

I found this paper among my old stuff.
What can you do with it?
Is there any way to fill in the missing part?

[![enter image description here](https://i.sstatic.net/e87Ju.jpg)](https://i.sstatic.net/e87Ju.jpg)

**Tags:** private-key, wallet-recovery, recover-private-key, lost-wallet

> **Comments:**
> **username_1**: Be very, very careful - The address has over 25 BTC in it - do not accept offers of help from anyone, do not give the part of the key that you have to anyone or any software without fully understanding what you are doing. While I don't normally do this, given the amount of BTC at stake here, there's an email in my profile, reach out if you have any questions  
> **username_2**: I'm pretty certain username_1 is completely trustworthy. However I expect dozens of scammers may be  busy working out how they can pretend to be him and contact you. Remember that email addresses are easily faked and it isn't hard to set up other social media accounts in someone else's name (or with minor variations of their name). Just be very very careful.  
> **username_3**: As a general case you can brute-force it.  https://github.com/salian/btc-incomplete-key  

---

## 2 answers

### Answer by username_4 on 2020-09-11. Score: 6

# TL;DR:

You don't need to bruteforce anything here (at least almost), and can recover the missing last 7 characters on an average PC at home within **less than 1 second** using a simple Python script!

# In detail:

In your picture there are **7 characters missing** at the end of the private key (*figured out by comparing with a test-printout using the same HTML file*).

Yes, it is correct that this key format is using `Base58` alphabet and therefore there are 58 possibilities per character, so for 7 characters you would need to try `58^7` possibilities (*which would be about 2 trillions*) in theory, but all these considerations are missing an important fact:

When such a private key (the format is called `WIF` short for `Wallet Import Format`, see also the [reference documentation](https://developer.bitcoin.org/devguide/wallets.html) here) is encoded, at the end (after the actual private key) 4 bytes are added as a checksum. So if these 4 bytes are missing (at the end) you can calculate it from the rest.

**Second**: in your picture it looks like your private key starts with an `L`. This indicates that the Bitcoin address is based on a compressed public key. Don't worry, this is a technical detail, but this helps you further:
Private keys for compressed pubkeys have another special byte added after the key (and before the checksum), namely a fixed `0x01` (see also in the [reference documenation for WIF](https://developer.bitcoin.org/devguide/wallets.html)).

**This means that the last 5 bytes of a WIF encoded private key (starting with `L` or `K`) are either static or can be computed from the rest.**

So you are very lucky that the *last* 7 characters are missing (and not the *first* 7, because then you really would need to bruteforce 2 trillion possibilities).

## What to do with this information:

If we apply this knowledge now to base58 we see that **only a single character is missing** and then we can calculate the rest.

**Reasoning**: first: a single base58 character carries ~5.85799 = log2(58) bits of information and second: we don't need the last 40 bits (*4 bytes checksum + 1 static byte for compressed key are 5 bytes = 40 bits*).

So, if only 6 characters would be missing at the end (`6 * 5.85799.. = 35.14794`) we not need to bruteforce anything, because this would be still less than the 40 bits we don't need.

## Conclusion:

As you are missing 7 characters we just need to bruteforce one single character (*and this means just 58 attempts, not 2 trillions*).
So we just attempt to add one of the 58 characters from the bas58 alphabet. For each attempt we calculate the full base58 string by adding the static compressed key flag byte (`0x01`) and after that the checksum and simply compare it with the rest of the key you have. If it matches it is a valid candidate.

At the end of these 58 attempts you will end up with 2 or 3 (at most) valid private key candidates, and just need to check these 3 keys, to see which one belongs to your address.

The Reddit user [/u/dooglus/](https://www.reddit.com/user/dooglus/) (not me) pointed out exactly this in the first place in his [comment on your post](https://www.reddit.com/r/Bitcoin/comments/ipcanh/damaged_secret_key/g4pjnhi?utm_source=share&utm_medium=web2x&context=3) and he also added a snippet of Python code which does exactly I've described above.

## Don't trust anybody, don't hand out your key to any stranger!

Now take your time, learn what the Python script below does (don't trust me or any strangers) and when you feel safe, copy the Python snippet from [/u/dooglus/](https://www.reddit.com/user/dooglus/)'s comment, save it in a text-file named `complete-wif.py` on a safe computer. After that take the computer offline and run the Python script by typing this into a commandline:

`python3 complete-wif.py L...-your-private-key-goes-here...yhub`

and **it will print 2 or 3 completed WIF private keys in less than 1 second**.

## Appendix:

For reference, I appended the Python script but it's not my work, all credits go to [/u/dooglus/](https://www.reddit.com/user/dooglus/). I just can confirm that it does what I described above (but ask others to confirm this and try it with other private keys before you trust it with your real private key):

```
#!/usr/bin/env python3

import base58, sys

partial = sys.argv[1]

if len(partial) != 45:
    print("partial key should be 45 characters")
    sys.exit(1)

results = {}
for c in '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz':
    wif = base58.b58encode_check(base58.b58decode(partial + c*7)[:33] + b'\x01').decode('ascii')
    if wif[:45] == partial: results[wif] = True

for k in results.keys(): print(k)

```

> **Comments:**
> **username_0**: Thank you very much, I will try this method  
> **username_5**: Thanks for crediting me as you did. This whole question was only recently brought to my attention.  
> **username_4**: @username_5-username_5: of course, credit where credit is due. It was your work. You are welcome! :-)  

---

### Answer by username_6 on 2020-09-10. Score: 2

It has to be brute forced. There are a couple of ways but basically it is replacing each character by base-58 chars and checking the key.  
The amount of time that process takes depends on the number of characters missing and slightly on whether the key is compressed or uncompressed and a little on your luck.

However if your key is compressed and is missing up to 11 characters or is uncompressed and is missing up to 9 characters *from its end* (which seems to be the case from your screenshot) it can be recovered within seconds.

Check out [FinderOuter](https://github.com/username_6/FinderOuter) on GitHub. The Missing Base58 option handles your case. You'll have to enter the characters you already have and replace the missing ones with a special char like `*` then enter your address in second box and click `Find`.  
Full disclosure: I'm the developer of The FinderOuter.  
P.S. The released version (0.4.1) is old and doesn't have the optimization mentioned above, you'll have to compile the code yourself or wait for 0.5.0.  
Edit: Version 0.5.0 released on 2020-09-17 and can recovery this special case with up to 11 missing chars from end.

> **Comments:**
> **username_0**: Unfortunately, I don't understand programming. My laptop has windows 10.  
> **username_2**: @username_0: If I offered you a quarter of a million dollars to spend a week or two learning programming, would you consider it?  
> **username_7**: @username_2 even if it took a year to learn enough to complete this task, thats still a great wage for the time spent.  
> **username_0**: Unfortunately, I don’t have the money and a quick fix would be good.  
> **username_8**: @username_0 You don't need to spend money to recover this wallet, you can learn all of those things on Youtube for free. Keep in mind that even if it takes a long time this is a lot of money, so it is worth it.  

---

